9#include "esphome/core/log.h"
17static const char *
const TAG_WINDOW =
"home_io_control.window";
18static const char *
const TAG_DETECTION =
"home_io_control.window_detection";
29 this->invalidate_state();
37 ESP_LOGCONFIG(
TAG_WINDOW,
"IO-Homecontrol Window:");
53 state ? 1.0F : 0.0F)) {
55 state ?
"on" :
"off");
60 EXCHANGE_RETRY_COUNT);
64 ESP_LOGCONFIG(
TAG_DETECTION,
"IO-Homecontrol Open Window Detection:");
73 auto traits = light::LightTraits();
74 traits.set_supported_color_modes({light::ColorMode::BRIGHTNESS});
85 const float brightness =
88 : this->
state_->remote_values.get_brightness();
109 const bool on = state->current_values.is_on();
110 bool brightness_written =
false;
114 const uint8_t percent = std::clamp<uint8_t>(
detail::round_percent(state->current_values.get_brightness()),
127 if (brightness_written) {
129 EXCHANGE_RETRY_COUNT);
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.
IOHomeControlComponent * parent_
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 IoDevice * get_device(const std::string &device_id)
Retrieve a device by ID; returns nullptr if not found.
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 on_device_update_(const IoDevice &dev)
Publish the heater's light state, without echoing it back as a write.
light::LightTraits get_traits() override
Brightness is the light's only colour mode.
void write_state(light::LightState *state) override
Send the requested state to the heater and read it back.
void dump_config() override
Dump light configuration to the log.
bool writing_
True while write_state() runs its writes and read-backs: the device updates they cause are not publis...
void setup() override
Subscribe to the device's updates and publish what is already known.
bool write_register_(HeatingFunction fn, float value)
Write one light register.
light::LightState * state_
bool suppress_write_
Swallows the write_state() that LightState::make_call().perform() causes for a state this entity publ...
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.
Conversions and renderers shared by the hub and its Home Assistant entities.
uint8_t round_percent(float fraction)
Convert a 0.0-1.0 HA fraction (position, tilt, or brightness) to a 0-100 IO percent.
HeatingFunction
Registers and functions of a 2W heater, one row of the descriptor table each.
@ NIGHT_LIGHT
Register 0x0144, read/write: a heater's night light on (1) or off (0).
@ NIGHT_LIGHT_BRIGHTNESS
Register 0x0142, read/write: the night light's brightness, 0-100 %, 16-bit.
@ SET_OPEN_WINDOW_DETECTION
Register 0x0106, read/write: open-window detection on (1) or off (0).
static const char *const TAG_NIGHT_LIGHT
const char * heating_function_name(HeatingFunction fn)
Stable lowercase name for a heating function ("power_on", "set_temperature", ...).
constexpr uint8_t HEATING_NIGHT_LIGHT_BRIGHTNESS_MAX
Highest night light brightness (HeatingFunction::NIGHT_LIGHT_BRIGHTNESS): a percentage,...
static constexpr uint8_t NIGHT_LIGHT_MIN_ON_PERCENT
Brightness register value for a light switched on at a brightness that rounds to 0 %: the lowest leve...
static const char *const TAG_WINDOW
static const char *const TAG_DETECTION
int16_t window_open
0 closed / 1 open; -1 until read.
int16_t open_window_detection
1 detection on / 0 off; -1 until read.
int16_t night_light
Night light 1 on / 0 off; -1 until read.
int16_t night_light_brightness
Night light brightness, 0-100 %; -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,...