From d1e9e8bf9b47a606b985ffdb9ce818fefad73af8 Mon Sep 17 00:00:00 2001 From: Florian Date: Thu, 23 Mar 2023 18:25:13 -0500 Subject: [PATCH] [RN8209] Fix in use switch value (#1572) --- main/ZmqttDiscovery.ino | 2 +- main/config_mqttDiscovery.h | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/main/ZmqttDiscovery.ino b/main/ZmqttDiscovery.ino index bd17fa9..0ac8858 100644 --- a/main/ZmqttDiscovery.ino +++ b/main/ZmqttDiscovery.ino @@ -897,7 +897,7 @@ void pubMqttDiscovery() { {"sensor", "volt", "RN8209", "voltage", jsonVolt, "", "", "V"}, {"sensor", "current", "RN8209", "current", jsonCurrent, "", "", "A"}, {"sensor", "power", "RN8209", "power", jsonPower, "", "", "W"}, - {"binary_sensor", "inUse", "RN8209", "power", jsonInuseRN8209, "", "", ""} + {"binary_sensor", "inUse", "RN8209", "power", jsonInuseRN8209, "on", "off", ""} //component type,name,availability topic,device class,value template,payload on, payload off, unit of measurement }; diff --git a/main/config_mqttDiscovery.h b/main/config_mqttDiscovery.h index f77cdf9..410142f 100644 --- a/main/config_mqttDiscovery.h +++ b/main/config_mqttDiscovery.h @@ -171,7 +171,7 @@ void announceDeviceTrigger(bool use_gateway_info, # define jsonCount "{{ value_json.count }}" # define jsonAlarm "{{ value_json.alarm }}" # define jsonInuse "{{ value_json.power | float > 0 }}" -# define jsonInuseRN8209 "{{ value_json.power | float > 0.02 }}" +# define jsonInuseRN8209 "{% if value_json.power > 0.02 -%} on {% else %} off {%- endif %}" # define jsonVoltBM2 "{% if value_json.uuid is not defined -%} {{value_json.volt}} {%- endif %}" #else // Home assistant autodiscovery value key definition # define jsonBatt "{{ value_json.batt | is_defined }}" @@ -209,7 +209,7 @@ void announceDeviceTrigger(bool use_gateway_info, # define jsonCount "{{ value_json.count | is_defined }}" # define jsonAlarm "{{ value_json.alarm | is_defined }}" # define jsonInuse "{{ value_json.power | is_defined | float > 0 }}" -# define jsonInuseRN8209 "{{ value_json.power | is_defined | float > 0.02 }}" +# define jsonInuseRN8209 "{% if value_json.power > 0.02 -%} on {% else %} off {%- endif %}" # define jsonVoltBM2 "{% if value_json.uuid is not defined and value_json.volt is defined -%} {{value_json.volt}} {%- endif %}" #endif