Home IO Control
ESPHome add-on for IO-Homecontrol devices
Loading...
Searching...
No Matches
platform_climate_controls.cpp
Go to the documentation of this file.
1/// @file platform_climate_controls.cpp
2/// @brief Generated per-heater auxiliary entities: the window binary sensor and the open-window
3/// detection switch.
4/// @ingroup hioc_platforms
5
7
8#include "esphome/core/log.h"
9
10namespace esphome {
11namespace home_io_control {
12
13static const char *const TAG_WINDOW = "home_io_control.window";
14static const char *const TAG_DETECTION = "home_io_control.window_detection";
15
17 this->register_companion_binding_([this](const IoDevice &dev) {
18 if (dev.heating.window_open < 0) {
19 // "Closed" must mean the heater said so: nothing read means no state.
20 this->invalidate_state();
21 return;
22 }
23 this->publish_state(dev.heating.window_open != 0);
24 });
25}
26
28 ESP_LOGCONFIG(TAG_WINDOW, "IO-Homecontrol Window:");
29 ESP_LOGCONFIG(TAG_WINDOW, " Device ID: %s", this->device_id_.c_str());
30}
31
33 this->register_companion_binding_([this](const IoDevice &dev) {
34 // Shown only from a reply; a switch with no reading yet keeps its unknown state.
35 if (dev.heating.open_window_detection >= 0)
36 this->publish_state(dev.heating.open_window_detection != 0);
37 });
38}
39
41 if (this->parent_ == nullptr)
42 return;
44 state ? 1.0F : 0.0F)) {
45 ESP_LOGW(TAG_DETECTION, "Device %s: open-window detection %s was not acknowledged", this->device_id_.c_str(),
46 state ? "on" : "off");
47 return;
48 }
49 // The read-back updates IoDevice::heating, and the companion binding above publishes it.
51 EXCHANGE_RETRY_COUNT);
52}
53
55 ESP_LOGCONFIG(TAG_DETECTION, "IO-Homecontrol Open Window Detection:");
56 ESP_LOGCONFIG(TAG_DETECTION, " Device ID: %s", this->device_id_.c_str());
57}
58
59} // namespace home_io_control
60} // namespace esphome
void register_companion_binding_(const std::function< void(const IoDevice &)> &publish)
Shared setup() body: subscribe to this device's updates and publish the initial state.
virtual bool send_heating_command(const std::string &device_id, HeatingFunction fn, float value)
Run one heating function on the heater's private register protocol (CMD_WRITE_PRIVATE 0x20): a write ...
virtual bool read_heating_register(const std::string &device_id, HeatingFunction fn, float *value_out, uint8_t max_tries)
Read one register of a heater and fold the decoded value into IoDevice::heating.
void dump_config() override
Dump switch configuration to the log.
void write_state(bool state) override
Write the detection setting and read it back.
void setup() override
Subscribe to the device's updates and publish what is already known.
void dump_config() override
Dump sensor configuration to the log.
void setup() override
Subscribe to the device's updates and publish what is already known.
@ SET_OPEN_WINDOW_DETECTION
Register 0x0106, read/write: open-window detection on (1) or off (0).
static const char *const TAG_WINDOW
static const char *const TAG_DETECTION
Generated per-heater auxiliary entities: the window binary sensor and the open-window detection switc...
int16_t window_open
0 closed / 1 open; -1 until read.
int16_t open_window_detection
1 detection on / 0 off; -1 until read.
Runtime state of a paired IO‑Homecontrol device.
HeatingReadings heating
What the hub has read from a heater over the private register protocol (room temperature,...