From 50226d2c8486eb92fd00c37041ef4d7d3e174ca1 Mon Sep 17 00:00:00 2001 From: Koen Kanters Date: Thu, 1 Oct 2020 18:33:59 +0200 Subject: [PATCH] Exposes for lights. #4466 (#4516) * Add dumpHomeAssistantMapping * Add exposes for lights. https://github.com/Koenkk/zigbee2mqtt/issues/4466 * Updates * Updates --- lib/extension/bridge.js | 33 +- lib/extension/homeassistant.js | 488 +++------------------------- scripts/dumpHomeAssistantMapping.js | 26 ++ test/bridge.test.js | 4 +- test/homeassistant.test.js | 4 +- 5 files changed, 101 insertions(+), 454 deletions(-) create mode 100644 scripts/dumpHomeAssistantMapping.js diff --git a/lib/extension/bridge.js b/lib/extension/bridge.js index 97003239..7eb28c11 100644 --- a/lib/extension/bridge.js +++ b/lib/extension/bridge.js @@ -92,13 +92,9 @@ class Bridge extends Extension { friendly_name: resolvedEntity.settings.friendlyName, status: data.status, ieee_address: ieeeAddress, }; if (data.status === 'successful') { - payload.supported = !!resolvedEntity.definition; - payload.definition = resolvedEntity.definition ? { - model: resolvedEntity.definition.model, - vendor: resolvedEntity.definition.vendor, - description: resolvedEntity.definition.description, - supports: resolvedEntity.definition.supports, - } : null; + const definition = resolvedEntity.definition; + payload.supported = !!definition; + payload.definition = this.getDefinitionPayload(definition); } } else if (type === 'deviceAnnounce') { payload = { @@ -437,13 +433,6 @@ class Bridge extends Extension { const devices = this.zigbee.getDevices().map((device) => { const definition = zigbeeHerdsmanConverters.findByDevice(device); const resolved = this.zigbee.resolveEntity(device); - const definitionPayload = definition ? { - model: definition.model, - vendor: definition.vendor, - description: definition.description, - supports: definition.supports, - } : null; - const endpoints = {}; for (const endpoint of device.endpoints) { const data = { @@ -477,7 +466,7 @@ class Bridge extends Extension { network_address: device.networkAddress, supported: !!definition, friendly_name: resolved.name, - definition: definitionPayload, + definition: this.getDefinitionPayload(definition), power_source: device.powerSource, software_build_id: device.softwareBuildID, date_code: device.dateCode, @@ -507,6 +496,20 @@ class Bridge extends Extension { await this.mqtt.publish('bridge/groups', stringify(groups), {retain: true, qos: 0}); } + + getDefinitionPayload(definition) { + if (definition) { + return { + model: definition.model, + vendor: definition.vendor, + description: definition.description, + [definition.hasOwnProperty('exposes') ? 'exposes' : 'supports']: + definition.hasOwnProperty('exposes') ? definition.exposes : definition.supports, + }; + } else { + return null; + } + } } module.exports = Bridge; diff --git a/lib/extension/homeassistant.js b/lib/extension/homeassistant.js index c10b5f44..19bb62ca 100644 --- a/lib/extension/homeassistant.js +++ b/lib/extension/homeassistant.js @@ -5,6 +5,8 @@ const zigbee2mqttVersion = require('../../package.json').version; const Extension = require('./extension'); const objectAssignDeep = require(`object-assign-deep`); const stringify = require('json-stable-stringify-without-jsonify'); +const zigbeeHerdsmanConverters = require('zigbee-herdsman-converters'); +const assert = require('assert'); const cfg = { // Binary sensor @@ -913,7 +915,7 @@ const climate = (minTemp=7, maxTemp=30, temperatureStateProperty='occupied_heati // Map Home Assistant configurations to devices. -const mapping = { +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], @@ -934,70 +936,13 @@ const mapping = { 'MFKZQ01LM': [cfg.sensor_action, cfg.sensor_battery], 'ZNCZ02LM': [cfg.switch, cfg.sensor_power, cfg.sensor_temperature, cfg.sensor_consumption, cfg.sensor_voltage], 'QBCZ11LM': [cfg.switch, cfg.sensor_power], - 'LED1545G12': [cfg.light_brightness_colortemp], - 'LED1623G12': [cfg.light_brightness], - 'LED1622G12': [cfg.light_brightness], - 'LED1537R6/LED1739R5': [cfg.light_brightness_colortemp], - 'LED1650R5': [cfg.light_brightness], - 'LED1536G5': [cfg.light_brightness_colortemp], - '7299760PH': [cfg.light_brightness_colorxy], - '7146060PH': [cfg.light_brightness_colortemp_colorxy], - '7602031P7': [cfg.light_brightness_colortemp_colorxy], - '046677476816': [cfg.light_brightness], - 'F7C033': [cfg.light_brightness], 'JTYJ-GD-01LM/BW': [cfg.binary_sensor_smoke, cfg.sensor_battery, cfg.sensor_sensitivity, cfg.sensor_smoke_density], 'PLUG EDP RE:DY': [cfg.switch, cfg.sensor_power], 'SWITCH EDP RE:DY': [cfg.switch], 'CC2530.ROUTER': [cfg.binary_sensor_led], - 'AA70155': [cfg.light_brightness_colortemp], - 'A9A19A60WESDZ02': [cfg.light_brightness_colortemp], - 'A9BR3065WESDZ02': [cfg.light_brightness_colortemp], - '4058075816718': [cfg.light_brightness_colortemp_colorxy], - 'AA69697': [cfg.light_brightness_colortemp_colorxy], - 'HALIGHTDIMWWE27': [cfg.light_brightness], - 'HALIGHTDIMWWB22': [cfg.light_brightness], 'AB3257001NJ': [cfg.switch], 'AC10691': [cfg.switch], - '8718696449691': [cfg.light_brightness], - 'RB 185 C': [cfg.light_brightness_colortemp_colorxy], - 'BY 185 C': [cfg.light_brightness_colortemp_colorxy], - '9290012573A': [cfg.light_brightness_colortemp_colorxy], - 'LED1624G9': [cfg.light_brightness_colorxy], - 'LED1837R5': [cfg.light_brightness], - '73742': [cfg.light_brightness_colortemp], - '73740': [cfg.light_brightness_colortemp], - '73739': [cfg.light_brightness_colortemp_colorxy], - '72569': [cfg.light_brightness_colortemp], - '72567': [cfg.light_brightness_colortemp], - '75541': [cfg.light_brightness_colortemp_colorxy], - '22670': [cfg.light_brightness], 'ICTC-G-1': [cfg.sensor_brightness, cfg.sensor_battery, cfg.sensor_action], - 'ICPSHC24-30EU-IL-1': [cfg.light_brightness], - '45852GE': [cfg.light_brightness], - 'E11-G13': [cfg.light_brightness], - 'LED1649C5': [cfg.light_brightness], - 'ICPSHC24-10EU-IL-1': [cfg.light_brightness], - 'LED1546G12': [cfg.light_brightness_colortemp], - 'L1527': [cfg.light_brightness_colortemp], - 'L1529': [cfg.light_brightness_colortemp], - 'L1528': [cfg.light_brightness_colortemp], - 'L1531': [cfg.light_brightness_colortemp], - 'RB 165': [cfg.light_brightness], - 'RB 175 W': [cfg.light_brightness], - 'RS 125': [cfg.light_brightness], - 'RS 225': [cfg.light_brightness], - 'RB 145': [cfg.light_brightness], - 'RB 245': [cfg.light_brightness], - 'PL 110': [cfg.light_brightness], - 'ST 110': [cfg.light_brightness], - 'UC 110': [cfg.light_brightness], - 'DL 110 N': [cfg.light_brightness], - 'DL 110 W': [cfg.light_brightness], - 'SL 110 N': [cfg.light_brightness], - 'SL 110 M': [cfg.light_brightness], - 'SL 110 W': [cfg.light_brightness], - 'AE 260': [cfg.light_brightness], - 'AA68199': [cfg.light_brightness_colortemp], '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], @@ -1005,38 +950,14 @@ const mapping = { switchEndpoint('left'), switchEndpoint('right'), cfg.sensor_power, cfg.sensor_click, cfg.sensor_temperature, cfg.sensor_action, ], - 'K2RGBW01': [cfg.light_brightness_colortemp_colorxy], - '9290011370': [cfg.light_brightness], 'Z809A': [cfg.switch, cfg.sensor_power], - 'NL08-0800': [cfg.light_brightness], - '98425031': [cfg.light_brightness], - '915005106701': [cfg.light_brightness_colortemp_colorxy], - 'Aj_Zigbee_Led_Strip': [cfg.light_brightness_colortemp_colorxy], - 'AB32840': [cfg.light_brightness_colortemp], - '8718696485880': [cfg.light_brightness_colortemp_colorxy], - '8718696598283': [cfg.light_brightness_colortemp], - '8718696695203': [cfg.light_brightness_colortemp], - '73693': [cfg.light_brightness_colortemp_colorxy], '324131092621': [cfg.sensor_action, cfg.sensor_battery], '9290012607': [ cfg.binary_sensor_occupancy, cfg.sensor_temperature, cfg.sensor_illuminance, cfg.sensor_illuminance_lux, cfg.sensor_battery, ], - 'GL-C-008-1ID': [cfg.light_brightness_colortemp_colorxy], - 'GL-C-009': [cfg.light_brightness], 'STSS-MULT-001': [cfg.binary_sensor_contact, cfg.sensor_battery], - 'E11-G23/E11-G33': [cfg.light_brightness], - 'E11-N13/E11-N13A/E11-N14/E11-N14A': [cfg.light_brightness], - 'E1ACA4ABE38A': [cfg.light_brightness], - 'AC03645': [cfg.light_brightness_colortemp_colorhs], - 'AC03641': [cfg.light_brightness], - 'AC03648': [cfg.light_brightness_colortemp], - 'FB56+ZSW05HG1.2': [cfg.switch], '72922-A': [cfg.switch], - 'AC03642': [cfg.light_brightness_colortemp], - 'AC08560': [cfg.light_brightness], - 'AC10786-DIM': [cfg.light_brightness], - 'DNCKATSD001': [cfg.light_brightness], 'DNCKATSW001': [cfg.switch], 'DNCKATSW002': [switchEndpoint('left'), switchEndpoint('right')], 'DNCKATSW003': [switchEndpoint('left'), switchEndpoint('right'), switchEndpoint('center')], @@ -1044,69 +965,29 @@ const mapping = { switchEndpoint('bottom_left'), switchEndpoint('bottom_right'), switchEndpoint('top_left'), switchEndpoint('top_right'), ], - 'BY 165': [cfg.light_brightness], - 'ZLED-2709': [cfg.light_brightness], - '8718696548738': [cfg.light_brightness_colortemp], - '915005587401': [cfg.light_brightness_colortemp], - '3435011P7': [cfg.light_brightness_colortemp], - '4052899926110': [cfg.light_brightness_colortemp_colorxy], - 'Z01-CIA19NAE26': [cfg.light_brightness], - 'E11-N1EA': [cfg.light_brightness_colortemp_colorxy], - 'E11-U2E': [cfg.light_brightness_colortemp_colorxy], - '74283': [cfg.light_brightness], 'JTQJ-BF-01LM/BW': [cfg.binary_sensor_gas, cfg.sensor_gas_density, cfg.sensor_sensitivity], '50043': [cfg.switch], - '50044/50045': [cfg.light_brightness], 'AV2010/22': [cfg.binary_sensor_occupancy, cfg.sensor_battery], '3210-L': [cfg.switch, cfg.sensor_power, cfg.sensor_current, cfg.sensor_voltage], '3320-L': [cfg.binary_sensor_contact, cfg.sensor_temperature, cfg.sensor_battery], '3326-L': [cfg.binary_sensor_occupancy, cfg.sensor_temperature, cfg.sensor_battery], - '7299355PH': [cfg.light_brightness_colorxy], - '45857GE': [cfg.light_brightness], 'A6121': [cfg.sensor_lock], - '433714': [cfg.light_brightness_colortemp], - '3261030P7': [cfg.light_brightness_colortemp], - '3216431P5': [cfg.light_brightness_colortemp], 'DJT11LM': [cfg.sensor_action, cfg.sensor_battery, cfg.sensor_sensitivity, cfg.sensor_strength], 'E1603/E1702': [cfg.switch], - '7199960PH': [cfg.light_brightness_colorxy], - '74696': [cfg.light_brightness], - 'AB35996': [cfg.light_brightness_colortemp_colorxy], - 'AB401130055': [cfg.light_brightness_colortemp], - '74282': [cfg.light_brightness_colortemp], - 'RS 128 T': [cfg.light_brightness_colortemp], - '53170161': [cfg.light_brightness_colortemp], - '4058075036147': [cfg.light_brightness_colortemp_colorxy], 'KS-SM001': [cfg.switch], 'MG-AUWS01': [switchEndpoint('left'), switchEndpoint('right')], - '9290002579A': [cfg.light_brightness_colortemp_colorxy], '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], - '4058075816794': [cfg.light_brightness_colortemp], - '4052899926158': [cfg.light_brightness], - '4058075036185': [cfg.light_brightness_colortemp_colorxy], - '50049': [cfg.light_brightness_colortemp_colorxy], - '500.47': [cfg.light_brightness_colortemp_colorxy], - '915005733701': [cfg.light_brightness_colortemp_colorxy], - 'RB 285 C': [cfg.light_brightness_colortemp_colorxy], - '3216331P5': [cfg.light_brightness_colortemp], - 'AC08562': [cfg.light_brightness], - '900008-WW': [cfg.light_brightness], - 'Mega23M12': [lightEndpoint('light_brightness_colortemp_colorxy', 'rgb'), - lightEndpoint('light_brightness', 'white')], 'PSS-23ZBS': [cfg.switch], 'HS1SA-M': [cfg.binary_sensor_smoke, cfg.binary_sensor_battery_low], - 'Z01-A19NAE26': [cfg.light_brightness_colortemp], - 'Z01-A60EAE27': [cfg.light_brightness_colortemp], 'AC01353010G': [ cfg.binary_sensor_occupancy, cfg.binary_sensor_tamper, cfg.sensor_temperature, cfg.binary_sensor_battery_low, ], 'SP 120': [cfg.switch, cfg.sensor_power, cfg.sensor_energy], 'SP 222': [cfg.switch], - 'RB 248 T': [cfg.light_brightness_colortemp], 'HS3SA': [cfg.binary_sensor_smoke, cfg.binary_sensor_battery_low], 'HS1DS/HS3DS': [cfg.binary_sensor_contact], 'HS3DS': [ @@ -1120,68 +1001,24 @@ const mapping = { 'HS1VS-N': [ cfg.binary_sensor_vibration, cfg.sensor_battery, cfg.binary_sensor_battery_low, cfg.binary_sensor_tamper], - '421786': [cfg.light_brightness], - 'ICZB-IW11D': [cfg.light_brightness], '3321-S': [cfg.binary_sensor_contact, cfg.sensor_temperature, cfg.sensor_battery], 'ZPIR-8000': [cfg.binary_sensor_occupancy, cfg.sensor_battery], 'ZCTS-808': [cfg.binary_sensor_contact, cfg.sensor_battery], - 'ZNLDP12LM': [cfg.light_brightness_colortemp], - 'XDD12LM': [cfg.light_brightness_colortemp], - 'XDD13LM': [cfg.light_brightness_colortemp], - 'D1821': [cfg.light_brightness_colortemp_colorxy], 'ZNCLDJ11LM': [cfg.cover_position, cfg.sensor_cover], 'TS0601_curtain': [cfg.cover_position], - 'LTFY004': [cfg.light_brightness_colorxy], - 'GL-S-007Z': [cfg.light_brightness_colortemp_colorxy], '3325-S': [cfg.sensor_temperature, cfg.binary_sensor_occupancy], - '4713407': [cfg.light_brightness], - '464800': [cfg.light_brightness_colortemp], - '3261331P7': [cfg.light_brightness_colortemp], - '4033930P7': [cfg.light_brightness_colortemp], - '4023330P7': [cfg.light_brightness_colortemp], - 'GL-B-008Z': [cfg.light_brightness_colortemp_colorxy], 'AV2010/25': [cfg.switch, cfg.sensor_power], - 'E12-N14': [cfg.light_brightness], '1TST-EU': [climate(), cfg.sensor_battery], - 'RB 178 T': [cfg.light_brightness_colortemp], '45856GE': [cfg.switch], - 'GL-D-003Z': [cfg.light_brightness_colortemp_colorxy], - 'GL-D-005Z': [cfg.light_brightness_colortemp_colorxy], - 'GD-CZ-006': [cfg.light_brightness], 'AIRAM-CTR.U': [], 'HGZB-20-DE': [cfg.switch], - 'D1531': [cfg.light_brightness], - 'D1532': [cfg.light_brightness], - 'D1533': [cfg.light_brightness], 'AV2010/32': [climate(7, 30, 'occupied_heating_setpoint', 0.5), cfg.sensor_battery], - 'HGZB-07A': [cfg.light_brightness_colortemp_colorxy], 'E1524/E1810': [cfg.sensor_action, cfg.sensor_battery], - 'GL-C-006': [cfg.light_brightness_colortemp], - 'GL-C-007-1ID': [cfg.light_brightness_colortemp_colorxy], - 'GL-C-007-2ID': [lightEndpoint('light_brightness_colortemp_colorxy', 'rgb'), - lightEndpoint('light_brightness', 'white')], - 'GL-C-008-2ID': [lightEndpoint('light_brightness_colorxy', 'rgb'), - lightEndpoint('light_brightness_colortemp', 'cct')], - 'GL-C-007S': [cfg.light_brightness_colorxy], - 'NLG-CCT light': [cfg.light_brightness_colortemp], 'AC0251100NJ/AC0251700NJ': [cfg.sensor_action, cfg.sensor_battery], - '71831': [cfg.light_brightness_colortemp], - '404000/404005/404012': [cfg.light_brightness_colortemp_colorxy], - '44435': [cfg.light_brightness_colortemp_colorxy], - '404006/404008/404004': [cfg.light_brightness_colortemp], 'MLI-404011': [cfg.sensor_action], - 'GL-S-003Z': [cfg.light_brightness_colorxy], - 'GL-S-005Z': [cfg.light_brightness_colortemp_colorxy], 'HS1DS-E': [cfg.binary_sensor_contact], 'SP600': [cfg.switch, cfg.sensor_power, cfg.sensor_energy], '1613V': [cfg.switch, cfg.sensor_power], - 'XVV-Mega23M12': [cfg.light_brightness_colortemp], - 'GL-B-007Z': [cfg.light_brightness_colortemp_colorxy], - '81809/81813': [cfg.light_brightness_colortemp_colorxy], - '4090130P7': [cfg.light_brightness_colortemp_colorxy], - 'NLG-RGBW light': [cfg.light_brightness_colortemp_colorxy], - 'NLG-RGBW light ': [cfg.light_brightness_colortemp_colorxy], - 'NLG-RGB-TW light': [cfg.light_brightness_colortemp_colorxy], 'TI0001': [switchEndpoint('left'), switchEndpoint('right')], 'SPZB0001': [climate(5, 30, 'current_heating_setpoint', 0.5), cfg.sensor_battery], 'HS3CG': [cfg.binary_sensor_gas], @@ -1190,26 +1027,17 @@ const mapping = { 'RADON TriTech ZB': [ cfg.binary_sensor_occupancy, cfg.sensor_temperature, cfg.sensor_battery, cfg.binary_sensor_battery_low, ], - '07005B': [cfg.light_brightness], - '07004D': [cfg.light_brightness_colortemp_colorxy], - '07008L': [cfg.light_brightness_colortemp_colorxy], 'E1746': [], - 'LED1836G9': [cfg.light_brightness], 'YRD426NRSC': [cfg.lock, cfg.sensor_battery], 'BE468': [cfg.lock, cfg.sensor_battery], 'YRD246HA20BP': [cfg.lock, cfg.sensor_battery], 'E1743': [cfg.sensor_click, cfg.sensor_action, cfg.sensor_battery], - 'LED1732G11': [cfg.light_brightness_colortemp], - 'LED1736G9': [cfg.light_brightness_colortemp], - 'RB 265': [cfg.light_brightness], '9290019758': [ cfg.binary_sensor_occupancy, cfg.sensor_temperature, cfg.sensor_illuminance, cfg.sensor_illuminance_lux, cfg.sensor_battery, ], 'HGZB-042': [switchEndpoint('top'), switchEndpoint('bottom')], 'HGZB-42': [switchEndpoint('top'), switchEndpoint('bottom')], - 'GL-FL-004TZ': [cfg.light_brightness_colortemp_colorxy], - 'GL-FL-004TZS': [cfg.light_brightness_colortemp_colorxy], 'IM6001-OTP05': [cfg.switch], 'SV01': [ cfg.cover_position, cfg.sensor_temperature, cfg.sensor_pressure, @@ -1219,8 +1047,6 @@ const mapping = { cfg.cover_position, cfg.sensor_temperature, cfg.sensor_pressure, cfg.sensor_battery, ], - '316GLEDRF': [cfg.light_brightness], - 'LVS-ZB500D': [cfg.light_brightness], 'ST218': [ climate(5, 30, 'occupied_heating_setpoint', 0.5), cfg.sensor_local_temperature, @@ -1232,14 +1058,11 @@ const mapping = { ], 'ZYCT-202': [cfg.sensor_action], 'GR-ZB01-W': [cfg.cover_position], - '4090531P7': [cfg.light_brightness_colortemp_colorxy], 'HGZB-42-UK / HGZB-41 / HGZB-41-UK': [cfg.switch], 'ISW-ZPR1-WP13': [ cfg.binary_sensor_occupancy, cfg.sensor_temperature, cfg.sensor_battery, cfg.binary_sensor_battery_low, ], - '9290018195': [cfg.light_brightness], - 'HGZB-04D / HGZB-4D-UK': [cfg.light_brightness], 'HGZB-043': [switchEndpoint('top'), switchEndpoint('bottom'), switchEndpoint('center')], 'HGZB-44': [ switchEndpoint('top_left'), switchEndpoint('top_right'), switchEndpoint('bottom_left'), @@ -1287,7 +1110,6 @@ const mapping = { 'HGZB-045': [cfg.switch, cfg.sensor_click, cfg.sensor_action], 'HGZB-43': [switchEndpoint('top'), switchEndpoint('bottom'), switchEndpoint('center')], 'HGZB-01A': [cfg.switch], - 'HGZB-02A': [cfg.light_brightness], 'MCT-350 SMA': [cfg.binary_sensor_contact], '3310-S': [cfg.sensor_temperature, cfg.sensor_humidity, cfg.sensor_battery], 'IM6001-WLP01': [ @@ -1309,15 +1131,8 @@ const mapping = { 'SWO-KEF1PA': [cfg.sensor_action], 'HGZB-02S': [cfg.sensor_click, cfg.sensor_action, cfg.switch], 'HGZB-41': [cfg.switch], - 'ZG9101SAC-HP': [cfg.light_brightness], - 'RS 122': [cfg.light_brightness], - 'GL-B-001Z': [cfg.light_brightness_colortemp_colorxy], 'IM6001-MTP01': [cfg.sensor_temperature, cfg.sensor_battery, cfg.binary_sensor_occupancy], 'U86K31ND6': [switchEndpoint('left'), switchEndpoint('right'), switchEndpoint('center')], - 'HLD812-Z-SC': [cfg.light_brightness], - 'HLC610-Z': [cfg.light_brightness], - 'BY 285 C': [cfg.light_brightness_colortemp_colorxy], - 'HS1RC-M': [cfg.sensor_action, cfg.sensor_battery], 'HS1RC-N': [cfg.sensor_action, cfg.sensor_battery], 'SWO-WDS1PA': [cfg.binary_sensor_contact], 'LLKZMK11LM': [ @@ -1329,18 +1144,10 @@ const mapping = { 'HS2SK': [cfg.switch, cfg.sensor_power, cfg.sensor_voltage, cfg.sensor_current], 'HS2SS': [cfg.sensor_action, cfg.sensor_battery], '45853GE': [cfg.switch, cfg.sensor_power], - '50064': [cfg.light_brightness_colortemp], - '9290011998B': [cfg.light_brightness_colortemp], - '9290022167': [cfg.light_brightness_colortemp], - '4096730U7': [cfg.light_brightness_colortemp], - 'RB 278 T': [cfg.light_brightness_colortemp], '3315-G': [ cfg.sensor_temperature, cfg.sensor_battery, cfg.binary_sensor_water_leak, ], 'N2G-SP': [cfg.sensor_power, cfg.switch, cfg.sensor_energy], - 'AC0363900NJ': [cfg.light_brightness_colortemp_colorxy], - 'LXZB-02A': [cfg.light_brightness], - 'GL-S-004Z': [cfg.light_brightness_colortemp], 'SCM-5ZBS': [cfg.cover_position], 'YRD226HA2619': [cfg.sensor_battery, cfg.lock], 'YMF40/YDM4109+': [cfg.lock, cfg.sensor_battery], @@ -1348,38 +1155,25 @@ const mapping = { '3RSS008Z': [cfg.switch, cfg.sensor_battery], '3RSS007Z': [cfg.switch], '99432': [cfg.fan, cfg.light_brightness], - '511.10': [cfg.light_brightness], 'IM6001-MPP01': [ cfg.sensor_temperature, cfg.binary_sensor_contact, cfg.sensor_battery, ], - 'HLC821-Z-SC': [cfg.light_brightness], - 'RS 228 T': [cfg.light_brightness_colortemp], - 'RS 229 T': [cfg.light_brightness_colortemp], '67200BL': [cfg.switch], 'InstaRemote': [cfg.sensor_action], '100.425.90': [cfg.switch], - '74580': [cfg.light_brightness], 'HS1CA-E': [ cfg.binary_sensor_carbon_monoxide, cfg.binary_sensor_battery_low, cfg.sensor_battery, ], 'MCT-340 E': [cfg.binary_sensor_contact, cfg.sensor_temperature, cfg.sensor_battery], 'MCT-340 SMA': [cfg.binary_sensor_contact, cfg.sensor_temperature, cfg.sensor_battery], - 'D1542': [cfg.light_brightness_colortemp], 'ZGRC-KEY-013': [cfg.sensor_click, cfg.sensor_action], 'ZigUP': [cfg.switch], 'YRD256HA20BP': [cfg.sensor_battery, cfg.lock], 'SZ-ESW01-AU': [cfg.sensor_power, cfg.switch], 'PSM-29ZBSR': [cfg.switch, cfg.sensor_power], - 'ZM350STW1TCF': [cfg.light_brightness_colortemp], - 'M350STW1': [cfg.light_brightness], - 'A806S-Q1R': [cfg.light_brightness], - 'XY12S-15': [cfg.light_brightness_colortemp_colorxy], - 'B07KG5KF5R': [cfg.light_brightness_colortemp], 'SCM-S1': [cfg.cover_position], 'HEIMAN-M1': [cfg.binary_sensor_contact], - '3216131P5': [cfg.light_brightness_colortemp], - 'ST8AU-CON': [cfg.light_brightness], 'HS3MS': [cfg.binary_sensor_occupancy], 'DIYRUZ_R4_5': [ switchEndpoint('bottom_left'), switchEndpoint('bottom_right'), switchEndpoint('center'), @@ -1389,20 +1183,8 @@ const mapping = { 'MEAZON_BIZY_PLUG': [cfg.sensor_power, cfg.switch, cfg.sensor_temperature], 'MEAZON_DINRAIL': [cfg.sensor_power, cfg.switch, cfg.sensor_temperature], 'HS1CA-M': [cfg.binary_sensor_carbon_monoxide, cfg.binary_sensor_battery_low], - '7099860PH': [cfg.light_brightness_colorxy], - 'HV-GSCXZB269': [cfg.light_brightness_colortemp], - '3216231P5': [cfg.light_brightness_colortemp], - 'AC03647': [cfg.light_brightness_colortemp_colorhs], '12031': [cfg.cover_position], 'LS12128': [cfg.cover_position], - '421792': [cfg.light_brightness_colortemp_colorxy], - 'HGZB-06A': [cfg.light_brightness_colortemp_colorxy], - 'LED1733G7': [cfg.light_brightness_colortemp], - '9290011370B': [cfg.light_brightness], - 'RB 250 C': [cfg.light_brightness_colortemp_colorxy], - '8718696170625': [cfg.light_brightness], - 'GL-G-001Z': [cfg.light_brightness_colortemp_colorxy], - 'HV-GSCXZB279_HV-GSCXZB229': [cfg.light_brightness_colortemp], 'HS2WD-E': [cfg.sensor_battery], 'ZNMS12LM': [ cfg.sensor_action, cfg.binary_sensor_lock, cfg.binary_sensor_lock_reverse, @@ -1415,10 +1197,7 @@ const mapping = { cfg.sensor_action, cfg.binary_sensor_lock, cfg.binary_sensor_lock_reverse, ], '12050': [cfg.switch, cfg.sensor_power], - 'ROB_200-004-0': [cfg.light_brightness], - '4512700': [cfg.light_brightness], 'RH3040': [cfg.sensor_battery, cfg.binary_sensor_occupancy], - 'DZ4743-00B': [cfg.switch], 'GLSK3ZB-1711': [cfg.switch], 'GLSK3ZB-1712': [switchEndpoint('top'), switchEndpoint('bottom')], 'GLSK3ZB-1713': [switchEndpoint('top'), switchEndpoint('center'), switchEndpoint('bottom')], @@ -1434,15 +1213,12 @@ const mapping = { switchEndpoint('top_left'), switchEndpoint('center_left'), switchEndpoint('bottom_left'), switchEndpoint('top_right'), switchEndpoint('center_right'), switchEndpoint('bottom_right'), ], - '3306431P7': [cfg.light_brightness_colortemp], - 'AC08559': [cfg.light_brightness_colortemp_colorxy], 'LVS-ZB15S': [cfg.switch], 'LZL4BWHL01': [cfg.sensor_action], '2AJZ4KPKEY': [cfg.sensor_click, cfg.sensor_action, cfg.sensor_battery], '2AJZ4KPFT': [cfg.sensor_temperature, cfg.sensor_humidity, cfg.sensor_battery], 'TT001ZAV20': [cfg.sensor_temperature, cfg.sensor_humidity, cfg.sensor_battery], 'TS0002': [switchEndpoint('l1'), switchEndpoint('l2')], - 'LVS-SN10ZW': [cfg.sensor_battery, cfg.binary_sensor_occupancy], 'LVS-ZB15R': [cfg.switch], 'TH1123ZB': [ climate(7, 30, 'occupied_heating_setpoint', 0.5), cfg.sensor_local_temperature, @@ -1459,7 +1235,6 @@ const mapping = { 'TH1400ZB': [climate()], 'TH1500ZB': [climate()], 'Zen-01-W': [climate(10, 30, 'occupied_heating_setpoint', 0.5)], - '9290022166': [cfg.light_brightness_colortemp_colorxy], 'PM-C140-ZB': [cfg.sensor_power, cfg.switch], 'PM-C150-ZB': [cfg.sensor_power, cfg.switch], 'PM-B530-ZB': [cfg.sensor_power, cfg.switch], @@ -1481,101 +1256,58 @@ const mapping = { ], 'DIYRuZ_KEYPAD20': [], 'DTB190502A1': [], - 'FL 130 C': [cfg.light_brightness_colortemp_colorxy], - 'OFL 120 C': [cfg.light_brightness_colortemp_colorxy], - 'OFL 140 C': [cfg.light_brightness_colortemp_colorxy], - 'OSL 130 C': [cfg.light_brightness_colortemp_colorxy], - 'BF 263': [cfg.light_brightness], - 'RF 263': [cfg.light_brightness], 'HS1CG-M': [cfg.binary_sensor_gas], 'HS1CG_M': [cfg.binary_sensor_gas], 'LVS-SN10ZW_SN11': [cfg.sensor_battery, cfg.binary_sensor_occupancy], - 'B00TN589ZG': [cfg.light_brightness], - 'PSB19-SW27': [cfg.light_brightness], 'S1': [cfg.switch, cfg.sensor_power], 'S2': [switchEndpoint('l1'), switchEndpoint('l2'), cfg.sensor_power], 'ZWallRemote0': [cfg.sensor_click, cfg.sensor_action], 'D1': [cfg.light_brightness, cfg.sensor_power], 'J1': [cfg.cover_position_tilt, cfg.sensor_power], - '73741': [cfg.light_brightness_colortemp_colorxy], - 'ZA806SQ1TCF': [cfg.light_brightness_colortemp], - 'RF 265': [cfg.light_brightness], 'ZNCZ03LM': [cfg.switch, cfg.sensor_power], - '17436/30/P7': [cfg.light_brightness], - '17435/30/P7': [cfg.light_brightness_colorxy], - '9290018187B': [cfg.light_brightness_colortemp_colorxy], - '1746330P7': [cfg.light_brightness_colortemp_colorxy], - '1741830P7': [cfg.light_brightness_colortemp_colorxy], 'Z3-1BRL': [cfg.sensor_action, cfg.sensor_brightness], 'HS1CG-E': [cfg.binary_sensor_gas], - 'LED1842G3': [cfg.light_brightness], 'ROB_200-008-0': [cfg.sensor_battery, cfg.sensor_click, cfg.sensor_action], 'ICZB-IW11SW': [cfg.switch], - 'HV-GUCXZB5': [cfg.light_brightness_colortemp], 'HGZB-20A': [cfg.switch], 'SZ-ESW01': [cfg.switch, cfg.sensor_power], - 'LXZB-12A': [cfg.light_brightness_colortemp_colorxy], '2AJZ4KPBS': [cfg.sensor_battery, cfg.binary_sensor_occupancy, cfg.binary_sensor_battery_low], '2AJZ4KPDR': [cfg.sensor_battery, cfg.binary_sensor_contact, cfg.binary_sensor_battery_low], '6717-84': [cfg.switch], 'ICZB-KPD18S': [cfg.sensor_battery, cfg.sensor_click, cfg.sensor_action], - 'NLG-TW light': [cfg.light_brightness_colortemp], 'E1757': [cfg.cover_position, cfg.sensor_battery], 'E1926': [cfg.cover_position, cfg.sensor_battery], - 'LWG004': [cfg.light_brightness], - '54668161': [cfg.light_brightness_colortemp], - '8718699688820': [cfg.light_brightness], 'GL-W-001Z': [cfg.switch], 'E1766': [cfg.sensor_click, cfg.sensor_battery, cfg.sensor_action], - '929001953101': [cfg.light_brightness_colortemp_colorxy], - '8718699673147': [cfg.light_brightness], '3300-P': [cfg.sensor_temperature, cfg.binary_sensor_contact, cfg.sensor_battery], - 'GL-B-008ZS': [cfg.light_brightness_colortemp_colorxy], - 'T1828': [cfg.light_brightness_colortemp], - 'T1829': [cfg.light_brightness_colortemp], '929002240401': [cfg.switch], 'HGZB-20-UK': [cfg.switch], 'PTAPT-WH02': [cfg.switch], - '929001953301': [cfg.light_brightness_colortemp], 'DIYRuZ_magnet': [cfg.binary_sensor_contact, cfg.sensor_battery], - 'ZLED-TUNE9': [cfg.light_brightness_colortemp], 'XHS2-SE': [cfg.binary_sensor_contact, cfg.sensor_temperature, cfg.sensor_battery], '4000116784070': [cfg.switch], - '9290020399': [cfg.light_brightness], - '929002241201': [cfg.light_brightness], 'YRD210-HA-605': [cfg.lock, cfg.sensor_battery], 'YRD220/YRD221': [cfg.lock, cfg.sensor_battery], 'ZM-CSW032-D': [cfg.cover_position], 'LH-32ZB': [cfg.sensor_humidity, cfg.sensor_temperature, cfg.sensor_battery], - '511.201': [cfg.light_brightness], 'ZNCLDJ12LM': [cfg.cover_position, cfg.sensor_battery], '046677552343': [cfg.switch], - '3115331PH': [cfg.light_brightness_colortemp_colorxy], 'ZWLD-100': [cfg.binary_sensor_water_leak, cfg.binary_sensor_battery_low, cfg.sensor_battery], - 'GL-MC-001': [cfg.light_brightness_colortemp_colorxy], 'YRD226/246 TSDB': [cfg.lock, cfg.sensor_battery], - 'T1820': [cfg.light_brightness_colortemp], 'BASICZBR3': [cfg.switch], 'E1744': [cfg.sensor_action, cfg.sensor_battery], 'TS0201': [cfg.sensor_temperature, cfg.sensor_humidity, cfg.sensor_battery], 'LH07321': [cfg.binary_sensor_water_leak, cfg.binary_sensor_battery_low], - 'GL-C-008S': [cfg.light_brightness_colortemp_colorxy], - 'BY 178 T': [cfg.light_brightness_colortemp], - '8718699688882': [cfg.light_brightness], - 'LED1738G7': [cfg.light_brightness_colortemp], - '9290022169': [cfg.light_brightness_colortemp], '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], - 'RB 148 T': [cfg.light_brightness_colortemp], 'STS-OUT-US-2': [cfg.switch, cfg.sensor_power], 'UK7004240': [climate(), cfg.sensor_battery], 'S31ZB': [cfg.switch], 'SA-003-Zigbee': [cfg.switch], 'SZ-DWS04': [cfg.binary_sensor_contact, cfg.sensor_temperature, cfg.sensor_battery], - 'ICZB-B1FC60/B3FC64/B2FC95/B2FC125': [cfg.light_brightness_colortemp], 'TS0203': [cfg.sensor_battery, cfg.binary_sensor_contact], 'TS0204': [cfg.binary_sensor_gas], 'TS0205': [cfg.binary_sensor_smoke, cfg.sensor_battery], @@ -1583,13 +1315,10 @@ const mapping = { 'TS0001': [cfg.switch], 'TS0207': [cfg.binary_sensor_water_leak, cfg.sensor_battery], 'iL07_1': [cfg.binary_sensor_occupancy, cfg.binary_sensor_tamper, cfg.binary_sensor_battery_low], - 'S31 Lite zb': [cfg.switch], 'LH-992ZB': [cfg.binary_sensor_occupancy, cfg.binary_sensor_battery_low], - '548727': [cfg.light_brightness_colortemp_colorxy], 'TS0202': [cfg.binary_sensor_occupancy, cfg.sensor_battery], 'TS0218': [cfg.sensor_action, cfg.sensor_battery], '404021': [cfg.switch], - 'Eco-Dim.07': [cfg.light_brightness], 'DIYRuZ_rspm': [cfg.switch, cfg.sensor_action, cfg.sensor_power, cfg.sensor_current], 'ZG9101SAC-HP-Switch': [cfg.switch], 'ZNCZ04LM': [ @@ -1597,59 +1326,40 @@ const mapping = { cfg.sensor_current, cfg.sensor_voltage, cfg.sensor_temperature, ], 'ZNCZ12LM': [cfg.switch, cfg.sensor_power], - 'GL-S-007ZS': [cfg.light_brightness_colortemp_colorxy], - '4058075816732': [cfg.light_brightness_colortemp_colorxy], - 'GL-B-007ZS': [cfg.light_brightness_colortemp_colorxy], - 'GL-G-007Z': [cfg.light_brightness_colortemp_colorxy], '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], - 'GL-D-004ZS': [cfg.light_brightness_colortemp_colorxy], - 'GL-D-005ZS': [cfg.light_brightness_colortemp_colorxy], - 'AC10787': [cfg.light_brightness_colortemp], 'F-APP-UK-V2': [cfg.switch, cfg.sensor_power], 'TS0043': [cfg.sensor_action, cfg.sensor_battery], 'TS0041': [cfg.sensor_action, cfg.sensor_battery], 'SP-EUC01': [cfg.switch, cfg.sensor_power], - '511.012': [cfg.light_brightness], - 'GL-S-008Z': [cfg.light_brightness_colortemp_colorxy], 'TZSW22FW-L4': [switchEndpoint('top'), switchEndpoint('bottom')], 'TS0011': [cfg.switch], 'TS0012': [switchEndpoint('left'), switchEndpoint('right')], 'TS0013': [switchEndpoint('left'), switchEndpoint('center'), switchEndpoint('right')], '6735/6736/6737': [cfg.switch, cfg.sensor_action], - '4034031P7': [cfg.light_brightness_colortemp], - '5900131C5': [cfg.light_brightness_colortemp], 'SZ-SRN12N': [], - 'ML-ST-D200': [cfg.light_brightness], - '7099930PH': [cfg.light_brightness_colorxy], '9GED18000-009': [cfg.lock, cfg.sensor_battery], '9GED21500-005': [cfg.lock, cfg.sensor_battery], 'MP-841': [cfg.binary_sensor_occupancy, cfg.binary_sensor_battery_low], 'MCT-370 SMA': [cfg.binary_sensor_contact, cfg.binary_sensor_battery_low], - 'RB 162': [cfg.light_brightness], 'SOHM-I1': [cfg.binary_sensor_contact, cfg.binary_sensor_battery_low], 'SWHM-I1': [cfg.binary_sensor_water_leak, cfg.binary_sensor_battery_low], 'SMHM-I1': [cfg.binary_sensor_occupancy, cfg.binary_sensor_battery_low], 'SKHMP30-I1': [cfg.switch, cfg.sensor_power], - '404028': [cfg.light_brightness_colortemp_colorxy], - '595UGR22': [cfg.light_brightness_colortemp], '6ARCZABZH': [cfg.sensor_battery, cfg.sensor_action], 'ZK-EU-2U': [cfg.switch], '511.202': [cfg.switch], 'SP 224': [cfg.switch], - '9290022411': [cfg.light_brightness], 'E1C-NB6': [cfg.switch], 'LVS-SC7': [cfg.sensor_action], - '1742930P7': [cfg.light_brightness_colortemp_colorxy], 'ZM-L03E-Z': [switchEndpoint('left'), switchEndpoint('center'), switchEndpoint('right')], 'DL15S-1BZ': [cfg.switch], 'E1D-G73WNA': [cfg.binary_sensor_contact, cfg.binary_sensor_battery_low], 'WV704R0A0902': [climate()], '067776': [cfg.cover_position], '067773': [cfg.sensor_action, cfg.sensor_battery], - '067771': [cfg.light_brightness], '064873': [cfg.sensor_action], 'K4003C/L4003C/N4003C/NT4003C': [cfg.switch, cfg.sensor_action], 'STZB402': [ @@ -1667,22 +1377,11 @@ const mapping = { cfg.sensor_local_temperature, cfg.lock_keypad_lockout, ], - '046677551780': [cfg.light_brightness], - '798.15': [cfg.light_brightness], '12126': [cfg.switch], '067775': [cfg.switch, cfg.sensor_power], '064888': [cfg.switch], '412015': [cfg.sensor_power, cfg.binary_sensor_power_alarm_active], - 'gq8b1uv': [cfg.light_brightness], 'GZCGQ01LM': [cfg.sensor_battery, cfg.sensor_illuminance, cfg.sensor_illuminance_lux], - '9290018215': [cfg.light_brightness], - '1743230P7': [cfg.light_brightness_colortemp_colorxy], - '1744130P7': [cfg.light_brightness_colortemp_colorxy], - '1743130P7': [cfg.light_brightness_colortemp_colorxy], - '100.110.51': [cfg.light_brightness_colortemp], - 'ZL1000100-CCT-US-V1A02': [cfg.light_brightness_colortemp], - 'ZL1000701-27-EU-V1A02': [cfg.light_brightness], - 'HGZB-DLC4-N12B': [cfg.light_brightness_colortemp_colorxy], 'U86KCJ-ZP': [cfg.sensor_action], 'HS1HT': [cfg.sensor_temperature, cfg.sensor_humidity, cfg.sensor_battery], 'HS1HT-N': [cfg.sensor_temperature, cfg.sensor_humidity, cfg.sensor_battery], @@ -1707,27 +1406,12 @@ const mapping = { 'BW-IS3': [cfg.binary_sensor_occupancy], 'SLR1b': [climate()], 'WPT1': [], - '4058075047853': [cfg.light_brightness_colortemp_colorxy], 'ROB_200-003-0': [cfg.switch], '4512704': [cfg.switch], 'AV2010/24A': [cfg.binary_sensor_smoke, cfg.binary_sensor_battery_low, cfg.binary_sensor_tamper], '902010/24': [cfg.binary_sensor_smoke, cfg.binary_sensor_battery_low, cfg.binary_sensor_tamper], - 'ROB_200-014-0': [cfg.light_brightness], - '4090631P7': [cfg.light_brightness_colortemp_colorxy], 'SGMHM-I1': [cfg.binary_sensor_gas, cfg.binary_sensor_battery_low, cfg.binary_sensor_tamper], 'STHM-I1H': [cfg.sensor_humidity, cfg.sensor_temperature, cfg.sensor_battery], - 'BDHM8E27W70-I1': [cfg.light_brightness_colortemp], - 'M420': [cfg.sensor_battery], - '8718696167991': [cfg.light_brightness_colortemp_colorxy], - 'GP-LBU019BBAWU': [cfg.light_brightness], - '371000001': [cfg.light_brightness_colortemp], - '10011725': [cfg.light_brightness_colortemp_colorxy], - '929002277501': [cfg.light_brightness], - 'RS 230 C': [cfg.light_brightness_colortemp_colorxy], - 'LED1903C5/LED1835C6': [cfg.light_brightness_colortemp], - '1402755': [cfg.light_brightness], - '4503848C5': [cfg.light_brightness_colortemp], - '500.48': [cfg.light_brightness], 'TS0042': [cfg.sensor_action, cfg.sensor_battery], 'SNZB-04': [cfg.binary_sensor_contact, cfg.sensor_battery], 'SNZB-01': [cfg.sensor_action, cfg.sensor_battery], @@ -1735,24 +1419,19 @@ const mapping = { 'SNZB-03': [cfg.binary_sensor_occupancy, cfg.sensor_battery], '07046L': [cfg.sensor_action], '07045L': [cfg.binary_sensor_contact, cfg.binary_sensor_tamper, cfg.binary_sensor_battery_low], - '3402831P7': [cfg.light_brightness_colortemp], 'TERNCY-SD01': [cfg.sensor_click, cfg.sensor_battery, cfg.sensor_action, cfg.sensor_direction], '07048L': [cfg.switch, cfg.sensor_power], 'ICZB-KPD14S': [cfg.sensor_battery, cfg.sensor_click, cfg.sensor_action], '73743': [cfg.sensor_action, cfg.sensor_battery], 'C4': [cfg.sensor_action], - 'GL-D-003ZS': [cfg.light_brightness_colortemp_colorxy], '66492-001': [cfg.lock, cfg.sensor_battery], - '371000002': [cfg.light_brightness_colortemp_colorxy], 'U202DST600ZB': [lightEndpoint('light_brightness', 'l1'), lightEndpoint('light_brightness', 'l2')], 'SM10ZW': [cfg.binary_sensor_contact, cfg.sensor_battery], - 'ICZB-R11D': [cfg.light_brightness], 'SW2500ZB': [cfg.switch], 'SP2600ZB': [cfg.switch], '4512703': [cfg.sensor_action, cfg.sensor_battery], '4512721': [cfg.sensor_action, cfg.sensor_battery], '4512702': [cfg.sensor_action, cfg.sensor_battery], - '4090331P9': [cfg.light_brightness_colortemp_colorxy], 'HS1EB/HS1EB-E': [cfg.sensor_click, cfg.sensor_action, cfg.sensor_battery], 'HS2SW1A/HS2SW1A-N': [cfg.switch, cfg.sensor_device_temperature], 'HS2SW2A/HS2SW2A-N': [switchEndpoint('left'), switchEndpoint('right'), cfg.sensor_device_temperature], @@ -1762,9 +1441,7 @@ const mapping = { ], 'MCLH-07': [cfg.binary_sensor_water_leak, cfg.sensor_battery], 'MCLH-04': [cfg.binary_sensor_contact, cfg.sensor_battery], - 'MCLH-02': [cfg.light_brightness_colortemp_colorxy], '3323-G': [cfg.binary_sensor_contact, cfg.sensor_temperature, cfg.binary_sensor_battery_low], - 'ZL1000400-CCT-EU-2-V1A02': [cfg.light_brightness_colortemp], 'ROB_200-007-0': [cfg.sensor_action, cfg.sensor_battery], 'PM-S140-ZB': [cfg.switch], 'PM-S240-ZB': [switchEndpoint('top'), switchEndpoint('bottom')], @@ -1775,10 +1452,8 @@ const mapping = { 'PM-S150-ZB': [cfg.switch], 'PM-S250-ZB': [switchEndpoint('top'), switchEndpoint('bottom')], 'PM-S350-ZB': [switchEndpoint('top'), switchEndpoint('center'), switchEndpoint('bottom')], - 'U201DST600ZB': [cfg.light_brightness], 'U201SRY2KWZB': [cfg.switch], 'U202SRY2KWZB': [switchEndpoint('l1'), switchEndpoint('l2')], - '93999': [cfg.light_brightness], 'ZHS-15': [cfg.switch, cfg.sensor_power, cfg.sensor_current, cfg.sensor_voltage], 'GS361A-H04': [ cfg.lock_child_lock, @@ -1794,17 +1469,10 @@ const mapping = { ], 'S9ZGBRC01': [cfg.sensor_action, cfg.sensor_battery], '511.557': [cfg.sensor_action], - 'RL804CZB': [cfg.light_brightness_colortemp_colorxy], - '3420-G': [cfg.light_brightness], 'U02I007C.01': [ cfg.sensor_action, cfg.binary_sensor_contact, cfg.binary_sensor_water_leak, cfg.sensor_temperature, cfg.sensor_humidity, cfg.sensor_battery, ], - '4080248P9': [cfg.light_brightness_colortemp_colorxy], - '4080148P9': [cfg.light_brightness_colortemp_colorxy], - '4058075148338': [cfg.light_brightness_colortemp], - '4058075181472': [cfg.light_brightness_colortemp], - '484719': [cfg.light_brightness], 'SEB01ZB': [cfg.binary_sensor_sos, cfg.sensor_battery], 'SBM01ZB': [cfg.binary_sensor_occupancy, cfg.sensor_battery], 'STH01ZB': [cfg.sensor_temperature, cfg.sensor_humidity, cfg.sensor_battery], @@ -1817,7 +1485,6 @@ const mapping = { 'SLS301ZB_2': [switchEndpoint('left'), switchEndpoint('right')], 'SLS301ZB_3': [switchEndpoint('left'), switchEndpoint('right'), switchEndpoint('center')], 'SSS401ZB': [cfg.switch, cfg.sensor_action], - 'E12-N1E': [cfg.light_brightness_colortemp_colorxy], '4040B': [cfg.sensor_power, switchEndpoint('l1'), switchEndpoint('l2')], '3460-L': [cfg.sensor_action, cfg.sensor_temperature, cfg.sensor_battery], '3157100': [climate(10, 30, 'occupied_heating_setpoint', 1, ['off', 'heat', 'cool'], @@ -1827,33 +1494,16 @@ const mapping = { '27087-03': [cfg.switch, cfg.sensor_battery], '99140-002': [cfg.lock, cfg.sensor_battery], '4512706': [cfg.sensor_battery, cfg.sensor_action], - 'GL-S-004ZS': [cfg.light_brightness_colortemp_colorxy], - '7121131PU': [cfg.light_brightness_colortemp_colorxy], - '5041131P9': [cfg.light_brightness_colortemp], 'RL804QZB': [switchEndpoint('l1'), switchEndpoint('l2'), switchEndpoint('l3')], 'RC-2000WH': [climate(10, 30, 'occupied_heating_setpoint', 1, ['off', 'auto', 'heat', 'cool'], ['auto', 'on', 'smart'], [], true, true)], 'SP 220': [cfg.switch], - '511.040': [cfg.light_brightness_colortemp_colorxy], '511.344': [cfg.sensor_battery, cfg.sensor_action, cfg.sensor_action_color, cfg.sensor_action_color_temperature], 'SMSZB-120': [cfg.binary_sensor_smoke, cfg.sensor_temperature, cfg.sensor_battery], 'DWS003': [cfg.binary_sensor_contact, cfg.sensor_battery, cfg.binary_sensor_battery_low, cfg.sensor_temperature], 'MOT003': [cfg.binary_sensor_occupancy, cfg.sensor_temperature, cfg.sensor_battery, cfg.binary_sensor_battery_low], - 'HALIGHTDIMWWE14': [cfg.light_brightness], 'GreenPower_On_Off_Switch': [cfg.sensor_action], 'GreenPower_7': [cfg.sensor_action], - '3RSL011Z': [cfg.light_brightness_colortemp], - '3RSL012Z': [cfg.light_brightness_colortemp], - '1746130P7': [cfg.light_brightness_colortemp_colorxy], - '1745630P7': [cfg.light_brightness_colortemp_colorxy], - '6xy-M350ST-W1Z': [cfg.light_brightness_colortemp], - 'AU-A1GUZBCX5': [cfg.light_brightness_colortemp], - 'AU-A1GUZB5/30': [cfg.light_brightness], - 'AU-A1GUZBRGBW': [cfg.light_brightness_colortemp_colorxy], - 'AU-A1GSZ9RGBW': [cfg.light_brightness_colortemp_colorxy], - 'AU-A1ZB2WDM': [cfg.light_brightness], - 'RF 261': [cfg.light_brightness], - 'RF 264': [cfg.light_brightness], '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, [], [], @@ -1872,15 +1522,9 @@ const mapping = { 'WXKG07LM': [cfg.sensor_action, cfg.sensor_battery], 'MCLH-03': [cfg.switch, cfg.sensor_voltage, cfg.sensor_power, cfg.sensor_current], '752189': [cfg.sensor_action, cfg.sensor_battery], - '676-00301024955Z': [cfg.light_brightness], - '151570': [cfg.light_brightness], - '1743030P7': [cfg.light_brightness_colortemp_colorxy], 'XBee': [], 'ZBHT-1': [cfg.sensor_temperature, cfg.sensor_humidity, cfg.sensor_battery], - 'rgbw2.zbee27': [cfg.light_brightness_colortemp_colorxy], 'MCLH-05': [cfg.binary_sensor_occupancy, cfg.sensor_battery], - '5045148P7': [cfg.light_brightness_colortemp_colorxy], - 'GL-FL-006TZ': [cfg.light_brightness_colortemp_colorxy], '5AA-SS-ZA-H0': [cfg.binary_sensor_occupancy, cfg.sensor_illuminance, cfg.sensor_illuminance_lux], 'MOSZB-130': [cfg.binary_sensor_occupancy, cfg.binary_sensor_battery_low], 'AU-A1ZBRC': [cfg.sensor_action, cfg.sensor_battery], @@ -1889,22 +1533,15 @@ const mapping = { 'ZK03840': [climate()], 'ZS1100400-IN-V1A02': [cfg.binary_sensor_occupancy, cfg.binary_sensor_battery_low], 'MCLH-08': [cfg.sensor_temperature, cfg.sensor_humidity, cfg.sensor_eco2, cfg.sensor_voc], - 'GL-FL-005TZ': [cfg.light_brightness_colortemp_colorxy], 'ED2004-012': [cfg.switch], - 'ZG192910-4': [cfg.light_brightness_colortemp], 'SLT2': [], - 'ZL1000700-22-EU-V1A02': [cfg.light_brightness], 'SLB2': [], '8840100H': [cfg.binary_sensor_water_leak, cfg.sensor_temperature, cfg.sensor_battery], - '404037': [cfg.light_brightness_colortemp], '9290022408': [cfg.switch], 'HGZB-14A': [cfg.binary_sensor_water_leak, cfg.sensor_battery], 'TERNCY-DC01': [cfg.sensor_temperature, cfg.binary_sensor_contact], 'ZS110050078': [cfg.binary_sensor_contact, cfg.binary_sensor_battery_low], - 'HGZB-DLC4-N15B': [cfg.light_brightness_colortemp_colorxy], 'ECW-100-A03': [switchEndpoint('top'), switchEndpoint('center'), switchEndpoint('bottom')], - '4098430P7': [cfg.light_brightness_colortemp], - 'PQC19-DY01': [cfg.light_brightness], 'DIYRuZ_FreePad': [cfg.sensor_action, cfg.sensor_battery], 'ST20': [cfg.sensor_temperature, cfg.sensor_humidity, cfg.sensor_battery], 'ST21': [cfg.sensor_temperature, cfg.sensor_humidity, cfg.sensor_battery], @@ -1916,8 +1553,6 @@ const mapping = { 'R20W2Z': [switchEndpoint('l1'), switchEndpoint('l2')], 'SW21': [cfg.binary_sensor_water_leak, cfg.binary_sensor_battery_low], 'SE21': [cfg.sensor_action], - '4052899926127': [cfg.light_brightness], - 'GL-B-001ZS': [cfg.light_brightness_colortemp_colorxy], 'LH-990ZB': [cfg.binary_sensor_occupancy, cfg.binary_sensor_battery_low], 'HO-09ZB': [cfg.binary_sensor_contact, cfg.binary_sensor_battery_low], '500.67': [cfg.sensor_action], @@ -1936,17 +1571,14 @@ const mapping = { 'AU-A1ZBDWS': [cfg.binary_sensor_contact, cfg.sensor_battery], '4058075816459': [cfg.sensor_action, cfg.sensor_battery], '14592.0': [cfg.switch], - '73699': [cfg.light_brightness_colorxy], 'SAGE206612': [cfg.sensor_action, cfg.sensor_battery], 'TI0001-switch': [cfg.switch], 'TI0001-socket': [cfg.switch], - '9290022891': [cfg.light_brightness_colortemp_colorxy], '160-01': [cfg.switch, cfg.sensor_power], 'ZS232000178': [cfg.sensor_action], 'ZS190000118 ': [cfg.switch], 'mcdj3aq': [cfg.cover_position], 'DIYRuZ_Geiger': [cfg.sensor_radioactive_events_per_minute, cfg.sensor_radiation_dose_per_hour, cfg.sensor_action], - '8718696170557': [cfg.light_brightness_colortemp_colorxy], '12127': [switchEndpoint('l1'), switchEndpoint('l2')], 'SWO-MOS1PA': [cfg.binary_sensor_occupancy, cfg.binary_sensor_battery_low], 'STS-IRM-251': [cfg.sensor_temperature, cfg.binary_sensor_occupancy, cfg.sensor_battery], @@ -1954,16 +1586,7 @@ const mapping = { 'SJCGQ12LM': [cfg.sensor_battery, cfg.binary_sensor_water_leak], 'DJT12LM': [cfg.sensor_action], 'AV2010/22A': [cfg.binary_sensor_occupancy, cfg.binary_sensor_battery_low], - 'D1523': [cfg.light_brightness], 'RS-23ZBS': [cfg.sensor_temperature, cfg.sensor_humidity], - 'E11-U3E': [cfg.light_brightness_colortemp_colorxy], - '5062231P7': [cfg.light_brightness_colortemp_colorxy], - '5062431P7': [cfg.light_brightness_colortemp_colorxy], - '5062131P7': [cfg.light_brightness_colortemp_colorxy], - '5062331P7': [cfg.light_brightness_colortemp_colorxy], - 'GL-D-004Z': [cfg.light_brightness_colortemp_colorxy], - '9290022268': [cfg.light_brightness], - '73773': [cfg.light_brightness_colortemp_colorxy], '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, @@ -1972,78 +1595,45 @@ const mapping = { switchEndpoint('l1'), switchEndpoint('l2'), switchEndpoint('l3'), switchEndpoint('l4'), switchEndpoint('l5'), switchEndpoint('l6'), switchEndpoint('l7'), switchEndpoint('l8'), ], - '511.010': [cfg.light_brightness], - '43080': [cfg.light_brightness], 'DIYRuZ_RT': [cfg.switch, cfg.sensor_temperature], - '929002039801': [cfg.light_brightness], - 'DM2500ZB': [cfg.light_brightness], '99100-006': [cfg.lock, cfg.sensor_battery], 'SPE600': [cfg.switch, cfg.sensor_power], '067774': [cfg.sensor_action, cfg.sensor_battery], '067694': [cfg.sensor_action, cfg.sensor_battery], '170-33505': [cfg.switch, cfg.sensor_voltage, cfg.sensor_current, cfg.sensor_power], - '07115L': [cfg.light_brightness_colortemp_colorxy], - 'A806S-Q1G': [cfg.light_brightness_colortemp_colorxy], 'YRL-220L': [cfg.lock, cfg.sensor_battery], - 'YSR-MINI-01': [cfg.light_brightness_colortemp_colorxy], - '9290023349': [cfg.light_brightness], 'TS0115': [ switchEndpoint('l1'), switchEndpoint('l2'), switchEndpoint('l3'), switchEndpoint('l4'), switchEndpoint('l5'), ], 'WL4200': [cfg.binary_sensor_water_leak, cfg.binary_sensor_battery_low], - '404031': [cfg.light_brightness_colortemp], - 'AE 280 C': [cfg.light_brightness_colortemp_colorxy], - 'HLC833-Z-SC': [cfg.light_brightness], - '5996411U5': [cfg.light_brightness_colortemp], 'LXN59-2S7LX1.0': [switchEndpoint('left'), switchEndpoint('right')], 'X711A': [cfg.switch], 'X712A': [switchEndpoint('l1'), switchEndpoint('l2')], 'X713A': [switchEndpoint('l1'), switchEndpoint('l2'), switchEndpoint('l3')], 'TYZS1L': [cfg.light_colorhs], '43102': [cfg.switch], - '1746430P7': [cfg.light_brightness_colortemp_colorxy], 'ROB_200-010-0': [cfg.cover_position], - '1743830P7': [cfg.light_brightness_colortemp_colorxy], - 'ZB-CT01': [cfg.light_brightness_colortemp_colorxy], - '8718699703424': [cfg.light_brightness_colortemp_colorxy], 'AM25': [cfg.cover_position, cfg.sensor_battery], '43076': [cfg.switch], 'ZSTY-SM-11ZG-US-W': [cfg.switch], 'ZSTY-SM-1CTZG-US-W': [cfg.cover_position], - 'ZSTY-SM-1DMZG-US-W': [cfg.light_brightness], 'SNTZ009': [cfg.binary_sensor_water_leak], - '4058075208414': [cfg.light_brightness_colortemp], - '4058075208339': [cfg.light_brightness_colortemp_colorxy], 'NAS-AB02B0': [ cfg.sensor_temperature, cfg.sensor_humidity, cfg.binary_sensor_humidity_alarm, cfg.binary_sensor_temperature_alarm, cfg.binary_sensor_alarm, ], - 'FL 120 C': [cfg.light_brightness_colortemp_colorxy], - '9290022267': [cfg.light_brightness_colortemp], - 'ZNTGMK11LM': [cfg.light_brightness_colortemp_colorxy], - 'HLQDQ01LM': [cfg.light_brightness], - 'TS0502A': [cfg.light_brightness_colortemp], 'TS0004': [switchEndpoint('l1'), switchEndpoint('l2'), switchEndpoint('l3'), switchEndpoint('l4')], 'U86KWF-ZPSJ': [climate(5, 30, 'current_heating_setpoint', 0.5)], 'D3-DPWK-TY': [climate(5, 30, 'current_heating_setpoint', 0.5)], - '100.075.74': [cfg.light_brightness_colortemp_colorxy], - '9290019534': [cfg.light_brightness_colortemp], '98423051': [cfg.switch], - 'SM309': [cfg.light_brightness], - 'QS-Zigbee-D02-TRIAC-LN': [cfg.light_brightness], - 'QS-Zigbee-D02-TRIAC-2C-LN': [lightEndpoint('light_brightness', 'l1'), lightEndpoint('light_brightness', 'l2')], - 'BE 220': [cfg.light_brightness], 'TS0215A': [cfg.sensor_battery, cfg.sensor_action], - '4713406': [cfg.light_brightness], - '3216131P6': [cfg.light_brightness_colortemp], 'GWA1521': [cfg.switch], 'GWA1522': [switchEndpoint('l1'), switchEndpoint('l2')], 'GWA1531': [cfg.cover_position], 'TPZRCO2HT-Z3': [cfg.sensor_temperature, cfg.sensor_humidity, cfg.sensor_battery, cfg.sensor_co2], '43100': [cfg.switch], '3400-D': [cfg.sensor_action, cfg.sensor_battery], - 'GL-FL-006TZS': [cfg.light_brightness_colortemp_colorxy], 'TS0121_switch': [cfg.switch], 'ED-10011': [cfg.sensor_action], 'ED-10012': [cfg.sensor_action], @@ -2051,7 +1641,6 @@ const mapping = { 'SM308': [cfg.switch], 'SR-ZG9001T4-DIM-EU': [cfg.sensor_action], 'MEG5113-0300/MEG5165-0000': [cfg.cover_position], - '929002335001': [cfg.light_brightness], '43084': [cfg.switch], 'WSP404': [cfg.switch, cfg.sensor_power, cfg.sensor_energy], '8718699689308': [cfg.switch], @@ -2060,24 +1649,13 @@ const mapping = { cfg.sensor_humidity, cfg.sensor_illuminance, cfg.sensor_illuminance_lux, ], 'BHT-002-GCLZB': [cfg.lock_child_lock, climate(5, 30, 'current_heating_setpoint', 1)], - '8718696153062': [cfg.light_brightness], - 'E1F-N5E': [cfg.light_brightness_colortemp_colorxy], 'E220-KR4N0Z0-HA': [switchEndpoint('l1'), switchEndpoint('l2'), switchEndpoint('l3'), switchEndpoint('l4')], - 'HLD503-Z-CT': [cfg.light_brightness_colortemp], '11830304': [cfg.cover_position], - 'TS0505A': [cfg.light_brightness_colortemp_colorxy], '99100-045': [cfg.lock, cfg.sensor_battery], - 'FL 140 C': [cfg.light_brightness_colortemp_colorxy], - 'ZG102-BOX-UNIDIM': [cfg.light_brightness], - '5110131H5': [cfg.light_brightness_colortemp], 'QZR-ZIG2400': [], 'HDM40PV620': [cfg.cover_position], 'TS0207_repeater': [], - '929002294203': [cfg.light_brightness_colortemp_colorxy], - 'DM A60F': [cfg.light_brightness], 'LeTV.8KEY': [cfg.sensor_action], - '5055148P7': [cfg.light_brightness_colortemp_colorxy], - '5055131P7': [cfg.light_brightness_colortemp_colorxy], 'TS0044': [cfg.sensor_action, cfg.sensor_battery], 'HS2CM-N-DC': [cfg.cover_position], 'ZS190000118': [cfg.switch], @@ -2086,7 +1664,6 @@ const mapping = { 'WS-USC03': [cfg.switch], 'TS0601_switch_3_gang': [switchEndpoint('l1'), switchEndpoint('l2'), switchEndpoint('l3')], '4655BC0-R': [cfg.binary_sensor_contact, cfg.binary_sensor_battery_low], - 'T2011': [cfg.light_brightness_colortemp], }; const defaultStatusTopic = 'homeassistant/status'; @@ -2100,6 +1677,7 @@ class HomeAssistant extends Extension { // A map of all discoverd devices this.discovered = {}; + this.mapping = {}; this.discoveredTriggers = {}; this.legacyApi = settings.get().advanced.legacy_api; this.newApi = settings.get().experimental.new_api; @@ -2121,9 +1699,49 @@ class HomeAssistant extends Extension { this.onDeviceRenamed(data.device, data.homeAssisantRename), this.constructor.name, ); + this.populateMapping(); + } + + populateMapping() { + for (const def of zigbeeHerdsmanConverters.definitions) { + if (def.hasOwnProperty('exposes')) { + assert(!manualMaping.hasOwnProperty(def.model), `'${def.model}' has manual mapping and exposes`); + this.mapping[def.model] = []; + + for (const expose of def.exposes) { + let discoveryEntry = null; + /* istanbul ignore else */ + if (expose.type === 'light') { + discoveryEntry = { + type: 'light', + object_id: expose.endpoint ? `light_${expose.endpoint}` : 'light', + discovery_payload: { + brightness: expose.features.includes('brightness'), + color_temp: expose.features.includes('color_temp'), + xy: expose.features.includes('color_xy'), + hs: expose.features.includes('color_hs'), + schema: 'json', + command_topic: true, + brightness_scale: 254, + command_topic_prefix: expose.endpoint ? expose.endpoint : undefined, + state_topic_postfix: expose.endpoint ? expose.endpoint : undefined, + }, + }; + } + + assert(discoveryEntry !== null, `Unsupported expose for '${def.model}': ${stringify(expose)}`); + this.mapping[def.model].push(discoveryEntry); + } + } else if (manualMaping.hasOwnProperty(def.model)) { + this.mapping[def.model] = manualMaping[def.model]; + } else { + logger.warn(`Supported device '${def.model}' has no Home Assistant mapping`); + } + } + for (const definition of utils.getExternalConvertersDefinitions(settings)) { if (definition.hasOwnProperty('homeassistant')) { - mapping[definition.model] = definition.homeassistant; + this.mapping[definition.model] = definition.homeassistant; } } } @@ -2146,8 +1764,8 @@ class HomeAssistant extends Extension { * Here we retrieve all the attributes with the _l1 values and republish them on * zigbee2mqtt/mydevice/l1. */ - if (data.entity.definition && mapping[data.entity.definition.model]) { - for (const config of mapping[data.entity.definition.model]) { + if (data.entity.definition && this.mapping[data.entity.definition.model]) { + for (const config of this.mapping[data.entity.definition.model]) { const match = /light_(.*)/.exec(config['object_id']); if (match) { const endpoint = match[1]; @@ -2212,8 +1830,8 @@ class HomeAssistant extends Extension { }, { property: 'water_leak', - condition: data.entity.device && data.entity.definition && mapping[data.entity.definition.model] && - mapping[data.entity.definition.model].includes(cfg.binary_sensor_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), value: false, }, ]; @@ -2263,9 +1881,9 @@ class HomeAssistant extends Extension { } getConfigs(resolvedEntity) { - if (!resolvedEntity || !resolvedEntity.definition || !mapping[resolvedEntity.definition.model]) return []; + if (!resolvedEntity || !resolvedEntity.definition || !this.mapping[resolvedEntity.definition.model]) return []; - let configs = mapping[resolvedEntity.definition.model].slice(); + let configs = this.mapping[resolvedEntity.definition.model].slice(); configs.push(cfg.sensor_linkquality); if (resolvedEntity.definition.hasOwnProperty('ota')) { @@ -2293,7 +1911,7 @@ class HomeAssistant extends Extension { // Check if already discoverd and check if there are configs. const {device, definition} = resolvedEntity; const discover = force || !this.discovered[device.ieeeAddr]; - if (!discover || !device || !definition || !mapping[definition.model] || device.interviewing || + if (!discover || !device || !definition || !this.mapping[definition.model] || device.interviewing || (resolvedEntity.settings.hasOwnProperty('homeassistant') && !resolvedEntity.settings.homeassistant)) { return; } @@ -2580,7 +2198,7 @@ class HomeAssistant extends Extension { // Only for homeassistant.test.js _getMapping() { - return mapping; + return this.mapping; } _clearDiscoveredTrigger() { diff --git a/scripts/dumpHomeAssistantMapping.js b/scripts/dumpHomeAssistantMapping.js new file mode 100644 index 00000000..3addb299 --- /dev/null +++ b/scripts/dumpHomeAssistantMapping.js @@ -0,0 +1,26 @@ +const HomeAssistant = require('../lib/extension/homeassistant'); +const stringify = require('json-stable-stringify-without-jsonify'); +const homeassistant = new HomeAssistant(null, null, null, null, {on: () => {}}); +const mapping = Object.entries(homeassistant._getMapping()); +mapping.sort((a, b) => { + if (a[0] > b[0]) { + return -1; + } + if (b[0] > a[0]) { + return 1; + } + return 0; +}); + +for (const map of mapping) { + for (const entry of map[1]) { + if (entry.type === 'light') { + if (entry.discovery_payload.brightness === false) delete entry.discovery_payload.brightness; + if (entry.discovery_payload.color_temp === false) delete entry.discovery_payload.color_temp; + if (entry.discovery_payload.xy === false) delete entry.discovery_payload.xy; + if (entry.discovery_payload.hs === false) delete entry.discovery_payload.hs; + } + } + + console.log(`${map[0]} - ${stringify(map[1])}`); +} diff --git a/test/bridge.test.js b/test/bridge.test.js index cbcb1bf4..76383afa 100644 --- a/test/bridge.test.js +++ b/test/bridge.test.js @@ -50,7 +50,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","model":"LED1545G12","supports":"on/off, brightness, color temperature","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"}]), + 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":["state","brightness","color_temp"],"type":"light"}],"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"}]), { retain: true, qos: 0 }, expect.any(Function) ); @@ -158,7 +158,7 @@ describe('Bridge', () => { expect(MQTT.publish).toHaveBeenCalledTimes(4); expect(MQTT.publish).toHaveBeenCalledWith( 'zigbee2mqtt/bridge/event', - stringify({"type":"device_interview","data":{"friendly_name":"bulb","status":"successful","ieee_address":"0x000b57fffec6a5b2","supported":true,"definition":{"model":"LED1545G12","vendor":"IKEA","description":"TRADFRI LED bulb E26/E27 980 lumen, dimmable, white spectrum, opal white","supports":"on/off, brightness, color temperature"}}}), + stringify({"type":"device_interview","data":{"friendly_name":"bulb","status":"successful","ieee_address":"0x000b57fffec6a5b2","supported":true,"definition":{"model":"LED1545G12","vendor":"IKEA","description":"TRADFRI LED bulb E26/E27 980 lumen, dimmable, white spectrum, opal white","exposes":[{"features":["state","brightness","color_temp"],"type":"light"}]}}}), { retain: false, qos: 0 }, expect.any(Function) ); diff --git a/test/homeassistant.test.js b/test/homeassistant.test.js index 285670e4..d0125762 100644 --- a/test/homeassistant.test.js +++ b/test/homeassistant.test.js @@ -26,8 +26,8 @@ describe('HomeAssistant extension', () => { const missing = []; const ha = new HomeAssistant(null, null, null, null, {on: () => {}}); - require('zigbee-herdsman-converters').devices.forEach((d) => { - if (!ha._getMapping()[d.model]) { + require('zigbee-herdsman-converters').definitions.forEach((d) => { + if (!d.hasOwnProperty('exposes') && !ha._getMapping()[d.model]) { missing.push(d.model); } });