diff --git a/esphome/components/esp32_touch/esp32_touch.h b/esphome/components/esp32_touch/esp32_touch.h index 6da2defe7d..48d962b881 100644 --- a/esphome/components/esp32_touch/esp32_touch.h +++ b/esphome/components/esp32_touch/esp32_touch.h @@ -178,7 +178,9 @@ class ESP32TouchBinarySensor : public binary_sensor::BinarySensor { touch_pad_t get_touch_pad() const { return this->touch_pad_; } uint32_t get_threshold() const { return this->threshold_; } void set_threshold(uint32_t threshold) { this->threshold_ = threshold; } +#ifdef USE_ESP32_VARIANT_ESP32 uint32_t get_value() const { return this->value_; } +#endif uint32_t get_wakeup_threshold() const { return this->wakeup_threshold_; } protected: @@ -186,7 +188,9 @@ class ESP32TouchBinarySensor : public binary_sensor::BinarySensor { touch_pad_t touch_pad_{TOUCH_PAD_MAX}; uint32_t threshold_{0}; +#ifdef USE_ESP32_VARIANT_ESP32 uint32_t value_{0}; +#endif bool last_state_{false}; const uint32_t wakeup_threshold_{0}; }; diff --git a/esphome/components/esp32_touch/esp32_touch_v2.cpp b/esphome/components/esp32_touch/esp32_touch_v2.cpp index fdf02932ae..3bd2a6c937 100644 --- a/esphome/components/esp32_touch/esp32_touch_v2.cpp +++ b/esphome/components/esp32_touch/esp32_touch_v2.cpp @@ -270,8 +270,6 @@ void ESP32TouchComponent::loop() { touch_pad_read_benchmark(child->get_touch_pad(), &value); } - child->value_ = value; - // For S2/S3 v2, higher value means touched (opposite of v1) bool is_touched = value > child->get_threshold(); child->last_state_ = is_touched; @@ -307,8 +305,6 @@ void ESP32TouchComponent::loop() { touch_pad_read_benchmark(event.pad, &value); } - child->value_ = value; - // Update state if changed if (child->last_state_ != is_touch_event) { child->last_state_ = is_touch_event;