From 2bbe08cee03f5c23c600d19015f1cb4adc696e2d Mon Sep 17 00:00:00 2001 From: "J. Nick Koston" Date: Tue, 17 Jun 2025 13:18:45 +0200 Subject: [PATCH] Avoid polling for GPIO binary sensors when possible --- esphome/components/gpio/binary_sensor/gpio_binary_sensor.h | 3 +++ 1 file changed, 3 insertions(+) diff --git a/esphome/components/gpio/binary_sensor/gpio_binary_sensor.h b/esphome/components/gpio/binary_sensor/gpio_binary_sensor.h index 960fa427f4..e517376d0f 100644 --- a/esphome/components/gpio/binary_sensor/gpio_binary_sensor.h +++ b/esphome/components/gpio/binary_sensor/gpio_binary_sensor.h @@ -36,6 +36,9 @@ class GPIOBinarySensorStore { class GPIOBinarySensor : public binary_sensor::BinarySensor, public Component { public: + // No destructor needed: ESPHome components are created at boot and live forever. + // Interrupts are only detached on reboot when memory is cleared anyway. + void set_pin(GPIOPin *pin) { pin_ = pin; } void set_use_interrupt(bool use_interrupt) { use_interrupt_ = use_interrupt; } void set_interrupt_type(gpio::InterruptType type) { interrupt_type_ = type; }