cleanups
This commit is contained in:
parent
3c0f829053
commit
2c9b6e9d65
|
@ -32,10 +32,7 @@ namespace ratgdo {
|
||||||
void RATGDOLightOutput::write_state(light::LightState* state)
|
void RATGDOLightOutput::write_state(light::LightState* state)
|
||||||
{
|
{
|
||||||
bool binary;
|
bool binary;
|
||||||
bool currentState = this->parent_->lightState == esphome::ratgdo::LightState::LIGHT_STATE_ON;
|
|
||||||
state->current_values_as_binary(&binary);
|
state->current_values_as_binary(&binary);
|
||||||
if (binary == currentState)
|
|
||||||
return;
|
|
||||||
if (binary) {
|
if (binary) {
|
||||||
ESP_LOGD(TAG, "output call lightOn");
|
ESP_LOGD(TAG, "output call lightOn");
|
||||||
this->parent_->lightOn();
|
this->parent_->lightOn();
|
||||||
|
|
|
@ -576,6 +576,9 @@ namespace ratgdo {
|
||||||
ESP_LOGD(TAG, "The light is already on");
|
ESP_LOGD(TAG, "The light is already on");
|
||||||
} else {
|
} else {
|
||||||
toggleLight();
|
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");
|
ESP_LOGD(TAG, "The light is already off");
|
||||||
} else {
|
} else {
|
||||||
toggleLight();
|
toggleLight();
|
||||||
|
// We don't always get the state back so be optimistic
|
||||||
|
this->previousLightState = this->lightState;
|
||||||
|
this->lightState = LightState::LIGHT_STATE_OFF;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue