From be8461082f979943213a9cb7ad1553333e076e12 Mon Sep 17 00:00:00 2001 From: "J. Nick Koston" Date: Fri, 9 Jun 2023 16:46:28 -0500 Subject: [PATCH] loop --- .../ratgdo/light/ratgdo_light_output.cpp | 61 ++++++++++--------- 1 file changed, 31 insertions(+), 30 deletions(-) diff --git a/components/ratgdo/light/ratgdo_light_output.cpp b/components/ratgdo/light/ratgdo_light_output.cpp index f16c260..dfb8dbd 100644 --- a/components/ratgdo/light/ratgdo_light_output.cpp +++ b/components/ratgdo/light/ratgdo_light_output.cpp @@ -21,39 +21,40 @@ namespace ratgdo { } } void RATGDOLightOutput::set_state(esphome::ratgdo::LightState state) + { bool is_on - = state == LightState::LIGHT_STATE_ON; - this->light_state_->current_values.set_state(is_on); - this->light_state_->remote_values.set_state(is_on); - this->light_state_->publish_state(); -} -void RATGDOLightOutput::setup_state(light::LightState* light_state) -{ - esphome::ratgdo::LightState state = this->parent_->getLightState(); - ESP_LOGD(TAG, "setup_state: getLightState: %d", state) - this->light_state_ = light_state; - this->set_state(state); -} -LightTraits RATGDOLightOutput::get_traits() -{ - auto traits = LightTraits(); - traits.set_supported_color_modes({ light::ColorMode::ON_OFF }); - return traits; -} - -void RATGDOLightOutput::write_state(light::LightState* state) -{ - bool binary; - state->current_values_as_binary(&binary); - if (binary) { - ESP_LOGD(TAG, "output call lightOn"); - this->parent_->lightOn(); - } else { - ESP_LOGD(TAG, "output call lightOff"); - this->parent_->lightOff(); + = state == LightState::LIGHT_STATE_ON; + this->light_state_->current_values.set_state(is_on); + this->light_state_->remote_values.set_state(is_on); + this->light_state_->publish_state(); + } + void RATGDOLightOutput::setup_state(light::LightState* light_state) + { + esphome::ratgdo::LightState state = this->parent_->getLightState(); + ESP_LOGD(TAG, "setup_state: getLightState: %d", state) + this->light_state_ = light_state; + this->set_state(state); + } + LightTraits RATGDOLightOutput::get_traits() + { + auto traits = LightTraits(); + traits.set_supported_color_modes({ light::ColorMode::ON_OFF }); + return traits; + } + + void RATGDOLightOutput::write_state(light::LightState* state) + { + bool binary; + state->current_values_as_binary(&binary); + if (binary) { + ESP_LOGD(TAG, "output call lightOn"); + this->parent_->lightOn(); + } else { + ESP_LOGD(TAG, "output call lightOff"); + this->parent_->lightOff(); + } } -} } // namespace ratgdo } // namespace esphome