Avoid polling for GPIO binary sensors when possible

This commit is contained in:
J. Nick Koston
2025-06-17 13:20:41 +02:00
parent 2bbe08cee0
commit e8547b16f6

View File

@@ -21,10 +21,13 @@ class GPIOBinarySensorStore {
}
bool has_changed() {
InterruptLock lock;
bool changed = this->changed_;
// No lock needed: single writer (ISR) / single reader (main loop) pattern
// Volatile bool operations are atomic on all ESPHome-supported platforms
if (!this->changed_) {
return false;
}
this->changed_ = false;
return changed;
return true;
}
protected: