Allow binary exposes not in lookup.

This commit is contained in:
Koen Kanters 2020-10-26 17:25:41 +01:00
parent fee631080e
commit 922f828696

View File

@ -1165,9 +1165,6 @@ class HomeAssistant extends Extension {
const lookup = {
occupancy: {device_class: 'motion'},
battery_low: {device_class: 'battery'},
tamper: {},
moving: {},
sos: {},
water_leak: {device_class: 'moisture'},
vibration: {device_class: 'vibration'},
contact: {device_class: 'door'},
@ -1177,7 +1174,6 @@ class HomeAssistant extends Extension {
};
assert(!expose.endpoint, `Endpoint not supported for binary type`);
assert(lookup[expose.name], `${expose.name} not in lookup`);
discoveryEntry = {
type: 'binary_sensor',
@ -1186,7 +1182,7 @@ class HomeAssistant extends Extension {
value_template: `{{ value_json.${expose.property} }}`,
payload_on: expose.value_on,
payload_off: expose.value_off,
...lookup[expose.name],
...(lookup[expose.name] || {}),
},
};
} else if (expose.type === 'numeric') {