ESPHome 2025.5.0
Loading...
Searching...
No Matches
uponor_smatrix_climate.cpp
Go to the documentation of this file.
3#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%04X", 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
44
46 if (call.get_target_temperature().has_value()) {
47 uint16_t temp = celsius_to_raw(*call.get_target_temperature());
49 // During ECO mode, the thermostat automatically substracts the setback value from the setpoint,
50 // so we need to add it here first
51 temp += this->eco_setback_value_raw_;
52 }
53
54 // For unknown reasons, we need to send a null setpoint first for the thermostat to react
55 UponorSmatrixData data[] = {{UPONOR_ID_TARGET_TEMP, 0}, {UPONOR_ID_TARGET_TEMP, temp}};
56 this->send(data, sizeof(data) / sizeof(data[0]));
57 }
58}
59
60void UponorSmatrixClimate::on_device_data(const UponorSmatrixData *data, size_t data_len) {
61 for (int i = 0; i < data_len; i++) {
62 switch (data[i].id) {
63 case UPONOR_ID_TARGET_TEMP_MIN:
64 this->min_temperature_ = raw_to_celsius(data[i].value);
65 break;
66 case UPONOR_ID_TARGET_TEMP_MAX:
67 this->max_temperature_ = raw_to_celsius(data[i].value);
68 break;
69 case UPONOR_ID_TARGET_TEMP:
70 // Ignore invalid values here as they are used by the controller to explicitely request the setpoint from a
71 // thermostat
72 if (data[i].value != UPONOR_INVALID_VALUE)
73 this->target_temperature_raw_ = data[i].value;
74 break;
75 case UPONOR_ID_ECO_SETBACK:
76 this->eco_setback_value_raw_ = data[i].value;
77 break;
78 case UPONOR_ID_DEMAND:
79 if (data[i].value & 0x1000) {
82 } else {
85 }
86 break;
87 case UPONOR_ID_MODE1:
89 break;
90 case UPONOR_ID_ROOM_TEMP:
91 this->current_temperature = raw_to_celsius(data[i].value);
92 break;
93 case UPONOR_ID_HUMIDITY:
94 this->current_humidity = data[i].value & 0x00FF;
95 }
96 }
97
98 this->last_data_ = millis();
99}
100
101} // namespace uponor_smatrix
102} // 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:173
ClimateTraits get_traits()
Get the traits of this climate device with all overrides applied.
Definition climate.cpp:440
float target_temperature
The target temperature of the climate device.
Definition climate.h:186
float current_humidity
The current humidity of the climate device, as reported from the integration.
Definition climate.h:182
bool set_preset_(ClimatePreset preset)
Set preset. Reset custom preset. Return true if preset has been changed.
Definition climate.cpp:563
float current_temperature
The current temperature of the climate device, as reported from the integration.
Definition climate.h:179
ClimateAction action
The active state of the climate device.
Definition climate.h:176
void publish_state()
Publish the state of the climate device, to be called from integrations.
Definition climate.cpp:395
optional< ClimatePreset > preset
The active preset of the climate device.
Definition climate.h:208
This class contains all static data for climate devices.
void set_visual_max_temperature(float visual_max_temperature)
void set_supported_modes(std::set< ClimateMode > modes)
void set_supports_action(bool supports_action)
void set_supports_current_humidity(bool supports_current_humidity)
void set_visual_target_temperature_step(float temperature_step)
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_presets(std::set< ClimatePreset > presets)
void set_supports_current_temperature(bool supports_current_temperature)
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_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:27
Application App
Global storage of Application pointer - only one Application can exist.