From ea3ea1eee7045f9b5eef752ed1480d9e29b7085b Mon Sep 17 00:00:00 2001 From: "J. Nick Koston" Date: Tue, 17 Jun 2025 14:17:35 +0200 Subject: [PATCH 1/2] tweak --- esphome/components/gpio/binary_sensor/gpio_binary_sensor.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/esphome/components/gpio/binary_sensor/gpio_binary_sensor.cpp b/esphome/components/gpio/binary_sensor/gpio_binary_sensor.cpp index fcb2696090..4a12ef834e 100644 --- a/esphome/components/gpio/binary_sensor/gpio_binary_sensor.cpp +++ b/esphome/components/gpio/binary_sensor/gpio_binary_sensor.cpp @@ -29,7 +29,7 @@ void GPIOBinarySensorStore::setup(InternalGPIOPin *pin, gpio::InterruptType type void GPIOBinarySensor::setup() { if (this->use_interrupt_ && !this->pin_->is_internal()) { - ESP_LOGW(TAG, "Interrupts not supported for this pin type, falling back to polling"); + ESP_LOGD(TAG, "GPIO is not internal, falling back to polling mode"); this->use_interrupt_ = false; } From 685ed87581068441c029ff13154aa76e5822a304 Mon Sep 17 00:00:00 2001 From: "J. Nick Koston" Date: Tue, 17 Jun 2025 14:38:00 +0200 Subject: [PATCH 2/2] preen --- esphome/components/gpio/binary_sensor/gpio_binary_sensor.h | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/esphome/components/gpio/binary_sensor/gpio_binary_sensor.h b/esphome/components/gpio/binary_sensor/gpio_binary_sensor.h index 17f7b4eb19..a25f8fc7fe 100644 --- a/esphome/components/gpio/binary_sensor/gpio_binary_sensor.h +++ b/esphome/components/gpio/binary_sensor/gpio_binary_sensor.h @@ -24,6 +24,13 @@ class GPIOBinarySensorStore { bool has_changed() { // No lock needed: single writer (ISR) / single reader (main loop) pattern // Volatile bool operations are atomic on all ESPHome-supported platforms + // + // Note: There's a benign race where ISR could set changed_ = true between + // our read and clear. This is intentional and causes no issues because: + // 1. We'll process the state change on the next loop iteration + // 2. Multiple rapid changes between loop iterations would only result in + // one update anyway (we only care about the final state) + // 3. This avoids the overhead of atomic operations in the ISR if (!this->changed_) { return false; }