endpoint support for binary and numeric discovery entries (#5771)

* endpoint support for binary and numeric exposes

* endpoint support for binary and numeric exposes
This commit is contained in:
xyzroe
2021-01-16 19:26:55 +02:00
committed by GitHub
parent 5050ca0dc0
commit bbe4f9cd5f
+2 -6
View File
@@ -319,11 +319,9 @@ class HomeAssistant extends Extension {
presence: {device_class: 'presence'},
};
assert(!expose.endpoint, `Endpoint not supported for binary type`);
discoveryEntry = {
type: 'binary_sensor',
object_id: expose.name,
object_id: expose.endpoint ? `${expose.name}_${expose.endpoint}` : `${expose.name}`,
discovery_payload: {
value_template: `{{ value_json.${expose.property} }}`,
payload_on: expose.value_on,
@@ -364,11 +362,9 @@ class HomeAssistant extends Extension {
local_temperature: {device_class: 'temperature'},
};
assert(!expose.endpoint, `Endpoint not supported for numeric type`);
discoveryEntry = {
type: 'sensor',
object_id: expose.name,
object_id: expose.endpoint ? `${expose.name}_${expose.endpoint}` : `${expose.name}`,
discovery_payload: {
unit_of_measurement: expose.unit ? expose.unit : '-',
value_template: `{{ value_json.${expose.property} }}`,