mirror of
https://github.com/esphome/esphome.git
synced 2026-05-27 20:53:46 +08:00
[esp32_touch] Fix initial state never published when sensor untouched (#15032)
This commit is contained in:
committed by
Jesse Hills
parent
3fe84eadef
commit
0bf6e1e839
@@ -360,11 +360,16 @@ void ESP32TouchComponent::loop() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Publish initial OFF state for sensors that haven't received events yet
|
// Publish initial OFF state for sensors that haven't received events yet
|
||||||
|
bool all_initial_published = true;
|
||||||
for (auto *child : this->children_) {
|
for (auto *child : this->children_) {
|
||||||
this->publish_initial_state_if_needed_(child, now);
|
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();
|
this->disable_loop();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user