[gpio] Use constexpr uint32_t timer ID for interlock timeout (#15010)

This commit is contained in:
J. Nick Koston
2026-03-20 15:00:56 -10:00
committed by GitHub
parent 2d39cc2540
commit 12ead0408a

View File

@@ -5,6 +5,7 @@ namespace esphome {
namespace gpio {
static const char *const TAG = "switch.gpio";
static constexpr uint32_t INTERLOCK_TIMEOUT_ID = 0;
float GPIOSwitch::get_setup_priority() const { return setup_priority::HARDWARE; }
void GPIOSwitch::setup() {
@@ -51,7 +52,7 @@ void GPIOSwitch::write_state(bool state) {
}
}
if (found && this->interlock_wait_time_ != 0) {
this->set_timeout("interlock", this->interlock_wait_time_, [this, state] {
this->set_timeout(INTERLOCK_TIMEOUT_ID, this->interlock_wait_time_, [this, state] {
// Don't write directly, call the function again
// (some other switch may have changed state while we were waiting)
this->write_state(state);
@@ -61,7 +62,7 @@ void GPIOSwitch::write_state(bool state) {
} else if (this->interlock_wait_time_ != 0) {
// If we are switched off during the interlock wait time, cancel any pending
// re-activations
this->cancel_timeout("interlock");
this->cancel_timeout(INTERLOCK_TIMEOUT_ID);
}
this->pin_->digital_write(state);