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