1
0
mirror of https://github.com/esphome/esphome.git synced 2025-09-06 13:22:19 +01:00

[switch] Add control() method to API (#10118)

This commit is contained in:
Edward Firmo
2025-08-08 07:51:19 +02:00
committed by GitHub
parent 7e4d09dbd8
commit 676c51ffa0
3 changed files with 17 additions and 5 deletions

View File

@@ -46,11 +46,7 @@ template<typename... Ts> class ControlAction : public Action<Ts...> {
void play(Ts... x) override {
auto state = this->state_.optional_value(x...);
if (state.has_value()) {
if (*state) {
this->switch_->turn_on();
} else {
this->switch_->turn_off();
}
this->switch_->control(*state);
}
}