Skip to content

Commit

Permalink
fix stat_class for HA
Browse files Browse the repository at this point in the history
  • Loading branch information
softwarecrash committed Dec 14, 2023
1 parent b9c1b1d commit 22f9ab9
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
2 changes: 1 addition & 1 deletion platformio.ini
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ framework = arduino
monitor_speed = 115200
monitor_filters = esp8266_exception_decoder, default, time, printable, colorize

custom_prog_version = 2.2.0A-1
custom_prog_version = 2.2.1

build_flags =
-DVERSION=${this.custom_prog_version}
Expand Down
6 changes: 3 additions & 3 deletions src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -697,7 +697,7 @@ bool getEpData(int invNum)
bool getJsonData(int invNum)
{

// for (size_t invNum = 1; invNum <= 3; invNum++) // for testing only{
// for (size_t invNum = 1; invNum <= 3; invNum++) // for testing only{
liveJson["EP_" + String(invNum)]["LiveData"]["CONNECTION"] = errorcode;

liveJson["EP_" + String(invNum)]["LiveData"]["DEVICE_NUM"] = String(invNum); // for testing
Expand Down Expand Up @@ -985,9 +985,9 @@ bool sendHaDiscovery()
if (strlen(haDescriptor[i][2]) != 0)
haPayLoad += (String) "\"unit_of_meas\":\"" + haDescriptor[i][2] + "\",";

if (haDescriptor[i][2] == "kWh" || haDescriptor[i][2] == "Wh")
if (strcmp(haDescriptor[i][2], "kWh") == 0 || strcmp(haDescriptor[i][2], "Wh") == 0)
haPayLoad += (String) "\"state_class\":\"total_increasing\",";
if (haDescriptor[i][2] == "A" || haDescriptor[i][2] == "V" || haDescriptor[i][2] == "W")
if (strcmp(haDescriptor[i][2], "A") == 0 || strcmp(haDescriptor[i][2], "V") == 0 || strcmp(haDescriptor[i][2], "W") == 0)
haPayLoad += (String) "\"state_class\":\"measurement\",";

if (strlen(haDescriptor[i][3]) != 0)
Expand Down

0 comments on commit 22f9ab9

Please sign in to comment.