From 8033917a362e0f68596f048f658fff71898e4de0 Mon Sep 17 00:00:00 2001 From: Barbudor Date: Tue, 31 Aug 2021 17:51:18 +0200 Subject: [PATCH 1/2] fix opentherm json --- tasmota/xsns_69_opentherm.ino | 2 +- tasmota/xsns_69_opentherm_protocol.ino | 6 +----- 2 files changed, 2 insertions(+), 6 deletions(-) diff --git a/tasmota/xsns_69_opentherm.ino b/tasmota/xsns_69_opentherm.ino index 4dee38c01..ed24d9ca0 100644 --- a/tasmota/xsns_69_opentherm.ino +++ b/tasmota/xsns_69_opentherm.ino @@ -237,7 +237,7 @@ void sns_opentherm_stat(bool json) { ResponseAppend_P(PSTR(",\"OPENTHERM\":{")); ResponseAppend_P(PSTR("\"conn\":\"%s\","), statusStr); - ResponseAppend_P(PSTR("\"settings\":%d,"), Settings->ot_flags); + ResponseAppend_P(PSTR("\"settings\":%d"), Settings->ot_flags); sns_opentherm_dump_telemetry(); ResponseJsonEnd(); #ifdef USE_WEBSERVER diff --git a/tasmota/xsns_69_opentherm_protocol.ino b/tasmota/xsns_69_opentherm_protocol.ino index 0047252af..d01c29bb7 100644 --- a/tasmota/xsns_69_opentherm_protocol.ino +++ b/tasmota/xsns_69_opentherm_protocol.ino @@ -549,7 +549,6 @@ void sns_opentherm_process_success_response(struct OT_BOILER_STATUS_T *boilerSta void sns_opentherm_dump_telemetry() { - bool add_coma = false; for (int i = 0; i < SNS_OT_COMMANDS_COUNT; ++i) { struct OpenThermCommandT *cmd = &sns_opentherm_commands[i]; @@ -558,11 +557,8 @@ void sns_opentherm_dump_telemetry() continue; } - ResponseAppend_P(PSTR("%s\"%s\":"), add_coma ? "," : "", cmd->m_command_name); - + ResponseAppend_P(PSTR(",\"%s\":"), cmd->m_command_name); cmd->m_ot_appent_telemetry(cmd); - - add_coma = true; } } From 62946c22b06800964d912b194a2678ed9518cc26 Mon Sep 17 00:00:00 2001 From: Barbudor Date: Tue, 31 Aug 2021 18:01:01 +0200 Subject: [PATCH 2/2] refactor in single append --- tasmota/xsns_69_opentherm.ino | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/tasmota/xsns_69_opentherm.ino b/tasmota/xsns_69_opentherm.ino index ed24d9ca0..095a1909a 100644 --- a/tasmota/xsns_69_opentherm.ino +++ b/tasmota/xsns_69_opentherm.ino @@ -235,9 +235,7 @@ void sns_opentherm_stat(bool json) if (json) { - ResponseAppend_P(PSTR(",\"OPENTHERM\":{")); - ResponseAppend_P(PSTR("\"conn\":\"%s\","), statusStr); - ResponseAppend_P(PSTR("\"settings\":%d"), Settings->ot_flags); + ResponseAppend_P(PSTR(",\"OPENTHERM\":{\"conn\":\"%s\",\"settings\":%d"), statusStr, Settings->ot_flags); sns_opentherm_dump_telemetry(); ResponseJsonEnd(); #ifdef USE_WEBSERVER