This commit is contained in:
J. Nick Koston 2023-06-07 19:45:01 -05:00
parent 3c0f829053
commit 2c9b6e9d65
No known key found for this signature in database
2 changed files with 6 additions and 3 deletions

View File

@ -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();

View File

@ -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;
}
}