From 2cce06ed4e0fce7ddaa3b0dd017d593e313dab1e Mon Sep 17 00:00:00 2001 From: DigiH Date: Wed, 4 Dec 2024 01:04:56 +0100 Subject: [PATCH] [DISC] Defined boolean values (#2126) Defined boolean values in discovery message for cross platform discovery in HA and OH for binary_sensors. --- main/ZmqttDiscovery.ino | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/main/ZmqttDiscovery.ino b/main/ZmqttDiscovery.ino index 47e77dd505..bf2a4e1303 100644 --- a/main/ZmqttDiscovery.ino +++ b/main/ZmqttDiscovery.ino @@ -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]) { @@ -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]) {