This commit is contained in:
J. Nick Koston 2023-06-09 16:45:53 -05:00
parent e5ec9f3350
commit a360ebae77
No known key found for this signature in database
1 changed files with 31 additions and 30 deletions

View File

@ -22,27 +22,28 @@ namespace ratgdo {
} }
void RATGDOLightOutput::set_state(esphome::ratgdo::LightState state) void RATGDOLightOutput::set_state(esphome::ratgdo::LightState state)
bool is_on = state == LightState::LIGHT_STATE_ON; bool is_on
= state == LightState::LIGHT_STATE_ON;
this->light_state_->current_values.set_state(is_on); this->light_state_->current_values.set_state(is_on);
this->light_state_->remote_values.set_state(is_on); this->light_state_->remote_values.set_state(is_on);
this->light_state_->publish_state(); this->light_state_->publish_state();
} }
void RATGDOLightOutput::setup_state(light::LightState* light_state) void RATGDOLightOutput::setup_state(light::LightState* light_state)
{ {
esphome::ratgdo::LightState state = this->parent_->getLightState(); esphome::ratgdo::LightState state = this->parent_->getLightState();
ESP_LOGD(TAG,"setup_state: getLightState: %d", state) ESP_LOGD(TAG, "setup_state: getLightState: %d", state)
this->light_state_ = light_state; this->light_state_ = light_state;
this->set_state(state); this->set_state(state);
} }
LightTraits RATGDOLightOutput::get_traits() LightTraits RATGDOLightOutput::get_traits()
{ {
auto traits = LightTraits(); auto traits = LightTraits();
traits.set_supported_color_modes({ light::ColorMode::ON_OFF }); traits.set_supported_color_modes({ light::ColorMode::ON_OFF });
return traits; return traits;
} }
void RATGDOLightOutput::write_state(light::LightState* state) void RATGDOLightOutput::write_state(light::LightState* state)
{ {
bool binary; bool binary;
state->current_values_as_binary(&binary); state->current_values_as_binary(&binary);
if (binary) { if (binary) {
@ -52,7 +53,7 @@ namespace ratgdo {
ESP_LOGD(TAG, "output call lightOff"); ESP_LOGD(TAG, "output call lightOff");
this->parent_->lightOff(); this->parent_->lightOff();
} }
} }
} // namespace ratgdo } // namespace ratgdo
} // namespace esphome } // namespace esphome