14#ifdef USE_DUCO_ERROR_TEXT_SENSOR
17static constexpr size_t MAX_ERROR_TEXT_LENGTH = 255;
19PROGMEM_STRING_TABLE(ErrorCodes,
"E01.04.01",
"E03.01.01",
"E03.01.02",
"E03.01.03",
"E03.01.04",
"E03.01.05",
20 "E03.01.06",
"E04.01.01",
"E04.01.02",
"E04.01.03",
"E04.01.04",
"E04.01.05",
"E04.01.06",
21 "E06.01.01",
"E06.01.02",
"E06.01.03",
"E06.01.04",
"E06.01.05",
"E06.01.06",
"E16.01.01",
22 "E16.01.02",
"E16.01.03",
"E16.01.04",
"E16.01.05",
"E16.01.06",
"E28.04.01",
"E29.01.01",
23 "E29.01.02",
"E29.01.03",
"E29.01.04",
"E29.01.05",
"E29.01.06",
"E30.01.01",
"E30.01.02",
24 "E30.01.03",
"E30.01.04",
"E30.01.05",
"E30.01.06",
"E31.19.01",
"E32.10.01",
"E33.10.01",
25 "E35.17.01",
"E35.17.02",
"E35.17.03",
"E36.24.01",
"E36.24.02",
"E37.17.01",
"E37.17.02",
26 "E37.17.03",
"E40.17.01",
"E40.17.02",
"E40.17.03",
"E42.22.01",
"E42.22.02",
"E43.23.01",
27 "E43.23.02",
"E44.06.01",
"E44.06.02");
29 ErrorDescriptions,
"No response from the extractor fan.",
"ODA temperature sensor value is too low.",
30 "ODA temperature sensor value is too high.",
"ODA temperature sensor cannot be read.",
31 "ODA temperature sensor value is unchanged for too long.",
"ODA temperature sensor is short-circuited.",
32 "ODA temperature sensor has a bad connection.",
"ETA temperature sensor value is too low.",
33 "ETA temperature sensor value is too high.",
"ETA temperature sensor cannot be read.",
34 "ETA temperature sensor value is unchanged for too long.",
"ETA temperature sensor is short-circuited.",
35 "ETA temperature sensor has a bad connection.",
"EHA temperature sensor value is too low.",
36 "EHA temperature sensor value is too high.",
"EHA temperature sensor cannot be read.",
37 "EHA temperature sensor value is unchanged for too long.",
"EHA temperature sensor is short-circuited.",
38 "EHA temperature sensor has a bad connection.",
"Extract air pressure sensor value is too low.",
39 "Extract air pressure sensor value is too high.",
"Extract air pressure sensor cannot be read.",
40 "Extract air pressure sensor value is unchanged for too long.",
"Extract air pressure sensor is short-circuited.",
41 "Extract air pressure sensor has a bad connection.",
"No response from the supply fan.",
42 "Supply air pressure sensor value is too low.",
"Supply air pressure sensor value is too high.",
43 "Supply air pressure sensor cannot be read.",
"Supply air pressure sensor value is unchanged for too long.",
44 "Supply air pressure sensor is short-circuited.",
"Supply air pressure sensor has a bad connection.",
45 "SUP temperature sensor value is too low.",
"SUP temperature sensor value is too high.",
46 "SUP temperature sensor cannot be read.",
"SUP temperature sensor value is unchanged for too long.",
47 "SUP temperature sensor is short-circuited.",
"SUP temperature sensor has a bad connection.",
48 "Filters need replacement.",
"Outdoor temperature is too low; ventilation is off for 8 hours.",
49 "Outdoor temperature is too low; ventilation is permanently off.",
"Temperature sensor value is too low.",
50 "Temperature sensor value is too high.",
"Temperature sensor cannot be read.",
51 "Connection to the weather station has been lost.",
"Connection to the outdoor temperature sensor has been lost.",
52 "CO2 sensor value is too low.",
"CO2 sensor value is too high.",
"CO2 sensor cannot be read.",
53 "Humidity sensor value is too low.",
"Humidity sensor value is too high.",
"Humidity sensor cannot be read.",
54 "Too many valves are connected.",
"Too few valves are connected; at least two are required.",
55 "Flow adjustment has not happened or failed.",
"The requested flow rate cannot be achieved.",
56 "No connection to the Duco Pre-Heater.",
"A Duco Pre-Heater is connected but not configured.",
57 "Unknown DUCO error");
58static_assert(ErrorCodes::COUNT + 1 == ErrorDescriptions::COUNT);
62static size_t format_errors(
const uint8_t *records, uint8_t
count,
char *text,
size_t size,
bool descriptions) {
64 for (uint8_t index = 0; index <
count; index++) {
65 const uint8_t *record = records + index * 5;
66 const size_t code_start =
pos;
67 pos = buf_append_printf(text,
size,
pos,
"E%02u.%02u.%02u", record[1], record[2], record[3]);
68 if (descriptions &&
pos <
size) {
72 reinterpret_cast<ESPHOME_PGM_P
>(ErrorDescriptions::get_progmem_str(description_index)));
76 return pos <= MAX_ERROR_TEXT_LENGTH ?
pos : 0;
85 this->
parent_->send(
this, FUNCTION_NODE_DATA, {0x01, 0x01, 0x00, 0x1a, 0x10});
87 this->
parent_->send(
this, FUNCTION_NODE_DATA, {0x01, this->
address_, 0x00, 0x08, 0x06});
91 this->
parent_->send(
this, FUNCTION_NODE_DATA, {0x01, this->
address_, 0x00, 0x00, 0x04});
94#ifdef USE_DUCO_ERROR_TEXT_SENSOR
95 this->
parent_->send(
this, FUNCTION_ERRORS, {this->
address_, 0x00, 0x00, 0x04});
99 this->
parent_->send(
this, FUNCTION_NODE_DATA, {0x01, this->
address_, 0x00, 0x49, 0x04});
116#ifdef USE_DUCO_ERROR_TEXT_SENSOR
134 const char *serial =
reinterpret_cast<const char *
>(
message.data + 2);
135 const auto serial_length = strnlen(serial,
message.size - 2);
136 if (serial_length == 0 || !std::all_of(serial, serial + serial_length, [](
char character) {
137 return std::isprint(
static_cast<unsigned char>(character));
150 snprintf(version,
sizeof(version),
"%u.%u.%u.%u", major, minor, patch, build);
154#ifdef USE_DUCO_ERROR_TEXT_SENSOR
160 const uint8_t error_count =
message.data[0];
161 if (
message.size < 1 +
static_cast<size_t>(error_count) * 5) {
162 ESP_LOGW(TAG,
"Error answer for %u errors has only %u bytes", error_count,
message.size);
166 char text[MAX_ERROR_TEXT_LENGTH + 2];
167 size_t length = format_errors(
message.data + 1, error_count, text,
sizeof(text),
true);
169 length = format_errors(
message.data + 1, error_count, text,
sizeof(text),
false);
178 const unsigned days = uptime_minutes / 1440;
179 const unsigned hours = uptime_minutes % 1440 / 60;
180 const unsigned minutes = uptime_minutes % 60;
182 snprintf(formatted,
sizeof(formatted),
"%ud %uh %um", days, hours, minutes);
void publish_errors_(const DucoMessage &message)
void publish_version_(const DucoMessage &message)
void receive_response(const DucoMessage &message) override
void publish_uptime_(const DucoMessage &message)
void publish_serial_number_(const DucoMessage &message)
void publish_state(const std::string &state)
const LogString * message
ESPHOME_LOG_TAG(TAG, "duco")
uint8_t node_type_byte(const DucoMessage &message)
The node type byte of a non-empty node answer; a one-byte answer has no network type.
PROGMEM_STRING_TABLE(ErrorCodes, "E01.04.01", "E03.01.01", "E03.01.02", "E03.01.03", "E03.01.04", "E03.01.05", "E03.01.06", "E04.01.01", "E04.01.02", "E04.01.03", "E04.01.04", "E04.01.05", "E04.01.06", "E06.01.01", "E06.01.02", "E06.01.03", "E06.01.04", "E06.01.05", "E06.01.06", "E16.01.01", "E16.01.02", "E16.01.03", "E16.01.04", "E16.01.05", "E16.01.06", "E28.04.01", "E29.01.01", "E29.01.02", "E29.01.03", "E29.01.04", "E29.01.05", "E29.01.06", "E30.01.01", "E30.01.02", "E30.01.03", "E30.01.04", "E30.01.05", "E30.01.06", "E31.19.01", "E32.10.01", "E33.10.01", "E35.17.01", "E35.17.02", "E35.17.03", "E36.24.01", "E36.24.02", "E37.17.01", "E37.17.02", "E37.17.03", "E40.17.01", "E40.17.02", "E40.17.03", "E42.22.01", "E42.22.02", "E43.23.01", "E43.23.02", "E44.06.01", "E44.06.02")
const LogString * node_type_name(uint8_t type)
The name of a node type byte.
@ DUCO_TEXT_READING_ERROR
@ DUCO_TEXT_READING_NODE_TYPE
@ DUCO_TEXT_READING_VERSION
@ DUCO_TEXT_READING_SERIAL_NUMBER
@ DUCO_TEXT_READING_UPTIME
size_t buf_append_str_p(char *buf, size_t size, size_t pos, PGM_P str)
Safely append a PROGMEM string to buffer, returning new position (capped at size).
size_t buf_append_str(char *buf, size_t size, size_t pos, const char *str)
Safely append a string to buffer, returning new position (capped at size).
int16_t progmem_string_table_find(const char *value, size_t len)
The index of the string value (len bytes, in RAM) in a PROGMEM_STRING_TABLE, or -1 when it is not one...
constexpr uint16_t encode_uint16(uint8_t msb, uint8_t lsb)
Encode a 16-bit value given the most and least significant byte.
const __FlashStringHelper * ProgmemStr
A received message; data points into the receive buffer and is valid only during the callback.