fix light state

This commit is contained in:
J. Nick Koston 2023-06-07 17:14:35 -05:00
parent d5b7fd25fd
commit 4363a25119
No known key found for this signature in database
2 changed files with 12 additions and 4 deletions

View File

@ -16,7 +16,15 @@ namespace ratgdo {
void RATGDOLightOutput::on_motion_state(MotionState state) { }
void RATGDOLightOutput::on_obstruction_state(ObstructionState state) { }
void RATGDOLightOutput::on_door_state(DoorState state) { }
void RATGDOLightOutput::on_light_state(LightState state) { }
void RATGDOLightOutput::on_light_state(LightState state)
{
ESP_LOGD(TAG, "name: %s on_light_state: %d", this->get_name(), state);
if (this->light_state_) {
auto call = this->light_state_->make_call();
call.set_state(state == LightState::LIGHT_STATE_ON);
call.perform();
}
}
void RATGDOLightOutput::on_lock_state(LockState state) { }
LightTraits RATGDOLightOutput::get_traits()

View File

@ -14,8 +14,8 @@ namespace ratgdo {
void dump_config() override;
light::LightTraits get_traits() override;
void write_state(light::LightState* state) override;
void setup_state(light::LightState* state) override { this->state_ = state; }
light::LightState* get_state() { return this->state_; }
void setup_state(light::LightState* state) override { this->light_state_ = state; }
light::LightState* get_state() { return this->light_state_; }
void on_motion_state(MotionState state) override;
void on_obstruction_state(ObstructionState state) override;
@ -25,7 +25,7 @@ namespace ratgdo {
protected:
bool _is_on;
light::LightState* state_;
light::LightState* light_state_;
};
} // namespace ratgdo