From 96c58fa66524616df70fec304bcfc589dcd5c2ad Mon Sep 17 00:00:00 2001 From: Marcel Date: Fri, 4 Dec 2020 15:53:32 +0100 Subject: [PATCH] Improved Opentherm error handling. - Added error counter avoiding disconnect state after single frame error. - Decreased cooldown period to avoid boiler entering PWM mode after line idle for more than 5s. --- tasmota/xsns_69_opentherm.ino | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/tasmota/xsns_69_opentherm.ino b/tasmota/xsns_69_opentherm.ino index e5f12c3f0..41f3377b7 100644 --- a/tasmota/xsns_69_opentherm.ino +++ b/tasmota/xsns_69_opentherm.ino @@ -33,7 +33,10 @@ #define OT_BOILER_DEFAULT 85; // Seconds before OT will make an attempt to connect to the boiler after connection error -#define SNS_OT_DISCONNECT_COOLDOWN_SECONDS 10 +#define SNS_OT_DISCONNECT_COOLDOWN_SECONDS 4 + +// Number of consecutive timeouts which are accepted before entering disconnect state +#define SNS_OT_MAX_TIMEOUTS_BEFORE_DISCONNECT 3 // Count of the OpenThermSettingsFlags #define OT_FLAGS_COUNT 6 @@ -63,6 +66,7 @@ enum OpenThermConnectionStatus OpenThermConnectionStatus sns_ot_connection_status = OpenThermConnectionStatus::OTC_NONE; uint8_t sns_ot_disconnect_cooldown = 0; +uint8_t sns_ot_timeout_before_disconnect = 0; OpenTherm *sns_ot_master = NULL; @@ -178,11 +182,13 @@ void sns_opentherm_processResponseCallback(unsigned long response, int st) sns_opentherm_process_success_response(&sns_ot_boiler_status, response); } sns_ot_connection_status = OpenThermConnectionStatus::OTC_READY; + sns_ot_timeout_before_disconnect = SNS_OT_MAX_TIMEOUTS_BEFORE_DISCONNECT; break; case OpenThermResponseStatus::INVALID: sns_opentherm_check_retry_request(); sns_ot_connection_status = OpenThermConnectionStatus::OTC_READY; + sns_ot_timeout_before_disconnect = SNS_OT_MAX_TIMEOUTS_BEFORE_DISCONNECT; break; // Timeout may indicate not valid/supported command or connection error @@ -191,7 +197,14 @@ void sns_opentherm_processResponseCallback(unsigned long response, int st) // after couple of failed attempts. See sns_opentherm_check_retry_request logic case OpenThermResponseStatus::TIMEOUT: sns_opentherm_check_retry_request(); - sns_ot_connection_status = OpenThermConnectionStatus::OTC_DISCONNECTED; + if (--sns_ot_timeout_before_disconnect == 0) + { + sns_ot_connection_status = OpenThermConnectionStatus::OTC_DISCONNECTED; + } + else + { + sns_ot_connection_status = OpenThermConnectionStatus::OTC_READY; + } break; } }