1
0
mirror of https://github.com/esphome/esphome.git synced 2025-10-30 06:33:51 +00:00
This commit is contained in:
J. Nick Koston
2025-06-12 10:27:22 -05:00
parent 0bd4c333bd
commit 5fca1be44d

View File

@@ -379,12 +379,19 @@ void ESP32TouchComponent::loop() {
continue;
}
if (child->last_state_) {
uint32_t last_time = this->last_touch_time_[pad];
uint32_t last_time = this->last_touch_time_[pad];
// If we've never seen this pad touched (last_time == 0) and enough time has passed
// since startup, publish OFF state and mark as published with value 1
if (last_time == 0 && now > this->release_timeout_ms_) {
child->publish_state(false);
this->last_touch_time_[pad] = 1; // Mark as "initial state published"
ESP_LOGD(TAG, "Touch Pad '%s' state: OFF (initial)", child->get_name().c_str());
} else if (child->last_state_) {
uint32_t time_diff = now - last_time;
// Check if we haven't seen this pad recently
if (last_time == 0 || time_diff > this->release_timeout_ms_) {
if (time_diff > this->release_timeout_ms_) {
// Haven't seen this pad recently, assume it's released
child->last_state_ = false;
child->publish_state(false);