From 4fbfec3fdbb13eb4330d8e6bbd646b76cd40bc18 Mon Sep 17 00:00:00 2001 From: ptvo <33662022+ptvoinfo@users.noreply.github.com> Date: Thu, 9 Jul 2020 22:10:10 +0300 Subject: [PATCH] ptvo.switch - updated HA integration settings. (#3880) * ptvo.switch - updated HA integration settings. * Update homeassistant.js Co-authored-by: ptvoinfo Co-authored-by: Koen Kanters --- lib/extension/homeassistant.js | 20 ++++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) diff --git a/lib/extension/homeassistant.js b/lib/extension/homeassistant.js index 116d17fd..9a8a4c3f 100644 --- a/lib/extension/homeassistant.js +++ b/lib/extension/homeassistant.js @@ -686,6 +686,16 @@ const lightEndpoint = (configType, endpointName) => { return config; }; +const sensorEndpoint = (endpointName) => { + return { + type: 'sensor', + object_id: `sensor_${endpointName}`, + discovery_payload: { + value_template: `{{ value_json.${endpointName} }}`, + }, + }; +}; + const thermostat = (minTemp=7, maxTemp=30, temperatureStateProperty='occupied_heating_setpoint', tempStep=1) => { return { type: 'climate', @@ -1269,8 +1279,14 @@ const mapping = { 'PM-B530-ZB': [cfg.sensor_power, cfg.switch], 'PM-B430-ZB': [cfg.sensor_power, cfg.switch], 'ptvo.switch': [ - switchEndpoint('bottom_left'), switchEndpoint('bottom_right'), switchEndpoint('top_left'), - switchEndpoint('top_right'), switchEndpoint('center'), cfg.sensor_click, + switchEndpoint('l1'), switchEndpoint('l2'), switchEndpoint('l3'), + switchEndpoint('l4'), switchEndpoint('l5'), switchEndpoint('l6'), + switchEndpoint('l7'), switchEndpoint('l8'), + sensorEndpoint('l1'), sensorEndpoint('l2'), sensorEndpoint('l3'), + sensorEndpoint('l4'), sensorEndpoint('l5'), sensorEndpoint('l6'), + sensorEndpoint('l7'), sensorEndpoint('l8'), + cfg.sensor_click, cfg.sensor_temperature, cfg.sensor_voltage, + cfg.sensor_pressure, cfg.sensor_humidity, ], 'DIYRuZ_R4_5': [ switchEndpoint('bottom_left'), switchEndpoint('bottom_right'), switchEndpoint('top_left'),