ESPHome 2026.11.0-dev
Loading...
Searching...
No Matches
haier_tundra_switch.cpp
Go to the documentation of this file.
2#include "esphome/core/log.h"
3
4namespace esphome::haier_tundra {
5
6ESPHOME_LOG_TAG(TAG, "haier_tundra.switch");
7
9 auto initial = this->get_initial_state_with_restore_mode();
10 if (initial.has_value()) {
11 const bool state = initial.value();
12 this->apply_(state, false);
13 this->publish_state(state);
14 }
15}
16
17void HaierTundraSwitch::dump_config() { LOG_SWITCH("", "Haier Tundra Switch", this); }
18
20 // Quiet and Turbo can only be turned on in Cool or Heat mode
22 this->parent_->mode != climate::CLIMATE_MODE_HEAT) {
23 return;
24 }
25 this->apply_(state, true);
26 this->publish_state(state);
27}
28
29void HaierTundraSwitch::apply_(bool state, bool transmit) {
30 switch (this->kind_) {
32 this->parent_->set_health_mode(state, transmit);
33 break;
35 this->parent_->set_quiet_mode(state, transmit);
36 break;
38 this->parent_->set_turbo_mode(state, transmit);
39 break;
40 }
41}
42
43} // namespace esphome::haier_tundra
bool state
The current reported state of the binary sensor.
Definition switch.h:55
void publish_state(bool state)
Publish a state to the front-end from the back-end.
Definition switch.cpp:56
optional< bool > get_initial_state_with_restore_mode()
Returns the initial state of the switch, after applying restore mode rules.
Definition switch.cpp:42
bool state
Definition fan.h:2
@ CLIMATE_MODE_HEAT
The climate device is set to heat to reach the target temperature.
@ CLIMATE_MODE_COOL
The climate device is set to cool to reach the target temperature.
ESPHOME_LOG_TAG(TAG, "haier_tundra.button")