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