ESPHome 2025.12.0-dev
Loading...
Searching...
No Matches
uponor_smatrix_climate.cpp
Go to the documentation of this file.
4#include "esphome/core/log.h"
5
6namespace esphome {
7namespace uponor_smatrix {
8
9static const char *const TAG = "uponor_smatrix.climate";
10
12 LOG_CLIMATE("", "Uponor Smatrix Climate", this);
13 ESP_LOGCONFIG(TAG, " Device address: 0x%08X", this->address_);
14}
15
17 const uint32_t now = App.get_loop_component_start_time();
18
19 // Publish state after all update packets are processed
20 if (this->last_data_ != 0 && (now - this->last_data_ > 100) && this->target_temperature_raw_ != 0) {
25 this->target_temperature = roundf(temp / step) * step;
26 this->publish_state();
27 this->last_data_ = 0;
28 }
29}
30
43
45 if (call.get_target_temperature().has_value()) {
46 uint16_t temp = celsius_to_raw(*call.get_target_temperature());
48 // During ECO mode, the thermostat automatically substracts the setback value from the setpoint,
49 // so we need to add it here first
50 temp += this->eco_setback_value_raw_;
51 }
52
53 // For unknown reasons, we need to send a null setpoint first for the thermostat to react
54 UponorSmatrixData data[] = {{UPONOR_ID_TARGET_TEMP, 0}, {UPONOR_ID_TARGET_TEMP, temp}};
55 this->send(data, sizeof(data) / sizeof(data[0]));
56 }
57}
58
59void UponorSmatrixClimate::on_device_data(const UponorSmatrixData *data, size_t data_len) {
60 for (size_t i = 0; i < data_len; i++) {
61 switch (data[i].id) {
62 case UPONOR_ID_TARGET_TEMP_MIN:
63 this->min_temperature_ = raw_to_celsius(data[i].value);
64 break;
65 case UPONOR_ID_TARGET_TEMP_MAX:
66 this->max_temperature_ = raw_to_celsius(data[i].value);
67 break;
68 case UPONOR_ID_TARGET_TEMP:
69 // Ignore invalid values here as they are used by the controller to explicitely request the setpoint from a
70 // thermostat
71 if (data[i].value != UPONOR_INVALID_VALUE)
72 this->target_temperature_raw_ = data[i].value;
73 break;
74 case UPONOR_ID_ECO_SETBACK:
75 this->eco_setback_value_raw_ = data[i].value;
76 break;
77 case UPONOR_ID_DEMAND:
78 if (data[i].value & 0x1000) {
81 } else {
84 }
85 break;
86 case UPONOR_ID_MODE1:
88 break;
89 case UPONOR_ID_ROOM_TEMP:
90 this->current_temperature = raw_to_celsius(data[i].value);
91 break;
92 case UPONOR_ID_HUMIDITY:
93 this->current_humidity = data[i].value & 0x00FF;
94 }
95 }
96
97 this->last_data_ = millis();
98}
99
100} // namespace uponor_smatrix
101} // namespace esphome
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:33
ClimateMode mode
The active mode of the climate device.
Definition climate.h:256
ClimateTraits get_traits()
Get the traits of this climate device with all overrides applied.
Definition climate.cpp:475
float target_temperature
The target temperature of the climate device.
Definition climate.h:237
float current_humidity
The current humidity of the climate device, as reported from the integration.
Definition climate.h:233
bool set_preset_(ClimatePreset preset)
Set preset. Reset custom preset. Return true if preset has been changed.
Definition climate.cpp:678
float current_temperature
The current temperature of the climate device, as reported from the integration.
Definition climate.h:230
ClimateAction action
The active state of the climate device.
Definition climate.h:259
void publish_state()
Publish the state of the climate device, to be called from integrations.
Definition climate.cpp:426
optional< ClimatePreset > preset
The active preset of the climate device.
Definition climate.h:253
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)
@ 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)
Providing packet encoding functions for exchanging data with a remote host.
Definition a01nyub.cpp:7
uint32_t IRAM_ATTR HOT millis()
Definition core.cpp:30
Application App
Global storage of Application pointer - only one Application can exist.