mirror of
https://github.com/esphome/esphome.git
synced 2025-11-19 16:25:50 +00:00
[switch] Add control() method to API (#10118)
This commit is contained in:
@@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user