Skip to content

Commit

Permalink
Merge pull request #33 from pzbitskiy/pavel/cc+str-fixes
Browse files Browse the repository at this point in the history
Compliation warning fixes + strcat usage fix
  • Loading branch information
dzungpv authored Aug 28, 2024
2 parents eb27777 + f5eb894 commit 5e3d619
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 15 deletions.
2 changes: 1 addition & 1 deletion main/language_util.h
Original file line number Diff line number Diff line change
Expand Up @@ -76,14 +76,14 @@ 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)
{
return ""; // no translations
}
#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;
Expand Down
30 changes: 16 additions & 14 deletions main/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand All @@ -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";
Expand Down Expand Up @@ -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)
Expand Down

0 comments on commit 5e3d619

Please sign in to comment.