ESPHome 2026.4.0
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
8namespace esphome {
9namespace uponor_smatrix {
10
11static const char *const TAG = "uponor_smatrix.climate";
12
14 LOG_CLIMATE("", "Uponor Smatrix Climate", this);
15 ESP_LOGCONFIG(TAG, " Device address: 0x%08" PRIX32, this->address_);
16}
17
20
21 // Publish state after all update packets are processed
22 if (this->last_data_ != 0 && (now - this->last_data_ > 100) && this->target_temperature_raw_ != 0) {
27 this->target_temperature = roundf(temp / step) * step;
28 this->publish_state();
29 this->last_data_ = 0;
30 }
31}
32
45
47 auto val = call.get_target_temperature();
48 if (val.has_value()) {
49 uint16_t temp = celsius_to_raw(*val);
51 // During ECO mode, the thermostat automatically substracts the setback value from the setpoint,
52 // so we need to add it here first
53 temp += this->eco_setback_value_raw_;
54 }
55
56 // For unknown reasons, we need to send a null setpoint first for the thermostat to react
57 UponorSmatrixData data[] = {{UPONOR_ID_TARGET_TEMP, 0}, {UPONOR_ID_TARGET_TEMP, temp}};
58 this->send(data, sizeof(data) / sizeof(data[0]));
59 }
60}
61
62void UponorSmatrixClimate::on_device_data(const UponorSmatrixData *data, size_t data_len) {
63 for (size_t i = 0; i < data_len; i++) {
64 switch (data[i].id) {
65 case UPONOR_ID_TARGET_TEMP_MIN:
66 this->min_temperature_ = raw_to_celsius(data[i].value);
67 break;
68 case UPONOR_ID_TARGET_TEMP_MAX:
69 this->max_temperature_ = raw_to_celsius(data[i].value);
70 break;
71 case UPONOR_ID_TARGET_TEMP:
72 // Ignore invalid values here as they are used by the controller to explicitely request the setpoint from a
73 // thermostat
74 if (data[i].value != UPONOR_INVALID_VALUE)
75 this->target_temperature_raw_ = data[i].value;
76 break;
77 case UPONOR_ID_ECO_SETBACK:
78 this->eco_setback_value_raw_ = data[i].value;
79 break;
80 case UPONOR_ID_DEMAND:
81 if (data[i].value & 0x1000) {
84 } else {
87 }
88 break;
89 case UPONOR_ID_MODE1:
91 break;
92 case UPONOR_ID_ROOM_TEMP:
93 this->current_temperature = raw_to_celsius(data[i].value);
94 break;
95 case UPONOR_ID_HUMIDITY:
96 this->current_humidity = data[i].value & 0x00FF;
97 }
98 }
99
100 this->last_data_ = millis();
101}
102
103} // namespace uponor_smatrix
104} // 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: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:485
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:695
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:436
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)
Providing packet encoding functions for exchanging data with a remote host.
Definition a01nyub.cpp:7
uint32_t IRAM_ATTR HOT millis()
Definition core.cpp:26
Application App
Global storage of Application pointer - only one Application can exist.
static void uint32_t