ESPHome 2026.11.0-dev
Loading...
Searching...
No Matches
opentherm_switch.cpp
Go to the documentation of this file.
1#include "opentherm_switch.h"
2
3namespace esphome::opentherm {
4
5ESPHOME_LOG_TAG(TAG, "opentherm.switch");
6
8
10 auto restored = this->get_initial_state_with_restore_mode();
11 bool state = false;
12 if (!restored.has_value()) {
13 ESP_LOGD(TAG, "Couldn't restore state for OpenTherm switch '%s'", LOG_STR_ARG(this->get_log_name()));
14 } else {
15 ESP_LOGD(TAG, "Restored state for OpenTherm switch '%s': %d", LOG_STR_ARG(this->get_log_name()), restored.value());
16 state = restored.value();
17 }
18 this->write_state(state);
19}
20
22 LOG_SWITCH("", "OpenTherm Switch", this);
23 ESP_LOGCONFIG(TAG, " Current state: %d", this->state);
24}
25
26} // namespace esphome::opentherm
const LogString * get_log_name() const
Get the name for a "%s" log argument (LOG_STR_ARG).
void write_state(bool state) override
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:70
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 state
Definition fan.h:2
ESPHOME_LOG_TAG(TAG, "opentherm")