From 4b8500603ddfeffdb5ad0a2ba3da223cc1367048 Mon Sep 17 00:00:00 2001 From: Koen Kanters Date: Tue, 5 Jan 2021 20:36:04 +0100 Subject: [PATCH] Prepare for next zhc release --- lib/extension/homeassistant.js | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/lib/extension/homeassistant.js b/lib/extension/homeassistant.js index 101981ba..99c7c232 100644 --- a/lib/extension/homeassistant.js +++ b/lib/extension/homeassistant.js @@ -111,18 +111,19 @@ class HomeAssistant extends Extension { type: 'switch', object_id: expose.endpoint ? `switch_${expose.endpoint}` : 'switch', discovery_payload: { - payload_off: 'OFF', - payload_on: 'ON', + payload_off: state.value_off, + payload_on: state.value_on, value_template: `{{ value_json.${state.property} }}`, command_topic: true, command_topic_prefix: expose.endpoint ? expose.endpoint : undefined, }, }; - if (state.property === 'valve_detection' || state.property === 'window_detection') { + const different = ['valve_detection', 'window_detection', 'auto_lock', 'away_mode']; + if (different.includes(state.property)) { discoveryEntry.discovery_payload.command_topic_postfix = state.property; - discoveryEntry.discovery_payload.state_off = 'OFF'; - discoveryEntry.discovery_payload.state_on = 'ON'; + discoveryEntry.discovery_payload.state_off = state.value_off; + discoveryEntry.discovery_payload.state_on = state.value_on; discoveryEntry.discovery_payload.state_topic = true; discoveryEntry.object_id = state.property;