ESPHome 2026.6.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
7
8static const char *const TAG = "uponor_smatrix.sensor";
9
11 ESP_LOGCONFIG(TAG,
12 "Uponor Smatrix Sensor\n"
13 " Device address: 0x%08" PRIX32,
14 this->address_);
15 LOG_SENSOR(" ", "Temperature", this->temperature_sensor_);
16 LOG_SENSOR(" ", "External Temperature", this->external_temperature_sensor_);
17 LOG_SENSOR(" ", "Humidity", this->humidity_sensor_);
18 LOG_SENSOR(" ", "Target Temperature", this->target_temperature_sensor_);
19}
20
21void UponorSmatrixSensor::on_device_data(const UponorSmatrixData *data, size_t data_len) {
22 for (size_t i = 0; i < data_len; i++) {
23 switch (data[i].id) {
24 case UPONOR_ID_ROOM_TEMP:
25 if (this->temperature_sensor_ != nullptr)
26 this->temperature_sensor_->publish_state(raw_to_celsius(data[i].value));
27 break;
28 case UPONOR_ID_EXTERNAL_TEMP:
29 if (this->external_temperature_sensor_ != nullptr)
30 this->external_temperature_sensor_->publish_state(raw_to_celsius(data[i].value));
31 break;
32 case UPONOR_ID_HUMIDITY:
33 if (this->humidity_sensor_ != nullptr)
34 this->humidity_sensor_->publish_state(data[i].value & 0x00FF);
35 break;
36 case UPONOR_ID_TARGET_TEMP:
37 if (this->target_temperature_sensor_ != nullptr)
38 this->target_temperature_sensor_->publish_state(raw_to_celsius(data[i].value));
39 break;
40 }
41 }
42}
43
44} // namespace esphome::uponor_smatrix
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)