This commit is contained in:
J. Nick Koston 2023-06-09 16:38:59 -05:00
parent 0c3a3d0a4c
commit 8e5b65c2e6
No known key found for this signature in database
3 changed files with 13 additions and 7 deletions

View File

@ -17,18 +17,19 @@ namespace ratgdo {
{
ESP_LOGD(TAG, "on_light_state: %d", state);
if (this->light_state_) {
this->light_state_->current_values.set_state(state == LightState::LIGHT_STATE_ON);
this->light_state_->remote_values.set_state(state == LightState::LIGHT_STATE_ON);
this->light_state_->publish_state();
set_state(this->light_state_, state);
}
}
void RATGDOLightOutput::set_state(light::LightState* light_state, esphome::ratgdo::LightState state)
{
light_state->current_values.set_state(is_on);
light_state->remote_values.set_state(is_on);
light_state->publish_state();
}
void RATGDOLightOutput::setup_state(light::LightState* state)
{
bool is_on = this->parent_->isLightOn();
this->light_state_ = state;
state->current_values.set_state(is_on);
state->remote_values.set_state(is_on);
state->publish_state();
this->set_state(state, this->parent_->getLightState());
}
LightTraits RATGDOLightOutput::get_traits()
{

View File

@ -497,6 +497,10 @@ namespace ratgdo {
this->children_.push_back(obj);
obj->set_parent(this);
}
LightState RATGDOComponent::get_light_state()
{
return static_cast<LightState>(this->lightState);
}
} // namespace ratgdo
} // namespace esphome

View File

@ -142,6 +142,7 @@ namespace ratgdo {
void sendRollingCodeChanged();
void setRollingCodeCounter(uint32_t counter);
void sendCommandAndSaveCounter(cmd command);
LightState RATGDOComponent::get_light_state();
/** Register a child component. */
void register_child(RATGDOClient* obj);