ESPHome 2026.5.1
Loading...
Searching...
No Matches
dfrobot_sen0395_switch.cpp
Go to the documentation of this file.
2
4
5void Sen0395PowerSwitch::write_state(bool state) { this->parent_->enqueue(make_unique<PowerCommand>(state)); }
6
8 bool was_active = false;
9 if (this->parent_->is_active()) {
10 was_active = true;
11 this->parent_->enqueue(make_unique<PowerCommand>(false));
12 }
13 this->parent_->enqueue(make_unique<LedModeCommand>(state));
14 this->parent_->enqueue(make_unique<SaveCfgCommand>());
15 if (was_active) {
16 this->parent_->enqueue(make_unique<PowerCommand>(true));
17 }
18}
19
21 bool was_active = false;
22 if (this->parent_->is_active()) {
23 was_active = true;
24 this->parent_->enqueue(make_unique<PowerCommand>(false));
25 }
26 this->parent_->enqueue(make_unique<UartOutputCommand>(state));
27 this->parent_->enqueue(make_unique<SaveCfgCommand>());
28 if (was_active) {
29 this->parent_->enqueue(make_unique<PowerCommand>(true));
30 }
31}
32
34 bool was_active = false;
35 if (this->parent_->is_active()) {
36 was_active = true;
37 this->parent_->enqueue(make_unique<PowerCommand>(false));
38 }
39 this->parent_->enqueue(make_unique<SensorCfgStartCommand>(state));
40 this->parent_->enqueue(make_unique<SaveCfgCommand>());
41 if (was_active) {
42 this->parent_->enqueue(make_unique<PowerCommand>(true));
43 }
44}
45
46} // namespace esphome::dfrobot_sen0395
bool state
The current reported state of the binary sensor.
Definition switch.h:55
bool state
Definition fan.h:2