ESPHome 2026.6.0-dev
Loading...
Searching...
No Matches
gree_switch.cpp
Go to the documentation of this file.
1#include "gree_switch.h"
2#include "esphome/core/log.h"
3
4namespace esphome::gree {
5
6static const char *const TAG = "gree.switch";
7
9 auto initial = this->get_initial_state_with_restore_mode();
10 if (initial.has_value()) {
11 this->write_state(*initial);
12 }
13}
14
15void GreeModeBitSwitch::dump_config() { log_switch(TAG, " ", this->name_, this); }
16
18 this->parent_->set_mode_bit(this->bit_mask_, state);
19 this->publish_state(state);
20}
21
22} // namespace esphome::gree
void write_state(bool state) override
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