ESPHome
2026.6.0-dev
Loading...
Searching...
No Matches
esphome
components
gree
switch
gree_switch.cpp
Go to the documentation of this file.
1
#include "
gree_switch.h
"
2
#include "
esphome/core/log.h
"
3
4
namespace
esphome::gree
{
5
6
static
const
char
*
const
TAG =
"gree.switch"
;
7
8
void
GreeModeBitSwitch::setup
() {
9
auto
initial = this->
get_initial_state_with_restore_mode
();
10
if
(initial.has_value()) {
11
this->
write_state
(*initial);
12
}
13
}
14
15
void
GreeModeBitSwitch::dump_config
() { log_switch(TAG,
" "
, this->
name_
,
this
); }
16
17
void
GreeModeBitSwitch::write_state
(
bool
state
) {
18
this->
parent_
->set_mode_bit(this->
bit_mask_
, state);
19
this->
publish_state
(state);
20
}
21
22
}
// namespace esphome::gree
esphome::Parented< GreeClimate >::parent_
GreeClimate * parent_
Definition
helpers.h:1872
esphome::gree::GreeModeBitSwitch::name_
const char * name_
Definition
gree_switch.h:18
esphome::gree::GreeModeBitSwitch::write_state
void write_state(bool state) override
Definition
gree_switch.cpp:17
esphome::gree::GreeModeBitSwitch::setup
void setup() override
Definition
gree_switch.cpp:8
esphome::gree::GreeModeBitSwitch::dump_config
void dump_config() override
Definition
gree_switch.cpp:15
esphome::gree::GreeModeBitSwitch::bit_mask_
uint8_t bit_mask_
Definition
gree_switch.h:19
esphome::switch_::Switch::publish_state
void publish_state(bool state)
Publish a state to the front-end from the back-end.
Definition
switch.cpp:56
esphome::switch_::Switch::get_initial_state_with_restore_mode
optional< bool > get_initial_state_with_restore_mode()
Returns the initial state of the switch, after applying restore mode rules.
Definition
switch.cpp:42
state
bool state
Definition
fan.h:2
gree_switch.h
log.h
esphome::gree
Definition
gree.cpp:4
Generated by
1.12.0