9 static const char *
const TAG =
"opentherm";
10 namespace message_data {
74 bool const ch_enabled = this->ch_enable && OPENTHERM_READ_ch_enable && OPENTHERM_READ_t_set > 0.0;
75 bool const dhw_enabled = this->dhw_enable && OPENTHERM_READ_dhw_enable;
76 bool const cooling_enabled =
77 this->cooling_enable && OPENTHERM_READ_cooling_enable && OPENTHERM_READ_cooling_control > 0.0;
78 bool const otc_enabled = this->otc_active && OPENTHERM_READ_otc_active;
79 bool const ch2_enabled = this->ch2_active && OPENTHERM_READ_ch2_active && OPENTHERM_READ_t_set_ch2 > 0.0;
80 bool const summer_mode_is_active = this->summer_mode_active && OPENTHERM_READ_summer_mode_active;
81 bool const dhw_blocked = this->dhw_block && OPENTHERM_READ_dhw_block;
86 data.
valueHB = ch_enabled | (dhw_enabled << 1) | (cooling_enabled << 2) | (otc_enabled << 3) | (ch2_enabled << 4) |
87 (summer_mode_is_active << 5) | (dhw_blocked << 6);
96 data.
f88(this->opentherm_version_);
103 #pragma GCC diagnostic push 104 #pragma GCC diagnostic ignored "-Wswitch" 110 switch (request_id) {
111 OPENTHERM_SWITCH_MESSAGE_HANDLERS(OPENTHERM_MESSAGE_WRITE_MESSAGE, OPENTHERM_MESSAGE_WRITE_ENTITY, ,
112 OPENTHERM_MESSAGE_WRITE_POSTSCRIPT, )
113 OPENTHERM_NUMBER_MESSAGE_HANDLERS(OPENTHERM_MESSAGE_WRITE_MESSAGE, OPENTHERM_MESSAGE_WRITE_ENTITY, ,
114 OPENTHERM_MESSAGE_WRITE_POSTSCRIPT, )
115 OPENTHERM_OUTPUT_MESSAGE_HANDLERS(OPENTHERM_MESSAGE_WRITE_MESSAGE, OPENTHERM_MESSAGE_WRITE_ENTITY, ,
116 OPENTHERM_MESSAGE_WRITE_POSTSCRIPT, )
117 OPENTHERM_INPUT_SENSOR_MESSAGE_HANDLERS(OPENTHERM_MESSAGE_WRITE_MESSAGE, OPENTHERM_MESSAGE_WRITE_ENTITY, ,
118 OPENTHERM_MESSAGE_WRITE_POSTSCRIPT, )
122 switch (request_id) { OPENTHERM_SENSOR_MESSAGE_HANDLERS(OPENTHERM_MESSAGE_READ_MESSAGE, OPENTHERM_IGNORE, , , ) }
123 switch (request_id) {
124 OPENTHERM_BINARY_SENSOR_MESSAGE_HANDLERS(OPENTHERM_MESSAGE_READ_MESSAGE, OPENTHERM_IGNORE, , , )
126 #pragma GCC diagnostic pop 131 ESP_LOGE(TAG,
"Tried to create a request with unknown id %d. This should never happen, so please open an issue.",
139 ESP_LOGD(TAG,
"Received OpenTherm response with id %d (%s)", data.
id,
140 this->opentherm_->message_id_to_str((
MessageId) data.
id));
144 OPENTHERM_SENSOR_MESSAGE_HANDLERS(OPENTHERM_MESSAGE_RESPONSE_MESSAGE, OPENTHERM_MESSAGE_RESPONSE_ENTITY, ,
145 OPENTHERM_MESSAGE_RESPONSE_POSTSCRIPT, )
148 OPENTHERM_BINARY_SENSOR_MESSAGE_HANDLERS(OPENTHERM_MESSAGE_RESPONSE_MESSAGE, OPENTHERM_MESSAGE_RESPONSE_ENTITY, ,
149 OPENTHERM_MESSAGE_RESPONSE_POSTSCRIPT, )
154 ESP_LOGD(TAG,
"Setting up OpenTherm component");
157 ESP_LOGE(TAG,
"Failed to initialize OpenTherm protocol. See previous log messages for details.");
186 auto const cur_mode = this->
opentherm_->get_mode();
227 ESP_LOGE(TAG,
"OpenTherm is not idle at the start of the loop");
242 ESP_LOGE(TAG,
"Hub timeout triggered during send");
252 ESP_LOGW(TAG,
"Unexpected state after sending request: %s",
253 this->
opentherm_->operation_mode_to_str(this->opentherm_->get_mode()));
261 ESP_LOGE(TAG,
"Hub timeout triggered during receive");
270 }
else if (this->
opentherm_->is_protocol_error()) {
274 }
else if (!this->
opentherm_->has_message()) {
275 ESP_LOGW(TAG,
"Unexpected state after receiving response: %s",
276 this->
opentherm_->operation_mode_to_str(this->opentherm_->get_mode()));
287 "%d ms elapsed since the start of the last convo, but 1150 ms are allowed at maximum. Look at other " 288 "components that might slow the loop down.",
299 ESP_LOGV(TAG,
"Less than 100 ms elapsed since last convo, skipping this iteration");
316 ESP_LOGD(TAG,
"Sending request with id %d (%s)", request.id,
317 this->opentherm_->message_id_to_str((
MessageId) request.id));
326 if (!this->
opentherm_->get_message(response)) {
327 ESP_LOGW(TAG,
"Couldn't get the response, but flags indicated success. This is a bug.");
344 ESP_LOGW(TAG,
"Error while sending request: %s",
345 this->
opentherm_->operation_mode_to_str(this->opentherm_->get_mode()));
351 ESP_LOGW(TAG,
"Protocol error occured while receiving response: %s",
356 ESP_LOGW(TAG,
"Receive response timed out at a protocol level");
361 ESP_LOGCONFIG(TAG,
"OpenTherm:");
362 LOG_PIN(
" In: ", this->
in_pin_);
364 ESP_LOGCONFIG(TAG,
" Sync mode: %d", this->
sync_mode_);
366 ESP_LOGCONFIG(TAG,
" Binary sensors: %s", SHOW(OPENTHERM_BINARY_SENSOR_LIST(ID, )));
368 ESP_LOGCONFIG(TAG,
" Input sensors: %s", SHOW(OPENTHERM_INPUT_SENSOR_LIST(ID, )));
370 ESP_LOGCONFIG(TAG,
" Numbers: %s", SHOW(OPENTHERM_NUMBER_LIST(ID, )));
371 ESP_LOGCONFIG(TAG,
" Initial requests:");
375 ESP_LOGCONFIG(TAG,
" Repeating requests:");
void write_flag8_lb_2(const bool value, OpenthermData &data)
bool should_skip_loop_(uint32_t cur_time) const
uint16_t parse_u8_lb_60(OpenthermData &data)
uint16_t parse_u16(OpenthermData &data)
constexpr T read_bit(T value, uint8_t bit)
bool check_timings_(uint32_t cur_time)
bool parse_flag8_hb_3(OpenthermData &data)
int8_t parse_s8_lb(OpenthermData &data)
void handle_protocol_read_error_()
void write_u16(const uint16_t value, OpenthermData &data)
void write_flag8_lb_1(const bool value, OpenthermData &data)
int16_t parse_s16(OpenthermData &data)
void write_s8_lb(const int8_t value, OpenthermData &data)
float parse_f88(OpenthermData &data)
void write_flag8_lb_7(const bool value, OpenthermData &data)
bool parse_flag8_lb_4(OpenthermData &data)
void write_s8_hb(const int8_t value, OpenthermData &data)
bool parse_flag8_lb_3(OpenthermData &data)
uint32_t last_conversation_start_
std::vector< MessageId >::const_iterator current_message_iterator_
uint16_t parse_u8_hb_60(OpenthermData &data)
void write_flag8_lb_3(const bool value, OpenthermData &data)
void process_response(OpenthermData &data)
ProtocolErrorType error_type
timeout while waiting to receive bytes
void write_f88(const float value, OpenthermData &data)
InternalGPIOPin * in_pin_
constexpr T write_bit(T value, uint8_t bit, uint8_t bit_value)
OPENTHERM_OUTPUT_LIST(OPENTHERM_DECLARE_OUTPUT,) OPENTHERM_INPUT_SENSOR_LIST(OPENTHERM_DECLARE_INPUT_SENSOR
std::unique_ptr< OpenTherm > opentherm_
bool parse_flag8_hb_1(OpenthermData &data)
void handle_protocol_write_error_()
void write_flag8_hb_4(const bool value, OpenthermData &data)
uint32_t IRAM_ATTR HOT millis()
bool parse_flag8_hb_2(OpenthermData &data)
bool parse_flag8_lb_0(OpenthermData &data)
bool spin_wait_(uint32_t timeout, F func)
void write_s16(const int16_t value, OpenthermData &data)
bool parse_flag8_lb_5(OpenthermData &data)
void write_flag8_hb_6(const bool value, OpenthermData &data)
bool parse_flag8_lb_7(OpenthermData &data)
bool parse_flag8_lb_6(OpenthermData &data)
void start_conversation_()
void write_flag8_hb_0(const bool value, OpenthermData &data)
void write_flag8_lb_4(const bool value, OpenthermData &data)
int8_t parse_s8_hb(OpenthermData &data)
uint32_t last_conversation_end_
InternalGPIOPin * out_pin_
bool parse_flag8_lb_1(OpenthermData &data)
std::vector< MessageId > initial_messages_
bool parse_flag8_hb_0(OpenthermData &data)
void write_flag8_lb_6(const bool value, OpenthermData &data)
bool parse_flag8_hb_7(OpenthermData &data)
std::vector< MessageId > repeating_messages_
uint8_t parse_u8_lb(OpenthermData &data)
void write_flag8_hb_5(const bool value, OpenthermData &data)
void write_flag8_hb_1(const bool value, OpenthermData &data)
bool parse_flag8_hb_4(OpenthermData &data)
void write_flag8_hb_2(const bool value, OpenthermData &data)
void dump_config() override
bool parse_flag8_hb_6(OpenthermData &data)
bool parse_flag8_lb_2(OpenthermData &data)
virtual void mark_failed()
Mark this component as failed.
void write_flag8_hb_3(const bool value, OpenthermData &data)
OPENTHERM_SWITCH_LIST(OPENTHERM_DECLARE_SWITCH,) OPENTHERM_NUMBER_LIST(OPENTHERM_DECLARE_NUMBER
void write_flag8_hb_7(const bool value, OpenthermData &data)
Implementation of SPI Controller mode.
void write_u8_lb(const uint8_t value, OpenthermData &data)
void write_u8_hb(const uint8_t value, OpenthermData &data)
void add_repeating_message(MessageId message_id)
Structure to hold Opentherm data packet content.
void handle_timeout_error_()
OPENTHERM_SENSOR_LIST(OPENTHERM_DECLARE_SENSOR,) OPENTHERM_BINARY_SENSOR_LIST(OPENTHERM_DECLARE_BINARY_SENSOR
uint8_t parse_u8_hb(OpenthermData &data)
void write_flag8_lb_5(const bool value, OpenthermData &data)
void on_shutdown() override
OpenthermData build_request_(MessageId request_id) const
void write_flag8_lb_0(const bool value, OpenthermData &data)
OpenthermData last_request_
bool parse_flag8_hb_5(OpenthermData &data)