From 5393c38ad4b2cc12cc876c5a3f3c2c5601e9a161 Mon Sep 17 00:00:00 2001 From: Pavel Zbitskiy Date: Wed, 31 Jul 2024 00:23:08 -0400 Subject: [PATCH 1/2] Fix compilation warnings --- main/language_util.h | 2 +- main/main.cpp | 26 +++++++++++++------------- 2 files changed, 14 insertions(+), 14 deletions(-) diff --git a/main/language_util.h b/main/language_util.h index 944dee9..2b29e4b 100644 --- a/main/language_util.h +++ b/main/language_util.h @@ -76,7 +76,6 @@ char buffer[200]; // buffer for reading the string to (needs to be large enough const char *translatedWord(const char *const *strings, const bool force_en) { uint8_t language_index = system_language_index; // default 0 for English - uint8_t index = 0; if (!strings) { @@ -84,6 +83,7 @@ const char *translatedWord(const char *const *strings, const bool force_en) } #ifdef ESP32 // see how many translations we have for this entity. if there is no translation for this, revert to EN + // uint8_t index = 0; // if (!force_en && (countItems(strings) >= language_index + 1 && strlen(strings[language_index]))) // { // index = language_index; diff --git a/main/main.cpp b/main/main.cpp index 184e13c..bbfbb94 100644 --- a/main/main.cpp +++ b/main/main.cpp @@ -1648,7 +1648,7 @@ void handleMetrics(AsyncWebServerRequest *request) heatpumpSettings currentSettings = hp.getSettings(); heatpumpStatus currentStatus = hp.getStatus(); - String hppower = currentSettings.power == "ON" ? "1" : "0"; + String hppower = strcmp(currentSettings.power, "ON") == 0 ? "1" : "0"; String hpfan = currentSettings.fan; if (hpfan == "AUTO") @@ -1663,31 +1663,31 @@ void handleMetrics(AsyncWebServerRequest *request) hpvane = "0"; String hpwidevane = "-2"; - if (currentSettings.wideVane == "SWING") + if (strcmp(currentSettings.wideVane, "SWING") == 0) hpwidevane = "0"; - if (currentSettings.wideVane == "<<") + if (strcmp(currentSettings.wideVane, "<<") == 0) hpwidevane = "1"; - if (currentSettings.wideVane == "<") + if (strcmp(currentSettings.wideVane, "<") == 0) hpwidevane = "2"; - if (currentSettings.wideVane == "|") + if (strcmp(currentSettings.wideVane, "|") == 0) hpwidevane = "3"; - if (currentSettings.wideVane == ">") + if (strcmp(currentSettings.wideVane, ">") == 0) hpwidevane = "4"; - if (currentSettings.wideVane == ">>") + if (strcmp(currentSettings.wideVane, ">>") == 0) hpwidevane = "5"; - if (currentSettings.wideVane == "<>") + if (strcmp(currentSettings.wideVane, "<>") == 0) hpwidevane = "6"; String hpmode = "-2"; - if (currentSettings.mode == "AUTO") + if (strcmp(currentSettings.mode, "AUTO") == 0) hpmode = "-1"; - if (currentSettings.mode == "COOL") + if (strcmp(currentSettings.mode, "COOL") == 0) hpmode = "1"; - if (currentSettings.mode == "DRY") + if (strcmp(currentSettings.mode, "DRY") == 0) hpmode = "2"; - if (currentSettings.mode == "HEAT") + if (strcmp(currentSettings.mode, "HEAT") == 0) hpmode = "3"; - if (currentSettings.mode == "FAN") + if (strcmp(currentSettings.mode, "FAN") == 0) hpmode = "4"; if (hppower == "0") hpmode = "0"; From f5eb894b8aca531b2ff76f62828cabbf452627da Mon Sep 17 00:00:00 2001 From: Pavel Zbitskiy Date: Thu, 1 Aug 2024 20:46:49 -0400 Subject: [PATCH 2/2] Fix invalid strcat usage --- main/main.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/main/main.cpp b/main/main.cpp index bbfbb94..cc50292 100644 --- a/main/main.cpp +++ b/main/main.cpp @@ -2533,7 +2533,9 @@ void mqttCallback(const char *topic, const uint8_t *payload, const unsigned int } else { - mqttClient->publish(ha_debug_logs_topic.c_str(), 1, false, strcat((char *)"heatpump: wrong mqtt topic: ", topic)); + String msg("heatpump: wrong mqtt topic: "); + msg += topic; + mqttClient->publish(ha_debug_logs_topic.c_str(), 1, false, msg.c_str()); } if (update)