Skip to content

Commit

Permalink
[DISC] Defined boolean values (#2126)
Browse files Browse the repository at this point in the history
Defined boolean values in discovery message for cross platform discovery in HA and OH for binary_sensors.
  • Loading branch information
DigiH authored Dec 4, 2024
1 parent 9bb7751 commit 2cce06e
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions main/ZmqttDiscovery.ino
Original file line number Diff line number Diff line change
Expand Up @@ -329,7 +329,11 @@ void createDiscovery(const char* sensor_type,
int value = std::stoi(payload_on);
sensor["pos_open"] = value; // open value for curtain
} else {
sensor["pl_on"] = payload_on; // payload_on for the rest
if (strcmp(payload_on, "True") == 0 || strcmp(payload_on, "true") == 0) {
sensor["pl_on"] = true;
} else {
sensor["pl_on"] = payload_on; // payload_on for the rest
}
}
}
if (payload_off && payload_off[0]) {
Expand All @@ -339,7 +343,11 @@ void createDiscovery(const char* sensor_type,
int value = std::stoi(payload_off);
sensor["pos_clsd"] = value; // closed value for curtain
} else {
sensor["pl_off"] = payload_off; //payload_off
if (strcmp(payload_off, "False") == 0 || strcmp(payload_off, "false") == 0) {
sensor["pl_off"] = false;
} else {
sensor["pl_off"] = payload_off; //payload_off for the rest
}
}
}
if (command_template && command_template[0]) {
Expand Down

0 comments on commit 2cce06e

Please sign in to comment.