[esp32_touch] Fix initial state never published when sensor untouched (#15032)

This commit is contained in:
Jonathan Swoboda
2026-03-20 19:53:02 -04:00
committed by Jesse Hills
parent 3fe84eadef
commit 0bf6e1e839

View File

@@ -360,11 +360,16 @@ void ESP32TouchComponent::loop() {
}
// Publish initial OFF state for sensors that haven't received events yet
bool all_initial_published = true;
for (auto *child : this->children_) {
this->publish_initial_state_if_needed_(child, now);
if (!child->initial_state_published_) {
all_initial_published = false;
}
}
if (!this->setup_mode_) {
// Only disable loop once all initial states are published
if (!this->setup_mode_ && all_initial_published) {
this->disable_loop();
}
}