ESPHome 2026.11.0b6
Loading...
Searching...
No Matches
sendspin_switch.cpp
Go to the documentation of this file.
1#include "sendspin_switch.h"
2
3#if defined(USE_ESP_IDF) && defined(USE_SENDSPIN_SWITCH)
4
5#include "esphome/core/log.h"
7
8namespace esphome::sendspin_ {
9
10ESPHOME_LOG_TAG(TAG, "sendspin.switch");
11
12// --- SendspinUnpairedAccessSwitch ---
13
15 // The hub holds the client's first start for this, so a restore mode without a state still has to answer.
16 this->restore(true);
17}
18
19void SendspinUnpairedAccessSwitch::dump_config() { LOG_SWITCH("", "Sendspin Unpaired Access Switch", this); }
20
21// THREAD CONTEXT: Main loop
23 const bool turning_off = !state && this->has_state() && this->state;
24 this->parent_->set_unpaired_access_enabled(state);
25 this->publish_state(state);
26 // Write the change to flash now: losing it in a power cut would reopen unpaired access.
27 if (turning_off) {
29 }
30}
31
32} // namespace esphome::sendspin_
33
34#endif
bool has_state() const
bool state
The current reported state of the binary sensor.
Definition switch.h:60
void restore()
Drive the switch to the state its restore mode yields, through control(), so inversion and write_stat...
Definition switch.cpp:68
void publish_state(bool state)
Publish a state to the front-end from the back-end.
Definition switch.cpp:75
bool state
Definition fan.h:2
ESPHOME_LOG_TAG(TAG, "sendspin.image")
ESPPreferences * global_preferences
bool sync()
Commit pending writes to flash.
Definition preferences.h:33