ESPHome 2026.12.0-dev
Loading...
Searching...
No Matches
systa_bus.h
Go to the documentation of this file.
1#pragma once
2
6
7#include <span>
8
9namespace esphome::systa_bus {
10
11// A frame is a start byte, the payload length, the payload and an 8-bit checksum that makes all bytes sum to
12// zero. The first two bytes together are the message type, so the type also fixes the frame length.
13static constexpr uint8_t START_BYTE = 0xfc;
14static constexpr uint8_t FRAME_OVERHEAD = 3; // start byte, length, checksum
15
16// SystaSolar Aqua sensor data, 25 bytes: [0..1] type, [2..3] not decoded, big-endian int16 in 0.1 degrees at
17// [4..5] TSA, [6..7] TSE, [8..9] TWU and [10..11] TW2, pump speed in percent at [12], [13..14] not decoded,
18// [15] error code (zero for no error), [16..23] not decoded.
19static constexpr uint16_t MESSAGE_TYPE_AQUA_SENSOR_DATA = 0xfc16;
20
21// The bus only buffers known message types, so the buffer is sized by the longest of them
22static constexpr size_t MAX_MESSAGE_SIZE = (MESSAGE_TYPE_AQUA_SENSOR_DATA & 0xff) + FRAME_OVERHEAD;
23
24inline uint16_t get_message_type(std::span<const uint8_t> message) { return encode_uint16(message[0], message[1]); }
25
26// Big-endian int16 in 0.1 degrees at `start` of an Aqua sensor data message
27inline float aqua_temperature(std::span<const uint8_t> message, size_t start) {
28 return encode_value<int16_t>(&message[start]) * 0.1f;
29}
30
31class SystaBus : public uart::UARTDevice, public Component {
32 public:
33 void dump_config() override;
34 void loop() override;
35
36#ifdef USE_SYSTA_BUS_AQUA_PUBLISHER
37 HUB_PUBLISHER(aqua, std::span<const uint8_t>)
38 HUB_PUBLISHER(dump, const char *)
39#endif
40
41 protected:
42 void handle_byte_(uint8_t c);
43 void resync_();
44
46};
47
48} // namespace esphome::systa_bus
Minimal static vector - saves memory by avoiding std::vector overhead.
Definition helpers.h:335
void dump_config() override
Definition systa_bus.cpp:11
HUB_PUBLISHER(aqua, std::span< const uint8_t >) HUB_PUBLISHER(dump
void handle_byte_(uint8_t c)
Definition systa_bus.cpp:27
StaticVector< uint8_t, MAX_MESSAGE_SIZE > buffer_
Definition systa_bus.h:45
const LogString * message
Definition component.cpp:35
uint16_t get_message_type(std::span< const uint8_t > message)
Definition systa_bus.h:24
float aqua_temperature(std::span< const uint8_t > message, size_t start)
Definition systa_bus.h:27
constexpr T encode_value(const uint8_t *bytes)
Encode a value from its constituent bytes (from most to least significant) in an array with length si...
Definition helpers.h:1248
constexpr uint16_t encode_uint16(uint8_t msb, uint8_t lsb)
Encode a 16-bit value given the most and least significant byte.
Definition helpers.h:1227