7#include "esphome/core/log.h"
14static const char *
const TAG =
"home_io_control.climate";
19struct ClimateModeMapping {
20 climate::ClimateMode climate_mode;
23constexpr ClimateModeMapping CLIMATE_MODE_MAP[] = {
30struct ClimatePresetMapping {
31 climate::ClimatePreset preset;
34constexpr ClimatePresetMapping CLIMATE_PRESET_MAP[] = {
35 {climate::CLIMATE_PRESET_HOME, 1.0F},
36 {climate::CLIMATE_PRESET_AWAY, 0.0F},
41constexpr const char *PROGRAM_PRESET_NAME =
"Program";
45constexpr float CLIMATE_TARGET_TEMP_STEP_C = 0.5F;
58 "Device %s declares io_device_type '%s', which is not a climate device — disabling this climate entity",
73 this->set_supported_custom_presets({PROGRAM_PRESET_NAME});
77 climate::ClimateTraits
traits;
81 for (
const auto &mapping : CLIMATE_MODE_MAP)
82 traits.add_supported_mode(mapping.climate_mode);
83 for (
const auto &mapping : CLIMATE_PRESET_MAP)
84 traits.add_supported_preset(mapping.preset);
89 traits.set_visual_target_temperature_step(CLIMATE_TARGET_TEMP_STEP_C);
102 if (mode_changed || custom_preset_changed || preset_changed || temperature_changed)
103 this->publish_state();
107 const auto &mode_opt = call.get_mode();
108 if (!mode_opt.has_value())
110 const climate::ClimateMode requested = *mode_opt;
111 for (
const auto &mapping : CLIMATE_MODE_MAP) {
112 if (mapping.climate_mode != requested)
115 static_cast<float>(mapping.heating_mode)))
117 this->mode = requested;
118 this->clear_custom_preset_();
125 if (!call.has_custom_preset())
127 const std::string custom = std::string(call.get_custom_preset());
128 if (custom != PROGRAM_PRESET_NAME)
133 this->set_custom_preset_(call.get_custom_preset());
138 const auto &preset_opt = call.get_preset();
139 if (!preset_opt.has_value())
141 const climate::ClimatePreset requested = *preset_opt;
142 for (
const auto &mapping : CLIMATE_PRESET_MAP) {
143 if (mapping.preset != requested)
147 this->preset = requested;
148 this->clear_custom_preset_();
155 const auto &target_opt = call.get_target_temperature();
156 if (!target_opt.has_value())
158 const float target = *target_opt;
161 this->target_temperature = target;
171 LOG_CLIMATE(
"",
"IO-Homecontrol Climate",
this);
172 ESP_LOGCONFIG(
TAG,
" Device ID: %s", this->
device_id_.c_str());
173 ESP_LOGCONFIG(
TAG,
" Target temperature range: %.1f-%.1f C (documented max; write-only, never confirmed)",
177 ESP_LOGCONFIG(
TAG,
" Status: experimental, unvalidated on hardware");
void register_device_binding_(Component *self, bool inverted, std::function< void(const std::string &, const IoDevice &)> on_update, bool schedule_initial_poll=true)
Perform the shared setup() registration ritual.
IOHomeControlComponent * parent_
void on_device_update_(const std::string &id, const IoDevice &dev)
Inbound device-update hook.
bool apply_custom_preset_(const climate::ClimateCall &call)
Apply the "Program" custom preset via SET_MODE(prog), if present.
void dump_config() override
Dump configuration to the log.
bool apply_target_temperature_(const climate::ClimateCall &call)
Apply the target temperature via SET_TEMPERATURE, if present.
bool apply_preset_(const climate::ClimateCall &call)
Apply a HOME/AWAY preset via SET_PRESENCE, if present.
climate::ClimateTraits traits() override
Static traits: modes OFF/HEAT/AUTO, presets HOME/AWAY, temperature range HEATING_TEMP_MIN_C....
void control(const climate::ClimateCall &call) override
Apply a Home Assistant climate control request.
void setup() override
Register the entity with the shared hub (no status poll — heating has no readback).
bool apply_mode_(const climate::ClimateCall &call)
Apply the request's HVAC mode via SET_MODE, if present.
virtual bool send_heating_command(const std::string &device_id, HeatingFunction fn, float value)
The single hub-side transmit path for 2W heating/climate control (CMD_WRITE_PRIVATE 0x20).
@ UNKNOWN
Unknown/unspecified device.
@ SET_PRESENCE
Presence / absence (iohcCozyDevice2W.cpp:195).
@ SET_TEMPERATURE
Setpoint in degrees Celsius (iohcCozyDevice2W.cpp:125).
@ SET_MODE
Operating mode (iohcCozyDevice2W.cpp:155).
static constexpr const char * TAG
bool device_supports_climate_control(DeviceType type)
Does this device type support 2W climate/heating control (CMD_WRITE_PRIVATE 0x20)?
constexpr float HEATING_TEMP_MAX_C
Highest setpoint this codec will encode.
const char * device_type_name(DeviceType type)
Convert a DeviceType to a lowercase string identifier.
constexpr float HEATING_TEMP_MIN_C
Lowest setpoint this codec will encode.
HeatingMode
Operating modes for HeatingFunction::SET_MODE.
@ OFF
Off / standby; note the value is 0x04, not 0x03 (that is the reference's commented-out "special" mode...
@ PROG
Program mode; device runs its own stored weekly schedule (iohcCozyDevice2W.cpp:160).
@ MANUAL
Manual mode; follows the last SET_TEMPERATURE setpoint (iohcCozyDevice2W.cpp:159).
@ AUTO
Automatic mode; device manages the setpoint itself (iohcCozyDevice2W.cpp:158).
static const char *const TAG
Runtime state of a paired IO‑Homecontrol device.