8#include "esphome/core/log.h"
15static const char *
const TAG =
"home_io_control.climate";
20struct ClimateModeMapping {
21 climate::ClimateMode climate_mode;
24constexpr ClimateModeMapping CLIMATE_MODE_MAP[] = {
31struct ClimatePresetMapping {
32 climate::ClimatePreset preset;
35constexpr ClimatePresetMapping CLIMATE_PRESET_MAP[] = {
36 {climate::CLIMATE_PRESET_HOME, 1.0F},
37 {climate::CLIMATE_PRESET_AWAY, 0.0F},
42constexpr const char *PROGRAM_PRESET_NAME =
"Program";
46constexpr float CLIMATE_TARGET_TEMP_STEP_C = 0.5F;
59 "Device %s declares io_device_type '%s', which is not a climate device — disabling this climate entity",
74 this->set_supported_custom_presets({PROGRAM_PRESET_NAME});
78 climate::ClimateTraits
traits;
82 for (
const auto &mapping : CLIMATE_MODE_MAP)
83 traits.add_supported_mode(mapping.climate_mode);
84 for (
const auto &mapping : CLIMATE_PRESET_MAP)
85 traits.add_supported_preset(mapping.preset);
90 traits.set_visual_target_temperature_step(CLIMATE_TARGET_TEMP_STEP_C);
103 if (mode_changed || custom_preset_changed || preset_changed || temperature_changed)
104 this->publish_state();
108 const auto &mode_opt = call.get_mode();
109 if (!mode_opt.has_value())
111 const climate::ClimateMode requested = *mode_opt;
112 for (
const auto &mapping : CLIMATE_MODE_MAP) {
113 if (mapping.climate_mode != requested)
116 static_cast<float>(mapping.heating_mode)))
118 this->mode = requested;
119 this->clear_custom_preset_();
126 if (!call.has_custom_preset())
128 const std::string custom = std::string(call.get_custom_preset());
129 if (custom != PROGRAM_PRESET_NAME)
134 this->set_custom_preset_(call.get_custom_preset());
139 const auto &preset_opt = call.get_preset();
140 if (!preset_opt.has_value())
142 const climate::ClimatePreset requested = *preset_opt;
143 for (
const auto &mapping : CLIMATE_PRESET_MAP) {
144 if (mapping.preset != requested)
148 this->preset = requested;
149 this->clear_custom_preset_();
156 const auto &target_opt = call.get_target_temperature();
157 if (!target_opt.has_value())
159 const float target = *target_opt;
162 this->target_temperature = target;
172 LOG_CLIMATE(
"",
"IO-Homecontrol Climate",
this);
173 ESP_LOGCONFIG(
TAG,
" Device ID: %s", this->
device_id_.c_str());
174 ESP_LOGCONFIG(
TAG,
" Target temperature range: %.1f-%.1f C (documented max; write-only, never confirmed)",
178 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.
Internal helpers shared by the hub implementation .cpp files.
@ 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).
Runtime state of a paired IO‑Homecontrol device.