From e5ec9f3350757775145944c2987848a40cdf764d Mon Sep 17 00:00:00 2001 From: "J. Nick Koston" Date: Fri, 9 Jun 2023 16:45:49 -0500 Subject: [PATCH] loop --- .../ratgdo/light/ratgdo_light_output.cpp | 18 ++++++++++-------- components/ratgdo/light/ratgdo_light_output.h | 2 +- 2 files changed, 11 insertions(+), 9 deletions(-) diff --git a/components/ratgdo/light/ratgdo_light_output.cpp b/components/ratgdo/light/ratgdo_light_output.cpp index afcafa2..784a248 100644 --- a/components/ratgdo/light/ratgdo_light_output.cpp +++ b/components/ratgdo/light/ratgdo_light_output.cpp @@ -17,20 +17,22 @@ namespace ratgdo { { ESP_LOGD(TAG, "on_light_state: %d", state); if (this->light_state_) { - set_state(this->light_state_, state); + set_state(state); } } - void RATGDOLightOutput::set_state(light::LightState* light_state, esphome::ratgdo::LightState state) + void RATGDOLightOutput::set_state(esphome::ratgdo::LightState state) bool is_on = state == LightState::LIGHT_STATE_ON; - light_state->current_values.set_state(is_on); - light_state->remote_values.set_state(is_on); - light_state->publish_state(); + 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* state) + void RATGDOLightOutput::setup_state(light::LightState* light_state) { - this->light_state_ = state; - this->set_state(state, this->parent_->getLightState()); + 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() { diff --git a/components/ratgdo/light/ratgdo_light_output.h b/components/ratgdo/light/ratgdo_light_output.h index 3514764..4dee47c 100644 --- a/components/ratgdo/light/ratgdo_light_output.h +++ b/components/ratgdo/light/ratgdo_light_output.h @@ -15,7 +15,7 @@ namespace ratgdo { light::LightTraits get_traits() override; void write_state(light::LightState* state) override; void setup_state(light::LightState* state) override; - void set_state(light::LightState* light_state, esphome::ratgdo::LightState state); + void set_state(esphome::ratgdo::LightState state); light::LightState* get_state() { return this->light_state_; } void on_light_state(esphome::ratgdo::LightState state) override;