This commit is contained in:
J. Nick Koston 2023-06-09 15:58:55 -05:00
parent 025ab70a3b
commit f8262a0cfa
No known key found for this signature in database
2 changed files with 8 additions and 11 deletions

View File

@ -17,16 +17,14 @@ namespace ratgdo {
{ {
this->state(state == LockState::LOCK_STATE_LOCKED) this->publish_state(); this->state(state == LockState::LOCK_STATE_LOCKED) this->publish_state();
} }
void RATGDOSwitch::turn_on() void RATGDOSwitch::write_state(bool state)
{ {
ESP_LOGD(TAG, "name: %s this->type_:%d ON", this->get_name(), this->switch_type_); ESP_LOGD(TAG, "name: %s this->type_:%d state: %d", this->get_name(), this->switch_type_, state);
this->parent_->lock(value); if (state) {
this->publish_state(value); this->parent_->lock(value);
} } else {
void RATGDOSwitch::turn_off() this->parent_->unlock(value);
{ }
ESP_LOGD(TAG, "name: %s this->type_:%d OFF", this->get_name(), this->switch_type_);
this->parent_->unlock(value);
this->publish_state(value); this->publish_state(value);
} }

View File

@ -19,8 +19,7 @@ namespace ratgdo {
void set_switch_type(SwitchType switch_type_) { this->switch_type_ = switch_type_; } void set_switch_type(SwitchType switch_type_) { this->switch_type_ = switch_type_; }
void on_lock_state(LockState state) override; void on_lock_state(LockState state) override;
void turn_off() override; void write_state(bool state) override;
void turn_on() override;
protected: protected:
SwitchType switch_type_; SwitchType switch_type_;