mirror of
				https://github.com/esphome/esphome.git
				synced 2025-10-31 15:12:06 +00:00 
			
		
		
		
	fixes
This commit is contained in:
		| @@ -379,12 +379,19 @@ void ESP32TouchComponent::loop() { | |||||||
|       continue; |       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; |       uint32_t time_diff = now - last_time; | ||||||
|  |  | ||||||
|       // Check if we haven't seen this pad recently |       // 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 |         // Haven't seen this pad recently, assume it's released | ||||||
|         child->last_state_ = false; |         child->last_state_ = false; | ||||||
|         child->publish_state(false); |         child->publish_state(false); | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user