From 032a82e5e2e0cd233484a9b553bb2a890475de53 Mon Sep 17 00:00:00 2001 From: Northern Man <19808920+NorthernMan54@users.noreply.github.com> Date: Thu, 23 Feb 2023 14:52:29 -0500 Subject: [PATCH] Create in use binary sensor for RN8209 Current sensor (#1474) --- main/ZmqttDiscovery.ino | 2 +- main/config_mqttDiscovery.h | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/main/ZmqttDiscovery.ino b/main/ZmqttDiscovery.ino index ae5cb9c..52801b4 100644 --- a/main/ZmqttDiscovery.ino +++ b/main/ZmqttDiscovery.ino @@ -779,7 +779,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", jsonPower, "", "", ""} + {"binary_sensor", "inUse", "RN8209", "power", jsonInuse, "", "", ""} //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 2a3e7d1..5a3ed1c 100644 --- a/main/config_mqttDiscovery.h +++ b/main/config_mqttDiscovery.h @@ -166,6 +166,7 @@ void announceDeviceTrigger(bool use_gateway_info, # define jsonTime "{{ value_json.time }}" # define jsonCount "{{ value_json.count }}" # define jsonAlarm "{{ value_json.alarm }}" +# define jsonInuse "{{ value_json.power | float > 0 }}" #else // Home assistant autodiscovery value key definition # define jsonBatt "{{ value_json.batt | is_defined }}" # define jsonLux "{{ value_json.lux | is_defined }}" @@ -201,6 +202,7 @@ void announceDeviceTrigger(bool use_gateway_info, # define jsonTime "{{ value_json.time | is_defined }}" # define jsonCount "{{ value_json.count | is_defined }}" # define jsonAlarm "{{ value_json.alarm | is_defined }}" +# define jsonInuse "{{ value_json.power | is_defined | float > 0 }}" #endif #define stateClassNone ""