This commit is contained in:
J. Nick Koston 2023-06-07 19:38:21 -05:00
parent 732b3b2670
commit ca42a12213
No known key found for this signature in database
2 changed files with 5 additions and 6 deletions

View File

@ -16,10 +16,9 @@ namespace ratgdo {
void RATGDOLightOutput::on_light_state(esphome::ratgdo::LightState state)
{
ESP_LOGD(TAG, "on_light_state: %d", state);
this->_is_on = state == LightState::LIGHT_STATE_ON;
if (this->light_state_) {
auto call = this->light_state_->make_call();
call.set_state(this->_is_on);
call.set_state(state == LightState::LIGHT_STATE_ON);
call.perform();
}
}
@ -34,14 +33,15 @@ namespace ratgdo {
{
bool binary;
state->current_values_as_binary(&binary);
if (binary == this->_is_on)
if (binary == state == LightState::LIGHT_STATE_ON)
return;
if (binary) {
ESP_LOGD(TAG, "output call lightOn");
this->parent_->lightOn();
} else {
ESP_LOGD(TAG, "output call lightOff");
this->parent_->lightOff();
}
this->_is_on = binary;
}
} // namespace ratgdo

View File

@ -17,10 +17,9 @@ namespace ratgdo {
void setup_state(light::LightState* state) override { this->light_state_ = state; }
light::LightState* get_state() { return this->light_state_; }
void on_light_state(LightState state) override;
void on_light_state(esphome::ratgdo::LightState state) override;
protected:
bool _is_on;
light::LightState* light_state_;
};