ESPHome 2026.11.0b6
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 // apply_() and publish_state() take the level, which an inverted switch flips
12 const bool level = *initial != this->is_inverted();
13 this->apply_(level, false);
14 this->publish_state(level);
15 }
16}
17
18void HaierTundraSwitch::dump_config() { LOG_SWITCH("", "Haier Tundra Switch", this); }
19
21 // Quiet and Turbo can only be turned on in Cool or Heat mode
23 this->parent_->mode != climate::CLIMATE_MODE_HEAT) {
24 return;
25 }
26 this->apply_(state, true);
27 this->publish_state(state);
28}
29
30void HaierTundraSwitch::apply_(bool state, bool transmit) {
31 switch (this->kind_) {
33 this->parent_->set_health_mode(state, transmit);
34 break;
36 this->parent_->set_quiet_mode(state, transmit);
37 break;
39 this->parent_->set_turbo_mode(state, transmit);
40 break;
41 }
42}
43
44} // namespace esphome::haier_tundra
bool state
The current reported state of the binary sensor.
Definition switch.h:60
void publish_state(bool state)
Publish a state to the front-end from the back-end.
Definition switch.cpp:75
optional< bool > get_initial_state_with_restore_mode()
Returns the initial state of the switch, after applying restore mode rules.
Definition switch.cpp:49
bool is_inverted() const
Definition switch.h:132
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.switch")