Prepare for next zhc release

This commit is contained in:
Koen Kanters
2021-01-05 20:36:04 +01:00
parent adfb9f0c42
commit 4b8500603d
+6 -5
View File
@@ -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;