ESPHome 2025.6.3
Loading...
Searching...
No Matches
uponor_smatrix_sensor.cpp
Go to the documentation of this file.
2#include "esphome/core/log.h"
3
4namespace esphome {
5namespace uponor_smatrix {
6
7static const char *const TAG = "uponor_smatrix.sensor";
8
10 ESP_LOGCONFIG(TAG,
11 "Uponor Smatrix Sensor\n"
12 " Device address: 0x%04X",
13 this->address_);
14 LOG_SENSOR(" ", "Temperature", this->temperature_sensor_);
15 LOG_SENSOR(" ", "External Temperature", this->external_temperature_sensor_);
16 LOG_SENSOR(" ", "Humidity", this->humidity_sensor_);
17 LOG_SENSOR(" ", "Target Temperature", this->target_temperature_sensor_);
18}
19
20void UponorSmatrixSensor::on_device_data(const UponorSmatrixData *data, size_t data_len) {
21 for (int i = 0; i < data_len; i++) {
22 switch (data[i].id) {
23 case UPONOR_ID_ROOM_TEMP:
24 if (this->temperature_sensor_ != nullptr)
25 this->temperature_sensor_->publish_state(raw_to_celsius(data[i].value));
26 break;
27 case UPONOR_ID_EXTERNAL_TEMP:
28 if (this->external_temperature_sensor_ != nullptr)
29 this->external_temperature_sensor_->publish_state(raw_to_celsius(data[i].value));
30 break;
31 case UPONOR_ID_HUMIDITY:
32 if (this->humidity_sensor_ != nullptr)
33 this->humidity_sensor_->publish_state(data[i].value & 0x00FF);
34 break;
35 case UPONOR_ID_TARGET_TEMP:
36 if (this->target_temperature_sensor_ != nullptr)
37 this->target_temperature_sensor_->publish_state(raw_to_celsius(data[i].value));
38 break;
39 }
40 }
41}
42
43} // namespace uponor_smatrix
44} // namespace esphome
virtual void dump_config()
void on_device_data(const UponorSmatrixData *data, size_t data_len) override
const char *const TAG
Definition spi.cpp:8
float raw_to_celsius(uint16_t raw)
Providing packet encoding functions for exchanging data with a remote host.
Definition a01nyub.cpp:7