Skip to content

Commit d1e9e8b

Browse files
authored
[RN8209] Fix in use switch value (#1572)
1 parent 11faf9a commit d1e9e8b

File tree

2 files changed

+3
-3
lines changed

2 files changed

+3
-3
lines changed

main/ZmqttDiscovery.ino

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -897,7 +897,7 @@ void pubMqttDiscovery() {
897897
{"sensor", "volt", "RN8209", "voltage", jsonVolt, "", "", "V"},
898898
{"sensor", "current", "RN8209", "current", jsonCurrent, "", "", "A"},
899899
{"sensor", "power", "RN8209", "power", jsonPower, "", "", "W"},
900-
{"binary_sensor", "inUse", "RN8209", "power", jsonInuseRN8209, "", "", ""}
900+
{"binary_sensor", "inUse", "RN8209", "power", jsonInuseRN8209, "on", "off", ""}
901901
//component type,name,availability topic,device class,value template,payload on, payload off, unit of measurement
902902
};
903903

main/config_mqttDiscovery.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -171,7 +171,7 @@ void announceDeviceTrigger(bool use_gateway_info,
171171
# define jsonCount "{{ value_json.count }}"
172172
# define jsonAlarm "{{ value_json.alarm }}"
173173
# define jsonInuse "{{ value_json.power | float > 0 }}"
174-
# define jsonInuseRN8209 "{{ value_json.power | float > 0.02 }}"
174+
# define jsonInuseRN8209 "{% if value_json.power > 0.02 -%} on {% else %} off {%- endif %}"
175175
# define jsonVoltBM2 "{% if value_json.uuid is not defined -%} {{value_json.volt}} {%- endif %}"
176176
#else // Home assistant autodiscovery value key definition
177177
# define jsonBatt "{{ value_json.batt | is_defined }}"
@@ -209,7 +209,7 @@ void announceDeviceTrigger(bool use_gateway_info,
209209
# define jsonCount "{{ value_json.count | is_defined }}"
210210
# define jsonAlarm "{{ value_json.alarm | is_defined }}"
211211
# define jsonInuse "{{ value_json.power | is_defined | float > 0 }}"
212-
# define jsonInuseRN8209 "{{ value_json.power | is_defined | float > 0.02 }}"
212+
# define jsonInuseRN8209 "{% if value_json.power > 0.02 -%} on {% else %} off {%- endif %}"
213213
# define jsonVoltBM2 "{% if value_json.uuid is not defined and value_json.volt is defined -%} {{value_json.volt}} {%- endif %}"
214214
#endif
215215

0 commit comments

Comments
 (0)