1
0
mirror of https://github.com/esphome/esphome.git synced 2025-04-15 07:10:33 +01:00
Oleg Tarasov 58d028ac13
Add OpenTherm component (part 3: rest of the sensors) (#7676)
Co-authored-by: FreeBear <freebear@tuxcnc.org>
Co-authored-by: FreeBear-nc <67865163+FreeBear-nc@users.noreply.github.com>
Co-authored-by: Jesse Hills <3060199+jesserockz@users.noreply.github.com>
2024-11-12 16:19:42 +13:00

29 lines
820 B
C++

#include "switch.h"
namespace esphome {
namespace opentherm {
static const char *const TAG = "opentherm.switch";
void OpenthermSwitch::write_state(bool state) { this->publish_state(state); }
void OpenthermSwitch::setup() {
auto restored = this->get_initial_state_with_restore_mode();
bool state = false;
if (!restored.has_value()) {
ESP_LOGD(TAG, "Couldn't restore state for OpenTherm switch '%s'", this->get_name().c_str());
} else {
ESP_LOGD(TAG, "Restored state for OpenTherm switch '%s': %d", this->get_name().c_str(), restored.value());
state = restored.value();
}
this->write_state(state);
}
void OpenthermSwitch::dump_config() {
LOG_SWITCH("", "OpenTherm Switch", this);
ESP_LOGCONFIG(TAG, " Current state: %d", this->state);
}
} // namespace opentherm
} // namespace esphome