ESPHome 2026.6.0-dev
Loading...
Searching...
No Matches
uponor_smatrix_climate.cpp
Go to the documentation of this file.
4#include "esphome/core/log.h"
5
6#include <cinttypes>
7
9
10static const char *const TAG = "uponor_smatrix.climate";
11
13 LOG_CLIMATE("", "Uponor Smatrix Climate", this);
14 ESP_LOGCONFIG(TAG, " Device address: 0x%08" PRIX32, this->address_);
15}
16
19
20 // Publish state after all update packets are processed
21 if (this->last_data_ != 0 && (now - this->last_data_ > 100) && this->target_temperature_raw_ != 0) {
26 this->target_temperature = roundf(temp / step) * step;
27 this->publish_state();
28 this->last_data_ = 0;
29 }
30}
31
44
46 auto val = call.get_target_temperature();
47 if (val.has_value()) {
48 uint16_t temp = celsius_to_raw(*val);
50 // During ECO mode, the thermostat automatically substracts the setback value from the setpoint,
51 // so we need to add it here first
52 temp += this->eco_setback_value_raw_;
53 }
54
55 // For unknown reasons, we need to send a null setpoint first for the thermostat to react
56 UponorSmatrixData data[] = {{UPONOR_ID_TARGET_TEMP, 0}, {UPONOR_ID_TARGET_TEMP, temp}};
57 this->send(data, sizeof(data) / sizeof(data[0]));
58 }
59}
60
61void UponorSmatrixClimate::on_device_data(const UponorSmatrixData *data, size_t data_len) {
62 for (size_t i = 0; i < data_len; i++) {
63 switch (data[i].id) {
64 case UPONOR_ID_TARGET_TEMP_MIN:
65 this->min_temperature_ = raw_to_celsius(data[i].value);
66 break;
67 case UPONOR_ID_TARGET_TEMP_MAX:
68 this->max_temperature_ = raw_to_celsius(data[i].value);
69 break;
70 case UPONOR_ID_TARGET_TEMP:
71 // Ignore invalid values here as they are used by the controller to explicitely request the setpoint from a
72 // thermostat
73 if (data[i].value != UPONOR_INVALID_VALUE)
74 this->target_temperature_raw_ = data[i].value;
75 break;
76 case UPONOR_ID_ECO_SETBACK:
77 this->eco_setback_value_raw_ = data[i].value;
78 break;
79 case UPONOR_ID_DEMAND:
80 if (data[i].value & 0x1000) {
83 } else {
86 }
87 break;
88 case UPONOR_ID_MODE1:
90 break;
91 case UPONOR_ID_ROOM_TEMP:
92 this->current_temperature = raw_to_celsius(data[i].value);
93 break;
94 case UPONOR_ID_HUMIDITY:
95 this->current_humidity = data[i].value & 0x00FF;
96 }
97 }
98
99 this->last_data_ = millis();
100}
101
102} // namespace esphome::uponor_smatrix
uint32_t IRAM_ATTR HOT get_loop_component_start_time() const
Get the cached time in milliseconds from when the current component started its loop execution.
This class is used to encode all control actions on a climate device.
Definition climate.h:34
ClimateMode mode
The active mode of the climate device.
Definition climate.h:293
ClimateTraits get_traits()
Get the traits of this climate device with all overrides applied.
Definition climate.cpp:486
float target_temperature
The target temperature of the climate device.
Definition climate.h:274
float current_humidity
The current humidity of the climate device, as reported from the integration.
Definition climate.h:270
bool set_preset_(ClimatePreset preset)
Set preset. Reset custom preset. Return true if preset has been changed.
Definition climate.cpp:696
float current_temperature
The current temperature of the climate device, as reported from the integration.
Definition climate.h:267
ClimateAction action
The active state of the climate device.
Definition climate.h:296
void publish_state()
Publish the state of the climate device, to be called from integrations.
Definition climate.cpp:437
optional< ClimatePreset > preset
The active preset of the climate device.
Definition climate.h:290
void set_visual_max_temperature(float visual_max_temperature)
void add_feature_flags(uint32_t feature_flags)
void set_visual_target_temperature_step(float temperature_step)
void set_supported_presets(ClimatePresetMask presets)
void set_visual_min_temperature(float visual_min_temperature)
float get_visual_target_temperature_step() const
void set_visual_current_temperature_step(float temperature_step)
void set_supported_modes(ClimateModeMask modes)
void control(const climate::ClimateCall &call) override
void on_device_data(const UponorSmatrixData *data, size_t data_len) override
bool send(const UponorSmatrixData *data, size_t data_len)
mopeka_std_values val[3]
@ CLIMATE_SUPPORTS_CURRENT_HUMIDITY
@ CLIMATE_SUPPORTS_CURRENT_TEMPERATURE
@ CLIMATE_PRESET_NONE
No preset is active.
@ CLIMATE_PRESET_ECO
Device is running an energy-saving preset.
@ CLIMATE_MODE_HEAT
The climate device is set to heat to reach the target temperature.
@ CLIMATE_MODE_COOL
The climate device is set to cool to reach the target temperature.
@ CLIMATE_ACTION_IDLE
The climate device is idle (monitoring climate but no action needed)
@ CLIMATE_ACTION_HEATING
The climate device is actively heating.
@ CLIMATE_ACTION_COOLING
The climate device is actively cooling.
uint16_t celsius_to_raw(float celsius)
float raw_to_celsius(uint16_t raw)
uint32_t IRAM_ATTR HOT millis()
Definition hal.cpp:28
Application App
Global storage of Application pointer - only one Application can exist.
static void uint32_t