From e1b5a105dde8a2caa28f7721a70970cda9727839 Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" <41898282+github-actions[bot]@users.noreply.github.com> Date: Fri, 30 Oct 2020 23:39:26 +0100 Subject: [PATCH] Update zigbee-herdsman-converters to 12.0.223 (#4820) * Update zigbee-herdsman-converters to 12.0.223 * Update homeassistant.js * Update bridge.test.js Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> Co-authored-by: Koen Kanters --- lib/extension/homeassistant.js | 675 +++------------------------------ npm-shrinkwrap.json | 6 +- package.json | 2 +- test/bridge.test.js | 2 +- 4 files changed, 48 insertions(+), 637 deletions(-) diff --git a/lib/extension/homeassistant.js b/lib/extension/homeassistant.js index 1033b1b31..d78705773 100644 --- a/lib/extension/homeassistant.js +++ b/lib/extension/homeassistant.js @@ -9,72 +9,6 @@ const assert = require('assert'); const cfg = { // Binary sensor - 'binary_sensor_occupancy': { - type: 'binary_sensor', - object_id: 'occupancy', - discovery_payload: { - payload_on: true, - payload_off: false, - value_template: '{{ value_json.occupancy }}', - device_class: 'motion', - }, - }, - 'binary_sensor_alarm': { - type: 'binary_sensor', - object_id: 'alarm', - discovery_payload: { - payload_on: true, - payload_off: false, - value_template: '{{ value_json.alarm }}', - }, - }, - 'binary_sensor_temperature_alarm': { - type: 'binary_sensor', - object_id: 'temperature_alarm', - discovery_payload: { - payload_on: true, - payload_off: false, - value_template: '{{ value_json.temperature_alarm }}', - }, - }, - 'binary_sensor_humidity_alarm': { - type: 'binary_sensor', - object_id: 'humidity_alarm', - discovery_payload: { - payload_on: true, - payload_off: false, - value_template: '{{ value_json.humidity_alarm }}', - }, - }, - 'binary_sensor_presence': { - type: 'binary_sensor', - object_id: 'presence', - discovery_payload: { - payload_on: true, - payload_off: false, - value_template: '{{ value_json.presence }}', - device_class: 'presence', - }, - }, - 'binary_sensor_tamper': { - type: 'binary_sensor', - object_id: 'tamper', - discovery_payload: { - payload_on: false, - payload_off: true, - value_template: '{{ value_json.tamper }}', - }, - }, - 'binary_sensor_contact': { - type: 'binary_sensor', - object_id: 'contact', - discovery_payload: { - payload_on: false, - payload_off: true, - value_template: '{{ value_json.contact }}', - device_class: 'door', - }, - }, 'binary_sensor_water_leak': { type: 'binary_sensor', object_id: 'water_leak', @@ -85,26 +19,6 @@ const cfg = { device_class: 'moisture', }, }, - 'binary_sensor_vibration': { - type: 'binary_sensor', - object_id: 'vibration', - discovery_payload: { - payload_on: true, - payload_off: false, - value_template: '{{ value_json.vibration }}', - device_class: 'vibration', - }, - }, - 'binary_sensor_led': { - type: 'binary_sensor', - object_id: 'led', - discovery_payload: { - payload_on: true, - payload_off: false, - value_template: '{{ value_json.led }}', - device_class: 'light', - }, - }, 'binary_sensor_battery_low': { type: 'binary_sensor', object_id: 'battery_low', @@ -124,36 +38,6 @@ const cfg = { value_template: '{{ value_json.update_available}}', }, }, - 'binary_sensor_lock': { - type: 'binary_sensor', - object_id: 'lock', - discovery_payload: { - payload_on: 'UNLOCK', - payload_off: 'LOCK', - value_template: '{{ value_json.state}}', - device_class: 'lock', - }, - }, - 'binary_sensor_lock_reverse': { - type: 'binary_sensor', - object_id: 'lock_reverse', - discovery_payload: { - payload_on: 'UNLOCK', - payload_off: 'LOCK', - value_template: '{{ value_json.reverse}}', - device_class: 'lock', - }, - }, - 'binary_sensor_power_alarm_active': { - type: 'binary_sensor', - object_id: 'power_alarm_active', - discovery_payload: { - payload_on: true, - payload_off: false, - value_template: '{{ value_json.power_alarm_active}}', - device_class: 'power', - }, - }, // Sensor 'sensor_update_state': { @@ -164,114 +48,6 @@ const cfg = { value_template: `{{ value_json['update']['state'] }}`, }, }, - 'sensor_illuminance': { - type: 'sensor', - object_id: 'illuminance', - discovery_payload: { - unit_of_measurement: '-', - device_class: 'illuminance', - value_template: '{{ value_json.illuminance }}', - }, - }, - 'sensor_illuminance_lux_unit': { - type: 'sensor', - object_id: 'illuminance', - discovery_payload: { - unit_of_measurement: 'lx', - device_class: 'illuminance', - value_template: '{{ value_json.illuminance }}', - }, - }, - 'sensor_illuminance_lux': { - type: 'sensor', - object_id: 'illuminance_lux', - discovery_payload: { - unit_of_measurement: 'lx', - device_class: 'illuminance', - value_template: '{{ value_json.illuminance_lux }}', - }, - }, - 'sensor_humidity': { - type: 'sensor', - object_id: 'humidity', - discovery_payload: { - unit_of_measurement: '%', - device_class: 'humidity', - value_template: '{{ value_json.humidity }}', - }, - }, - 'sensor_eco2': { - type: 'sensor', - object_id: 'eco2', - discovery_payload: { - unit_of_measurement: 'ppm', - icon: 'mdi:air-filter', - value_template: '{{ value_json.eco2 }}', - }, - }, - 'sensor_voc': { - type: 'sensor', - object_id: 'voc', - discovery_payload: { - unit_of_measurement: 'ppb', - icon: 'mdi:air-filter', - value_template: '{{ value_json.voc }}', - }, - }, - 'sensor_pm25': { - type: 'sensor', - object_id: 'pm25', - discovery_payload: { - unit_of_measurement: 'µg/m³', - icon: 'mdi:air-filter', - value_template: '{{ value_json.pm25 }}', - }, - }, - 'sensor_pm10': { - type: 'sensor', - object_id: 'pm10', - discovery_payload: { - unit_of_measurement: 'µg/m³', - icon: 'mdi:air-filter', - value_template: '{{ value_json.pm10}}', - }, - }, - 'sensor_hcho': { - type: 'sensor', - object_id: 'hcho', - discovery_payload: { - unit_of_measurement: 'µg/m³', - icon: 'mdi:air-filter', - value_template: '{{ value_json.hcho }}', - }, - }, - 'sensor_aqi': { - type: 'sensor', - object_id: 'aqi', - discovery_payload: { - // unit_of_measurement: 'ppb', - icon: 'mdi:air-filter', - value_template: '{{ value_json.aqi }}', - }, - }, - 'sensor_temperature': { - type: 'sensor', - object_id: 'temperature', - discovery_payload: { - unit_of_measurement: '°C', - device_class: 'temperature', - value_template: '{{ value_json.temperature }}', - }, - }, - 'sensor_device_temperature': { - type: 'sensor', - object_id: 'device_temperature', - discovery_payload: { - unit_of_measurement: '°C', - device_class: 'temperature', - value_template: '{{ value_json.device_temperature }}', - }, - }, 'sensor_local_temperature': { type: 'sensor', object_id: 'local_temperature', @@ -281,15 +57,6 @@ const cfg = { value_template: '{{ value_json.local_temperature }}', }, }, - 'sensor_pressure': { - type: 'sensor', - object_id: 'pressure', - discovery_payload: { - unit_of_measurement: 'hPa', - device_class: 'pressure', - value_template: '{{ value_json.pressure }}', - }, - }, 'sensor_click': { type: 'sensor', object_id: 'click', @@ -307,24 +74,6 @@ const cfg = { value_template: '{{ value_json.power }}', }, }, - 'sensor_current': { - type: 'sensor', - object_id: 'current', - discovery_payload: { - unit_of_measurement: 'A', - icon: 'mdi:current-ac', - value_template: '{{ value_json.current }}', - }, - }, - 'sensor_voltage': { - type: 'sensor', - object_id: 'voltage', - discovery_payload: { - unit_of_measurement: 'V', - icon: 'mdi:alpha-v', - value_template: '{{ value_json.voltage }}', - }, - }, 'sensor_energy': { type: 'sensor', object_id: 'energy', @@ -334,30 +83,6 @@ const cfg = { value_template: '{{ value_json.energy }}', }, }, - 'sensor_action': { - type: 'sensor', - object_id: 'action', - discovery_payload: { - icon: 'mdi:gesture-double-tap', - value_template: '{{ value_json.action }}', - }, - }, - 'sensor_action_color': { - type: 'sensor', - object_id: 'action_color', - discovery_payload: { - value_template: '{{ value_json.action_color }}', - icon: 'mdi:palette', - }, - }, - 'sensor_action_color_temperature': { - type: 'sensor', - object_id: 'action_color_temperature', - discovery_payload: { - value_template: '{{ value_json.action_color_temperature }}', - icon: 'hass:thermometer', - }, - }, 'sensor_brightness': { type: 'sensor', object_id: 'brightness', @@ -367,14 +92,6 @@ const cfg = { value_template: '{{ value_json.brightness }}', }, }, - 'sensor_lock': { - type: 'sensor', - object_id: 'lock', - discovery_payload: { - icon: 'mdi:lock', - value_template: '{{ value_json.inserted }}', - }, - }, 'sensor_battery': { type: 'sensor', object_id: 'battery', @@ -384,14 +101,6 @@ const cfg = { value_template: '{{ value_json.battery }}', }, }, - 'sensor_battery_state': { - type: 'sensor', - object_id: 'battery_state', - discovery_payload: { - icon: 'mdi:battery-charging', - value_template: '{{ value_json.battery_state }}', - }, - }, 'sensor_linkquality': { type: 'sensor', object_id: 'linkquality', @@ -401,112 +110,8 @@ const cfg = { value_template: '{{ value_json.linkquality }}', }, }, - 'sensor_gas_density': { - type: 'sensor', - object_id: 'gas_density', - discovery_payload: { - value_template: '{{ value_json.gas_density }}', - icon: 'mdi:google-circles-communities', - }, - }, - 'sensor_smoke_density': { - type: 'sensor', - object_id: 'smoke_density', - discovery_payload: { - value_template: '{{ value_json.smoke_density }}', - icon: 'mdi:google-circles-communities', - }, - }, - 'sensor_cover': { - type: 'sensor', - object_id: 'cover', - discovery_payload: { - value_template: '{{ value_json.position }}', - icon: 'mdi:view-array', - }, - }, - 'sensor_consumption': { - type: 'sensor', - object_id: 'consumption', - discovery_payload: { - unit_of_measurement: 'kWh', - value_template: '{{ value_json.consumption }}', - icon: 'mdi:flash', - }, - }, - 'sensor_sensitivity': { - type: 'sensor', - object_id: 'sensitivity', - discovery_payload: { - value_template: '{{ value_json.sensitivity }}', - icon: 'mdi:filter-variant', - }, - }, - 'sensor_strength': { - type: 'sensor', - object_id: 'strength', - discovery_payload: { - value_template: '{{ value_json.strength }}', - icon: 'mdi:weight', - }, - }, - 'sensor_radioactive_events_per_minute': { - type: 'sensor', - object_id: 'radioactive_events_per_minute', - discovery_payload: { - unit_of_measurement: 'rpm', - value_template: '{{ value_json.radioactive_events_per_minute }}', - }, - }, - 'sensor_radiation_dose_per_hour': { - type: 'sensor', - object_id: 'radiation_dose_per_hour', - discovery_payload: { - unit_of_measurement: 'rph', - value_template: '{{ value_json.radiation_dose_per_hour }}', - }, - }, - 'sensor_direction': { - type: 'sensor', - object_id: 'direction', - discovery_payload: { - value_template: '{{ value_json.direction }}', - icon: 'mdi:rotate-3d-variant', - }, - }, - 'sensor_co2': { - type: 'sensor', - object_id: 'co2', - discovery_payload: { - unit_of_measurement: 'ppm', - value_template: '{{ value_json.co2 }}', - icon: 'mdi:molecule-co2', - }, - }, - - // Light - 'light_brightness': { - type: 'light', - object_id: 'light', - discovery_payload: { - brightness: true, - schema: 'json', - command_topic: true, - brightness_scale: 254, - }, - }, // Switch - 'switch': { - type: 'switch', - object_id: 'switch', - discovery_payload: { - payload_off: 'OFF', - payload_on: 'ON', - value_template: '{{ value_json.state }}', - command_topic: true, - }, - }, 'switch_window_detection': { type: 'switch', object_id: 'window_detection', @@ -537,16 +142,6 @@ const cfg = { }, }, - // Cover - 'cover': { - type: 'cover', - object_id: 'cover', - discovery_payload: { - command_topic: true, - optimistic: true, - }, - }, - // Lock 'lock_keypad_lockout': { type: 'lock', @@ -575,22 +170,6 @@ const cfg = { }, }, - // Fan - 'fan': { - type: 'fan', - object_id: 'fan', - discovery_payload: { - state_topic: true, - state_value_template: '{{ value_json.fan_state }}', - command_topic: true, - command_topic_postfix: 'fan_state', - speed_state_topic: true, - speed_command_topic: true, - speed_value_template: '{{ value_json.fan_mode }}', - speeds: ['off', 'low', 'medium', 'high', 'on', 'auto', 'smart'], - }, - }, - // Trigger 'trigger_action': { type: 'device_automation', @@ -608,31 +187,6 @@ const cfg = { }, }; -const switchEndpoint = (endpointName) => { - return { - type: 'switch', - object_id: `switch_${endpointName}`, - discovery_payload: { - payload_off: 'OFF', - payload_on: 'ON', - value_template: `{{ value_json.state_${endpointName} }}`, - command_topic: true, - command_topic_prefix: endpointName, - }, - }; -}; - -const sensorEndpoint = (endpointName) => { - return { - type: 'sensor', - object_id: `sensor_${endpointName}`, - discovery_payload: { - value_template: `{{ value_json.${endpointName} }}`, - }, - }; -}; - - const climate = (minTemp=7, maxTemp=30, temperatureStateProperty='occupied_heating_setpoint', tempStep=1, systemModes=['off', 'auto', 'heat'], fanModes=[], holdModes=[], temperatureLowStateTopic=false, temperatureHighStateTopic=false, endpoint=null ) => { @@ -724,79 +278,14 @@ const climate = (minTemp=7, maxTemp=30, temperatureStateProperty='occupied_heati // Map Home Assistant configurations to devices. const manualMaping = { - 'WXKG01LM': [cfg.sensor_click, cfg.sensor_action, cfg.sensor_battery], - 'WXKG11LM': [cfg.sensor_click, cfg.sensor_action, cfg.sensor_battery], - 'WXKG12LM': [cfg.sensor_click, cfg.sensor_action, cfg.sensor_battery], - 'WXKG03LM': [cfg.sensor_click, cfg.sensor_action, cfg.sensor_battery], - 'WXKG06LM': [cfg.sensor_battery, cfg.sensor_action], - 'WXKG02LM': [cfg.sensor_click, cfg.sensor_action, cfg.sensor_battery], - 'QBKG04LM': [cfg.switch, cfg.sensor_click, cfg.sensor_action], - 'QBKG03LM': [ - switchEndpoint('left'), switchEndpoint('right'), cfg.sensor_click, cfg.sensor_action, cfg.sensor_temperature, - ], - 'MFKZQ01LM': [cfg.sensor_action, cfg.sensor_battery], - 'ICTC-G-1': [cfg.sensor_brightness, cfg.sensor_battery, cfg.sensor_action], - 'QBKG11LM': [cfg.switch, cfg.sensor_power, cfg.sensor_click, cfg.sensor_action, cfg.sensor_temperature], - 'QBKG21LM': [cfg.switch, cfg.sensor_click, cfg.sensor_action], - 'QBKG22LM': [switchEndpoint('left'), switchEndpoint('right'), cfg.sensor_action, cfg.sensor_click], - 'QBKG12LM': [ - switchEndpoint('left'), switchEndpoint('right'), cfg.sensor_power, cfg.sensor_click, - cfg.sensor_temperature, cfg.sensor_action, - ], - 'Z809A': [cfg.switch, cfg.sensor_power], - '324131092621': [cfg.sensor_action, cfg.sensor_battery], - 'STSS-MULT-001': [cfg.binary_sensor_contact, cfg.sensor_battery], - 'A6121': [cfg.sensor_lock], - 'DJT11LM': [cfg.sensor_action, cfg.sensor_battery, cfg.sensor_sensitivity, cfg.sensor_strength], - '4256251-RZHAC': [cfg.switch, cfg.sensor_power], - '4257050-ZHAC': [cfg.light_brightness, cfg.sensor_power, cfg.sensor_current, cfg.sensor_voltage], - 'STS-PRS-251': [cfg.binary_sensor_presence, cfg.sensor_battery], - 'STSS-PRES-001': [cfg.binary_sensor_presence, cfg.sensor_battery], - 'AV2010/25': [cfg.switch, cfg.sensor_power], '1TST-EU': [climate(), cfg.sensor_battery], - 'AIRAM-CTR.U': [], 'AV2010/32': [climate(7, 30, 'occupied_heating_setpoint', 0.5), cfg.sensor_battery], - 'E1524/E1810': [cfg.sensor_action, cfg.sensor_battery], - 'AC0251100NJ/AC0251700NJ': [cfg.sensor_action, cfg.sensor_battery], - 'MLI-404011': [cfg.sensor_action], - 'SP600': [cfg.switch, cfg.sensor_power, cfg.sensor_energy], 'SPZB0001': [climate(5, 30, 'occupied_heating_setpoint', 0.5), cfg.sensor_battery], - '81825': [cfg.sensor_action], - 'E1743': [cfg.sensor_click, cfg.sensor_action, cfg.sensor_battery], 'ST218': [ climate(5, 30, 'occupied_heating_setpoint', 0.5), cfg.sensor_local_temperature, cfg.lock_keypad_lockout, ], - 'ZYCT-202': [cfg.sensor_action], - 'IM6001-BTP01': [cfg.sensor_click, cfg.sensor_action, cfg.sensor_temperature, cfg.sensor_battery], - 'AV2010/34': [cfg.sensor_click, cfg.sensor_action], - 'HGZB-1S': [cfg.switch, cfg.sensor_click, cfg.sensor_action], - 'HGZB-045': [cfg.switch, cfg.sensor_click, cfg.sensor_action], - 'SWO-KEF1PA': [cfg.sensor_action], - 'HGZB-02S': [cfg.sensor_click, cfg.sensor_action, cfg.switch], - 'HS1RC-N': [cfg.sensor_action, cfg.sensor_battery], - 'HS2SS': [cfg.sensor_action, cfg.sensor_battery], - 'N2G-SP': [cfg.sensor_power, cfg.switch, cfg.sensor_energy], - '99432': [cfg.fan, cfg.light_brightness], - 'InstaRemote': [cfg.sensor_action], - 'ZGRC-KEY-013': [cfg.sensor_click, cfg.sensor_action], - 'SZ-ESW01-AU': [cfg.sensor_power, cfg.switch], - 'MEAZON_BIZY_PLUG': [cfg.sensor_power, cfg.switch, cfg.sensor_temperature], - 'MEAZON_DINRAIL': [cfg.sensor_power, cfg.switch, cfg.sensor_temperature], - 'ZNMS12LM': [ - cfg.sensor_action, cfg.binary_sensor_lock, cfg.binary_sensor_lock_reverse, - cfg.sensor_battery, - ], - 'ZNMS13LM': [ - cfg.sensor_action, cfg.binary_sensor_lock, cfg.binary_sensor_lock_reverse, - ], - 'ZNMS11LM': [ - cfg.sensor_action, cfg.binary_sensor_lock, cfg.binary_sensor_lock_reverse, - ], - '12050': [cfg.switch, cfg.sensor_power], - 'LZL4BWHL01': [cfg.sensor_action], - '2AJZ4KPKEY': [cfg.sensor_click, cfg.sensor_action, cfg.sensor_battery], 'TH1123ZB': [ climate(7, 30, 'occupied_heating_setpoint', 0.5), cfg.sensor_local_temperature, cfg.lock_keypad_lockout, cfg.sensor_power, cfg.sensor_energy, @@ -812,49 +301,8 @@ const manualMaping = { 'TH1400ZB': [climate()], 'TH1500ZB': [climate()], 'Zen-01-W': [climate(10, 30, 'occupied_heating_setpoint', 0.5)], - 'ptvo.switch': [ - 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, cfg.sensor_action, - ], - 'DIYRuZ_KEYPAD20': [], - 'DTB190502A1': [], - 'ZWallRemote0': [cfg.sensor_click, cfg.sensor_action], - 'D1': [cfg.light_brightness, cfg.sensor_power], - 'Z3-1BRL': [cfg.sensor_action, cfg.sensor_brightness], - 'ROB_200-008-0': [cfg.sensor_battery, cfg.sensor_click, cfg.sensor_action], - 'SZ-ESW01': [cfg.switch, cfg.sensor_power], - 'ICZB-KPD18S': [cfg.sensor_battery, cfg.sensor_click, cfg.sensor_action], - 'E1766': [cfg.sensor_click, cfg.sensor_battery, cfg.sensor_action], - 'DIYRuZ_magnet': [cfg.binary_sensor_contact, cfg.sensor_battery], - 'E1744': [cfg.sensor_action, cfg.sensor_battery], - 'TERNCY-PP01': [ - cfg.sensor_temperature, cfg.binary_sensor_occupancy, cfg.sensor_illuminance, cfg.sensor_illuminance_lux, - cfg.sensor_click, cfg.sensor_action, - ], - 'CR11S8UZ': [cfg.sensor_action], 'UK7004240': [climate(), cfg.sensor_battery], - 'TS0218': [cfg.sensor_action, cfg.sensor_battery], - 'DIYRuZ_rspm': [cfg.switch, cfg.sensor_action, cfg.sensor_power, cfg.sensor_current], - 'WXCJKG11LM': [cfg.sensor_action, cfg.sensor_battery], - 'WXCJKG12LM': [cfg.sensor_action, cfg.sensor_battery], - 'WXCJKG13LM': [cfg.sensor_action, cfg.sensor_battery], - '8718699693985': [cfg.sensor_action, cfg.sensor_battery], - 'TS0043': [cfg.sensor_action, cfg.sensor_battery], - 'TS0041': [cfg.sensor_action, cfg.sensor_battery], - '6735/6736/6737': [cfg.switch, cfg.sensor_action], - 'SKHMP30-I1': [cfg.switch, cfg.sensor_power], - '6ARCZABZH': [cfg.sensor_battery, cfg.sensor_action], - 'LVS-SC7': [cfg.sensor_action], 'WV704R0A0902': [climate()], - '067773': [cfg.sensor_action, cfg.sensor_battery], - '064873': [cfg.sensor_action], - 'K4003C/L4003C/N4003C/NT4003C': [cfg.switch, cfg.sensor_action], 'STZB402': [ climate(5, 30, 'occupied_heating_setpoint', 0.5), cfg.sensor_local_temperature, @@ -870,25 +318,7 @@ const manualMaping = { cfg.sensor_local_temperature, cfg.lock_keypad_lockout, ], - '067775': [cfg.switch, cfg.sensor_power], - '412015': [cfg.sensor_power, cfg.binary_sensor_power_alarm_active], - 'U86KCJ-ZP': [cfg.sensor_action], - 'HS2IRC': [cfg.sensor_battery], - 'B01M7Y8BP9': [cfg.sensor_action], - 'ZG2835RAC': [cfg.light_brightness, cfg.sensor_power, cfg.sensor_energy], 'SLR1b': [climate()], - 'TS0042': [cfg.sensor_action, cfg.sensor_battery], - 'SNZB-01': [cfg.sensor_action, cfg.sensor_battery], - '07046L': [cfg.sensor_action], - 'TERNCY-SD01': [cfg.sensor_click, cfg.sensor_battery, cfg.sensor_action, cfg.sensor_direction], - 'ICZB-KPD14S': [cfg.sensor_battery, cfg.sensor_click, cfg.sensor_action], - '73743': [cfg.sensor_action, cfg.sensor_battery], - 'C4': [cfg.sensor_action], - '4512703': [cfg.sensor_action, cfg.sensor_battery], - '4512721': [cfg.sensor_action, cfg.sensor_battery], - '4512702': [cfg.sensor_action, cfg.sensor_battery], - 'HS1EB/HS1EB-E': [cfg.sensor_click, cfg.sensor_action, cfg.sensor_battery], - 'ROB_200-007-0': [cfg.sensor_action, cfg.sensor_battery], 'GS361A-H04': [ cfg.lock_child_lock, cfg.switch_window_detection, @@ -896,23 +326,10 @@ const manualMaping = { climate(5, 30, 'current_heating_setpoint', 0.5, ['off', 'auto', 'heat', 'manual']), cfg.sensor_battery, ], - 'S9ZGBRC01': [cfg.sensor_action, cfg.sensor_battery], - '511.557': [cfg.sensor_action], - 'U02I007C.01': [ - cfg.sensor_action, cfg.binary_sensor_contact, cfg.binary_sensor_water_leak, - cfg.sensor_temperature, cfg.sensor_humidity, cfg.sensor_battery, - ], - 'SSS401ZB': [cfg.switch, cfg.sensor_action], - '3460-L': [cfg.sensor_action, cfg.sensor_temperature, cfg.sensor_battery], '3157100': [climate(10, 30, 'occupied_heating_setpoint', 1, ['off', 'heat', 'cool'], ['auto', 'on'], [], true, true), cfg.sensor_battery], - '4512706': [cfg.sensor_battery, cfg.sensor_action], 'RC-2000WH': [climate(10, 30, 'occupied_heating_setpoint', 1, ['off', 'auto', 'heat', 'cool'], ['auto', 'on', 'smart'], [], true, true)], - '511.344': [cfg.sensor_battery, cfg.sensor_action, cfg.sensor_action_color, cfg.sensor_action_color_temperature], - 'AU-A1ZBPIA': [cfg.switch, cfg.sensor_power, cfg.sensor_voltage, cfg.sensor_current], - 'GreenPower_On_Off_Switch': [cfg.sensor_action], - 'GreenPower_7': [cfg.sensor_action], 'TS0601_thermostat': [ cfg.lock_child_lock, cfg.switch_window_detection, cfg.switch_valve_detection, cfg.sensor_battery, climate(5, 30, 'current_heating_setpoint', 0.5, [], [], @@ -933,53 +350,12 @@ const manualMaping = { climate(5, 35, 'current_heating_setpoint', 0.5, ['off', 'heat', 'auto'], [], ['none', 'away']), ], - 'WXKG07LM': [cfg.sensor_action, cfg.sensor_battery], - '752189': [cfg.sensor_action, cfg.sensor_battery], - 'AU-A1ZBRC': [cfg.sensor_action, cfg.sensor_battery], 'ZK03840': [climate()], - 'MCLH-08': [cfg.sensor_temperature, cfg.sensor_humidity, cfg.sensor_eco2, cfg.sensor_voc], - '8840100H': [cfg.binary_sensor_water_leak, cfg.sensor_temperature, cfg.sensor_battery], - 'TERNCY-DC01': [cfg.sensor_temperature, cfg.binary_sensor_contact], - 'DIYRuZ_FreePad': [cfg.sensor_action, cfg.sensor_battery], - 'SE21': [cfg.sensor_action], - '500.67': [cfg.sensor_action], - 'E1E-G7F': [cfg.sensor_action], - 'QBKG25LM': [switchEndpoint('left'), switchEndpoint('center'), switchEndpoint('right'), cfg.sensor_action], - 'QBKG24LM': [switchEndpoint('left'), switchEndpoint('right'), cfg.sensor_power, cfg.sensor_action], - '100.462.31': [cfg.sensor_action], - 'AU-A1ZBPIAB': [cfg.switch, cfg.sensor_voltage, cfg.sensor_current, cfg.sensor_power], - '4058075816459': [cfg.sensor_action, cfg.sensor_battery], - 'SAGE206612': [cfg.sensor_action, cfg.sensor_battery], - 'ZS232000178': [cfg.sensor_action], - 'DIYRuZ_Geiger': [cfg.sensor_radioactive_events_per_minute, cfg.sensor_radiation_dose_per_hour, cfg.sensor_action], - 'DJT12LM': [cfg.sensor_action], - 'KMPCIL_RES005': [ - cfg.sensor_battery, cfg.sensor_temperature, cfg.sensor_humidity, cfg.sensor_pressure, cfg.sensor_illuminance, - cfg.sensor_illuminance_lux, cfg.binary_sensor_occupancy, cfg.switch, - ], - '067774': [cfg.sensor_action, cfg.sensor_battery], - '067694': [cfg.sensor_action, cfg.sensor_battery], - 'SNTZ009': [cfg.binary_sensor_water_leak], - 'NAS-AB02B0': [ - cfg.sensor_temperature, cfg.sensor_humidity, cfg.binary_sensor_humidity_alarm, - cfg.binary_sensor_temperature_alarm, cfg.binary_sensor_alarm, - ], 'U86KWF-ZPSJ': [climate(5, 30, 'current_heating_setpoint', 0.5)], 'D3-DPWK-TY': [climate(5, 30, 'current_heating_setpoint', 0.5)], - 'TS0215A': [cfg.sensor_battery, cfg.sensor_action], - 'TPZRCO2HT-Z3': [cfg.sensor_temperature, cfg.sensor_humidity, cfg.sensor_battery, cfg.sensor_co2], - '3400-D': [cfg.sensor_action, cfg.sensor_battery], - 'ED-10011': [cfg.sensor_action], - 'ED-10012': [cfg.sensor_action], - 'SR-ZG9001T4-DIM-EU': [cfg.sensor_action], 'BHT-002-GCLZB': [ cfg.lock_child_lock, climate(5, 30, 'current_heating_setpoint', 1, ['off', 'heat'], [], ['hold', 'program']), ], - 'QZR-ZIG2400': [], - 'LeTV.8KEY': [cfg.sensor_action], - 'TS0044': [cfg.sensor_action, cfg.sensor_battery], - 'ZG2835': [cfg.sensor_action], - 'CTR.UBX': [cfg.sensor_action], 'SLR2': [ climate(7, 30, 'occupied_heating_setpoint', 1, ['off', 'auto', 'heat'], [], [], false, false, 'heat'), climate(7, 30, 'occupied_heating_setpoint', 1, ['off', 'auto', 'heat'], [], [], false, false, 'cool'), @@ -992,9 +368,6 @@ const manualMaping = { cfg.binary_sensor_battery_low, climate(5, 30, 'current_heating_setpoint', 0.5, ['off', 'heat'], [], ['manual', 'auto']), ], - 'JS-SLK2-ZB': [cfg.sensor_action], - 'TS0216': [cfg.sensor_battery], - 'ICZB-RM11S': [cfg.sensor_battery, cfg.sensor_action], 'HY08WE': [climate(5, 30, 'current_heating_setpoint', 0.5)], }; @@ -1040,6 +413,19 @@ class HomeAssistant extends Extension { assert(!manualMaping.hasOwnProperty(def.model), `'${def.model}' has manual mapping and exposes`); this.mapping[def.model] = []; + if (['WXKG01LM', 'HS1EB/HS1EB-E', 'ICZB-KPD14S', 'TERNCY-SD01', 'TERNCY-PP01', 'ICZB-KPD18S', + 'E1766', 'ZWallRemote0', 'ptvo.switch', '2AJZ4KPKEY', 'ZGRC-KEY-013', 'HGZB-02S', 'HGZB-045', + 'HGZB-1S', 'AV2010/34', 'IM6001-BTP01', 'WXKG11LM', 'WXKG03LM', 'WXKG02LM', 'QBKG04LM', 'QBKG03LM', + 'QBKG11LM', 'QBKG21LM', 'QBKG22LM', 'WXKG12LM', 'QBKG12LM', 'E1743'].includes(def.model)) { + // deprecated + this.mapping[def.model].push(cfg.sensor_click); + } + + if (['ICTC-G-1'].includes(def.model)) { + // deprecated + this.mapping[def.model].push(cfg.sensor_brightness); + } + for (const expose of def.exposes) { let discoveryEntry = null; /* istanbul ignore else */ @@ -1123,6 +509,26 @@ class HomeAssistant extends Extension { tilt_status_template: '{{ value_json.tilt }}', }; } + } else if (expose.type === 'fan') { + assert(!expose.endpoint, `Endpoint not supported for fan type`); + discoveryEntry = { + type: 'fan', + object_id: 'fan', + discovery_payload: { + state_topic: true, + state_value_template: '{{ value_json.fan_state }}', + command_topic: true, + command_topic_postfix: 'fan_state', + }, + }; + + const speed = expose.features.find((e) => e.name === 'mode'); + if (speed) { + discoveryEntry.discovery_payload.speed_state_topic = true; + discoveryEntry.discovery_payload.speed_command_topic = true; + discoveryEntry.discovery_payload.speed_value_template = '{{ value_json.fan_mode }}'; + discoveryEntry.discovery_payload.speeds = speed.values; + } } else if (expose.type === 'binary') { const lookup = { occupancy: {device_class: 'motion'}, @@ -1174,6 +580,8 @@ class HomeAssistant extends Extension { hcho: {icon: 'mdi:air-filter'}, requested_brightness_level: {icon: 'mdi:brightness-5'}, requested_brightness_percent: {icon: 'mdi:brightness-5'}, + eco2: {icon: 'mdi:molecule-co2'}, + co2: {icon: 'mdi:molecule-co2'}, }; assert(!expose.endpoint, `Endpoint not supported for numeric type`); @@ -1187,15 +595,18 @@ class HomeAssistant extends Extension { ...lookup[expose.name], }, }; - } else if (expose.type === 'enum') { + } else if (expose.type === 'enum' || expose.type === 'text') { if (expose.access === 'r' || expose.access === 'rw') { - assert(!expose.endpoint, `Endpoint not supported for enum type`); + const lookup = { + action: {icon: 'mdi:gesture-double-tap'}, + }; discoveryEntry = { type: 'sensor', - object_id: expose.name, + object_id: expose.endpoint ? `sensor_${expose.endpoint}` : expose.name, discovery_payload: { value_template: `{{ value_json.${expose.property} }}`, + ...lookup[expose.name], }, }; } @@ -1306,7 +717,7 @@ class HomeAssistant extends Extension { { property: 'water_leak', condition: data.entity.device && data.entity.definition && this.mapping[data.entity.definition.model] && - this.mapping[data.entity.definition.model].includes(cfg.binary_sensor_water_leak), + this.mapping[data.entity.definition.model].filter((c) => c.object_id === 'water_leak').length === 1, value: false, }, ]; @@ -1379,7 +790,7 @@ class HomeAssistant extends Extension { } if (!settings.get().advanced.homeassistant_legacy_triggers) { - configs = configs.filter((c) => c !== cfg.sensor_action && c !== cfg.sensor_click); + configs = configs.filter((c) => c.object_id !== 'action' && c.object_id !== 'click'); } // deep clone of the config objects diff --git a/npm-shrinkwrap.json b/npm-shrinkwrap.json index d538c2c6b..77fafd936 100644 --- a/npm-shrinkwrap.json +++ b/npm-shrinkwrap.json @@ -14602,9 +14602,9 @@ } }, "zigbee-herdsman-converters": { - "version": "12.0.222", - "resolved": "https://registry.npmjs.org/zigbee-herdsman-converters/-/zigbee-herdsman-converters-12.0.222.tgz", - "integrity": "sha512-hXSXB04vX0onzPWwEbkdpymlE/CKUHkdvm/WRxMswkTEEUDkBn31223UPdV/Q3bsuJYbaZyjFfrl+efkWy64sQ==", + "version": "12.0.223", + "resolved": "https://registry.npmjs.org/zigbee-herdsman-converters/-/zigbee-herdsman-converters-12.0.223.tgz", + "integrity": "sha512-rkdVydLN2vipMfNIHJfH0y14RMKWjc4SXodddXAHWBZSMBajeo3TQUkltPQh6IoyTMQTk+p92TsIc1Oy9wiF0Q==", "requires": { "axios": "^0.21.0", "buffer-crc32": "^0.2.13", diff --git a/package.json b/package.json index e4080f5c7..648e97ab8 100644 --- a/package.json +++ b/package.json @@ -53,7 +53,7 @@ "winston-syslog": "^2.4.4", "ws": "^7.3.1", "zigbee-herdsman": "0.13.24", - "zigbee-herdsman-converters": "12.0.222", + "zigbee-herdsman-converters": "12.0.223", "zigbee2mqtt-frontend": "0.2.63" }, "devDependencies": { diff --git a/test/bridge.test.js b/test/bridge.test.js index d676f1bdc..9d95d952a 100644 --- a/test/bridge.test.js +++ b/test/bridge.test.js @@ -51,7 +51,7 @@ describe('Bridge', () => { it('Should publish devices on startup', async () => { expect(MQTT.publish).toHaveBeenCalledWith( 'zigbee2mqtt/bridge/devices', - stringify([{"date_code":null,"definition":null,"endpoints":{"1":{"bindings":[],"clusters":{"input":[],"output":[]}}},"friendly_name":"Coordinator","ieee_address":"0x00124b00120144ae","interview_completed":false,"interviewing":false,"network_address":0,"power_source":null,"software_build_id":null,"supported":false,"type":"Coordinator"},{"date_code":null,"definition":{"description":"TRADFRI LED bulb E26/E27 980 lumen, dimmable, white spectrum, opal white","exposes":[{"features":[{"access":"rw","name":"state","property":"state","type":"binary","value_off":"OFF","value_on":"ON","value_toggle":"TOGGLE"},{"access":"rw","name":"brightness","property":"brightness","type":"numeric","value_max":254,"value_min":0},{"access":"rw","name":"color_temp","property":"color_temp","type":"numeric","unit":"mired","value_max":500,"value_min":150}],"type":"light"},{"access":"w","name":"effect","property":"effect","type":"enum","values":["blink","breathe","okay","channel_change","finish_effect","stop_effect"]},{"access":"r","name":"linkquality","property":"linkquality","type":"numeric","unit":"lqi"}],"model":"LED1545G12","vendor":"IKEA"},"endpoints":{"1":{"bindings":[],"clusters":{"input":["genBasic","genScenes","genOnOff","genLevelCtrl","lightingColorCtrl"],"output":["genScenes","genOta"]}}},"friendly_name":"bulb","ieee_address":"0x000b57fffec6a5b2","interview_completed":true,"interviewing":false,"network_address":40369,"power_source":"Mains (single phase)","software_build_id":null,"supported":true,"type":"Router"},{"date_code":null,"definition":{"description":"Hue dimmer switch","model":"324131092621","supports":"on/off, brightness, up/down/hold/release, click count","vendor":"Philips"},"endpoints":{"1":{"bindings":[{"cluster":"genLevelCtrl","target":{"endpoint":1,"ieee_address":"0x000b57fffec6a5b3","type":"endpoint"}},{"cluster":"genOnOff","target":{"id":1,"type":"group"}}],"clusters":{"input":["genBasic"],"output":["genBasic","genOnOff","genLevelCtrl","genScenes"]}},"2":{"bindings":[],"clusters":{"input":["genBasic"],"output":["genOta","genOnOff"]}}},"friendly_name":"remote","ieee_address":"0x0017880104e45517","interview_completed":true,"interviewing":false,"network_address":6535,"power_source":"Battery","software_build_id":null,"supported":true,"type":"EndDevice"},{"date_code":null,"definition":null,"endpoints":{"1":{"bindings":[],"clusters":{"input":["genBasic"],"output":["genBasic","genOnOff","genLevelCtrl","genScenes"]}}},"friendly_name":"0x0017880104e45518","ieee_address":"0x0017880104e45518","interview_completed":true,"interviewing":false,"network_address":6536,"power_source":"Battery","software_build_id":null,"supported":false,"type":"EndDevice"},{"date_code":null,"definition":{"description":"Aqara wireless switch","model":"WXKG11LM","supports":"single, double click (and triple, quadruple, hold, release depending on model)","vendor":"Xiaomi"},"endpoints":{"1":{"bindings":[],"clusters":{"input":["genBasic"],"output":["genBasic","genOnOff","genLevelCtrl","genScenes"]}}},"friendly_name":"button","ieee_address":"0x0017880104e45520","interview_completed":true,"interviewing":false,"network_address":6537,"power_source":"Battery","software_build_id":null,"supported":true,"type":"EndDevice"},{"date_code":null,"definition":{"description":"Mi power plug ZigBee","exposes":[{"features":[{"access":"rw","name":"state","property":"state","type":"binary","value_off":"OFF","value_on":"ON","value_toggle":"TOGGLE"}],"type":"switch"},{"access":"r","name":"power","property":"power","type":"numeric","unit":"W"},{"access":"r","name":"energy","property":"energy","type":"numeric","unit":"kWh"},{"access":"r","name":"temperature","property":"temperature","type":"numeric","unit":"°C"},{"access":"r","name":"linkquality","property":"linkquality","type":"numeric","unit":"lqi"}],"model":"ZNCZ02LM","vendor":"Xiaomi"},"endpoints":{"1":{"bindings":[],"clusters":{"input":["genBasic"],"output":[]}}},"friendly_name":"power_plug","ieee_address":"0x0017880104e45524","interview_completed":true,"interviewing":false,"network_address":6540,"power_source":"Mains (single phase)","software_build_id":null,"supported":true,"type":"Router"}]), + stringify([{"date_code":null,"definition":null,"endpoints":{"1":{"bindings":[],"clusters":{"input":[],"output":[]}}},"friendly_name":"Coordinator","ieee_address":"0x00124b00120144ae","interview_completed":false,"interviewing":false,"network_address":0,"power_source":null,"software_build_id":null,"supported":false,"type":"Coordinator"},{"date_code":null,"definition":{"description":"TRADFRI LED bulb E26/E27 980 lumen, dimmable, white spectrum, opal white","exposes":[{"features":[{"access":"rw","name":"state","property":"state","type":"binary","value_off":"OFF","value_on":"ON","value_toggle":"TOGGLE"},{"access":"rw","name":"brightness","property":"brightness","type":"numeric","value_max":254,"value_min":0},{"access":"rw","name":"color_temp","property":"color_temp","type":"numeric","unit":"mired","value_max":500,"value_min":150}],"type":"light"},{"access":"w","name":"effect","property":"effect","type":"enum","values":["blink","breathe","okay","channel_change","finish_effect","stop_effect"]},{"access":"r","name":"linkquality","property":"linkquality","type":"numeric","unit":"lqi"}],"model":"LED1545G12","vendor":"IKEA"},"endpoints":{"1":{"bindings":[],"clusters":{"input":["genBasic","genScenes","genOnOff","genLevelCtrl","lightingColorCtrl"],"output":["genScenes","genOta"]}}},"friendly_name":"bulb","ieee_address":"0x000b57fffec6a5b2","interview_completed":true,"interviewing":false,"network_address":40369,"power_source":"Mains (single phase)","software_build_id":null,"supported":true,"type":"Router"},{"date_code":null,"definition":{"description":"Hue dimmer switch","exposes":[{"access":"r","name":"battery","property":"battery","type":"numeric","unit":"%"},{"access":"r","name":"action","property":"action","type":"enum","values":["on-press","on-hold","on-release","up-press","up-hold","up-release","down-press","down-hold","down-release","off-press","off-hold","off-release"]},{"access":"r","name":"linkquality","property":"linkquality","type":"numeric","unit":"lqi"}],"model":"324131092621","vendor":"Philips"},"endpoints":{"1":{"bindings":[{"cluster":"genLevelCtrl","target":{"endpoint":1,"ieee_address":"0x000b57fffec6a5b3","type":"endpoint"}},{"cluster":"genOnOff","target":{"id":1,"type":"group"}}],"clusters":{"input":["genBasic"],"output":["genBasic","genOnOff","genLevelCtrl","genScenes"]}},"2":{"bindings":[],"clusters":{"input":["genBasic"],"output":["genOta","genOnOff"]}}},"friendly_name":"remote","ieee_address":"0x0017880104e45517","interview_completed":true,"interviewing":false,"network_address":6535,"power_source":"Battery","software_build_id":null,"supported":true,"type":"EndDevice"},{"date_code":null,"definition":null,"endpoints":{"1":{"bindings":[],"clusters":{"input":["genBasic"],"output":["genBasic","genOnOff","genLevelCtrl","genScenes"]}}},"friendly_name":"0x0017880104e45518","ieee_address":"0x0017880104e45518","interview_completed":true,"interviewing":false,"network_address":6536,"power_source":"Battery","software_build_id":null,"supported":false,"type":"EndDevice"},{"date_code":null,"definition":{"description":"Aqara wireless switch","exposes":[{"access":"r","name":"battery","property":"battery","type":"numeric","unit":"%"},{"access":"r","name":"action","property":"action","type":"enum","values":["single","double","tripple","quadruple","hold","release"]},{"access":"r","name":"linkquality","property":"linkquality","type":"numeric","unit":"lqi"}],"model":"WXKG11LM","vendor":"Xiaomi"},"endpoints":{"1":{"bindings":[],"clusters":{"input":["genBasic"],"output":["genBasic","genOnOff","genLevelCtrl","genScenes"]}}},"friendly_name":"button","ieee_address":"0x0017880104e45520","interview_completed":true,"interviewing":false,"network_address":6537,"power_source":"Battery","software_build_id":null,"supported":true,"type":"EndDevice"},{"date_code":null,"definition":{"description":"Mi power plug ZigBee","exposes":[{"features":[{"access":"rw","name":"state","property":"state","type":"binary","value_off":"OFF","value_on":"ON","value_toggle":"TOGGLE"}],"type":"switch"},{"access":"r","name":"power","property":"power","type":"numeric","unit":"W"},{"access":"r","name":"energy","property":"energy","type":"numeric","unit":"kWh"},{"access":"r","name":"temperature","property":"temperature","type":"numeric","unit":"°C"},{"access":"r","name":"linkquality","property":"linkquality","type":"numeric","unit":"lqi"}],"model":"ZNCZ02LM","vendor":"Xiaomi"},"endpoints":{"1":{"bindings":[],"clusters":{"input":["genBasic"],"output":[]}}},"friendly_name":"power_plug","ieee_address":"0x0017880104e45524","interview_completed":true,"interviewing":false,"network_address":6540,"power_source":"Mains (single phase)","software_build_id":null,"supported":true,"type":"Router"}]), { retain: true, qos: 0 }, expect.any(Function) );