ESPHome 2026.5.1
Loading...
Searching...
No Matches
uponor_smatrix.h
Go to the documentation of this file.
1#pragma once
2
6
8
9#ifdef USE_TIME
11#include "esphome/core/time.h"
12#endif
13
14#include <queue>
15#include <set>
16#include <vector>
17
19
21static const uint8_t UPONOR_ID_DATETIME1 = 0x08;
23static const uint8_t UPONOR_ID_DATETIME2 = 0x09;
25static const uint8_t UPONOR_ID_DATETIME3 = 0x0A;
27static const uint8_t UPONOR_ID_UNKNOWN1 = 0x0C;
29static const uint8_t UPONOR_ID_OUTDOOR_TEMP = 0x2D;
31static const uint8_t UPONOR_ID_UNKNOWN2 = 0x35;
33static const uint8_t UPONOR_ID_TARGET_TEMP_MIN = 0x37;
35static const uint8_t UPONOR_ID_TARGET_TEMP_MAX = 0x38;
37static const uint8_t UPONOR_ID_TARGET_TEMP = 0x3B;
39static const uint8_t UPONOR_ID_ECO_SETBACK = 0x3C;
41static const uint8_t UPONOR_ID_DEMAND = 0x3D;
43static const uint8_t UPONOR_ID_MODE1 = 0x3E;
45static const uint8_t UPONOR_ID_MODE2 = 0x3F;
47static const uint8_t UPONOR_ID_ROOM_TEMP = 0x40;
49static const uint8_t UPONOR_ID_EXTERNAL_TEMP = 0x41;
51static const uint8_t UPONOR_ID_HUMIDITY = 0x42;
53static const uint8_t UPONOR_ID_REQUEST = 0xFF;
54
56static const uint16_t UPONOR_INVALID_VALUE = 0x7FFF;
57
59 uint8_t id;
60 uint16_t value;
61};
62
64
66 public:
68
69 void setup() override;
70 void dump_config() override;
71 void loop() override;
72
73 void register_device(UponorSmatrixDevice *device) { this->devices_.push_back(device); }
74
75 bool send(uint32_t device_address, const UponorSmatrixData *data, size_t data_len);
76
77#ifdef USE_TIME
78 void set_time_id(time::RealTimeClock *time_id) { this->time_id_ = time_id; }
80 void send_time() { this->send_time_requested_ = true; }
81#endif
82
83 protected:
84 bool parse_byte_(uint8_t byte);
85
86 std::vector<UponorSmatrixDevice *> devices_;
87 std::set<uint32_t> unknown_devices_;
88
89 std::vector<uint8_t> rx_buffer_;
90 std::queue<std::vector<uint8_t>> tx_queue_;
93
94#ifdef USE_TIME
98 bool do_send_time_();
99#endif
100};
101
102class UponorSmatrixDevice : public Parented<UponorSmatrixComponent> {
103 public:
105
106 virtual void on_device_data(const UponorSmatrixData *data, size_t data_len) = 0;
107 bool send(const UponorSmatrixData *data, size_t data_len) {
108 return this->parent_->send(this->address_, data, data_len);
109 }
110
111 protected:
114};
115
116inline float raw_to_celsius(uint16_t raw) {
117 return (raw == UPONOR_INVALID_VALUE) ? NAN : fahrenheit_to_celsius(raw / 10.0f);
118}
119
120inline uint16_t celsius_to_raw(float celsius) {
121 return std::isnan(celsius) ? UPONOR_INVALID_VALUE
122 : static_cast<uint16_t>(lroundf(celsius_to_fahrenheit(celsius) * 10.0f));
123}
124
125} // namespace esphome::uponor_smatrix
uint8_t address
Definition bl0906.h:4
uint8_t raw[35]
Definition bl0939.h:0
Helper class to easily give an object a parent of type T.
Definition helpers.h:1861
The RealTimeClock class exposes common timekeeping functions via the device's local real-time clock.
void set_time_id(time::RealTimeClock *time_id)
void register_device(UponorSmatrixDevice *device)
std::vector< UponorSmatrixDevice * > devices_
bool send(uint32_t device_address, const UponorSmatrixData *data, size_t data_len)
std::queue< std::vector< uint8_t > > tx_queue_
virtual void on_device_data(const UponorSmatrixData *data, size_t data_len)=0
bool send(const UponorSmatrixData *data, size_t data_len)
uint16_t celsius_to_raw(float celsius)
float raw_to_celsius(uint16_t raw)
constexpr float celsius_to_fahrenheit(float value)
Convert degrees Celsius to degrees Fahrenheit.
Definition helpers.h:1610
constexpr float fahrenheit_to_celsius(float value)
Convert degrees Fahrenheit to degrees Celsius.
Definition helpers.h:1612
static void uint32_t