diff --git a/components/ratgdo/light/ratgdo_light_output.cpp b/components/ratgdo/light/ratgdo_light_output.cpp index e662e6c..b73743b 100644 --- a/components/ratgdo/light/ratgdo_light_output.cpp +++ b/components/ratgdo/light/ratgdo_light_output.cpp @@ -32,10 +32,7 @@ namespace ratgdo { void RATGDOLightOutput::write_state(light::LightState* state) { bool binary; - bool currentState = this->parent_->lightState == esphome::ratgdo::LightState::LIGHT_STATE_ON; state->current_values_as_binary(&binary); - if (binary == currentState) - return; if (binary) { ESP_LOGD(TAG, "output call lightOn"); this->parent_->lightOn(); diff --git a/components/ratgdo/ratgdo.cpp b/components/ratgdo/ratgdo.cpp index d001a14..761875b 100644 --- a/components/ratgdo/ratgdo.cpp +++ b/components/ratgdo/ratgdo.cpp @@ -576,6 +576,9 @@ namespace ratgdo { ESP_LOGD(TAG, "The light is already on"); } else { toggleLight(); + // We don't always get the state back so be optimistic + this->previousLightState = this->lightState; + this->lightState = LightState::LIGHT_STATE_ON; } } @@ -585,6 +588,9 @@ namespace ratgdo { ESP_LOGD(TAG, "The light is already off"); } else { toggleLight(); + // We don't always get the state back so be optimistic + this->previousLightState = this->lightState; + this->lightState = LightState::LIGHT_STATE_OFF; } }