From 41e68c8ffe8b6a182607b501f9c3dd8b876c78db Mon Sep 17 00:00:00 2001 From: Koen Kanters Date: Mon, 23 Sep 2019 22:21:27 +0200 Subject: [PATCH] Update zigbee-herdsman to 0.7.0. --- lib/controller.js | 12 +- lib/extension/bridgeConfig.js | 8 +- lib/extension/deviceAvailability.js | 13 +- lib/extension/deviceBind.js | 4 +- lib/extension/deviceConfigure.js | 5 +- lib/extension/deviceEvent.js | 4 +- lib/extension/deviceGroupMembership.js | 2 +- lib/extension/deviceReceive.js | 2 +- lib/extension/deviceReport.js | 4 +- lib/extension/entityPublish.js | 2 +- lib/extension/groups.js | 19 ++- lib/extension/homeassistant.js | 4 +- lib/extension/networkMap.js | 6 +- lib/zigbee.js | 41 +++--- npm-shrinkwrap.json | 185 ++++++++----------------- package.json | 2 +- test/controller.test.js | 2 +- test/deviceEvent.test.js | 2 +- test/stub/zigbeeHerdsman.js | 25 ++-- 19 files changed, 130 insertions(+), 212 deletions(-) diff --git a/lib/controller.js b/lib/controller.js index 0bb449868..74542dfb3 100644 --- a/lib/controller.js +++ b/lib/controller.js @@ -90,10 +90,10 @@ class Controller { } // Log zigbee clients on startup - const devices = await this.zigbee.getClients(); + const devices = this.zigbee.getClients(); logger.info(`Currently ${devices.length} devices are joined:`); for (const device of devices) { - const entity = await this.zigbee.resolveEntity(device); + const entity = this.zigbee.resolveEntity(device); logger.info( (entity.settings ? entity.settings.friendlyName : entity.device.ieeeAddr) + ` (${entity.device.ieeeAddr}): ` + @@ -121,7 +121,7 @@ class Controller { await this.mqtt.connect(); // Send all cached states. - for (const device of await this.zigbee.getClients()) { + for (const device of this.zigbee.getClients()) { if (this.state.exists(device.ieeeAddr)) { this.publishEntityState(device.ieeeAddr, this.state.get(device.ieeeAddr)); } @@ -154,7 +154,7 @@ class Controller { } async onZigbeeEvent(type, data) { - const entity = await this.zigbee.resolveEntity(data.device || data.ieeeAddr); + const entity = this.zigbee.resolveEntity(data.device || data.ieeeAddr); if (!entity.settings && data.device) { // Only deviceLeave doesn't have a device (not interesting to add to settings) entity.settings = settings.addDevice(data.device.ieeeAddr); @@ -223,7 +223,7 @@ class Controller { } async publishEntityState(IDorName, payload) { - const entity = await this.zigbee.resolveEntity(IDorName); + const entity = this.zigbee.resolveEntity(IDorName); if (!entity || !entity.settings) { logger.error(`'${IDorName}' does not exist, skipping publish`); return; @@ -247,7 +247,7 @@ class Controller { }; if (entity.type === 'device' && settings.get().mqtt.include_device_information) { - const device = await this.zigbee.getDevice({ieeeAddr: entity.device.ieeeAddr}); + const device = this.zigbee.getDeviceByIeeeAddr(entity.device.ieeeAddr); const attributes = [ 'ieeeAddr', 'networkAddress', 'type', 'manufacturerID', 'manufacturerName', 'powerSource', 'applicationVersion', 'stackVersion', 'zclVersion', 'hardwareVersion', 'dateCode', 'softwareBuildID', diff --git a/lib/extension/bridgeConfig.js b/lib/extension/bridgeConfig.js index 08794f97b..b4e5ca52a 100644 --- a/lib/extension/bridgeConfig.js +++ b/lib/extension/bridgeConfig.js @@ -130,7 +130,7 @@ class BridgeConfig extends BaseExtension { } async devices(topic, message) { - const devices = (await this.zigbee.getDevices({})).map((device) => { + const devices = this.zigbee.getDevices().map((device) => { const payload = { ieeeAddr: device.ieeeAddr, type: device.type, @@ -196,10 +196,10 @@ class BridgeConfig extends BaseExtension { } } - async addGroup(topic, message) { + addGroup(topic, message) { const name = message; const group = settings.addGroup(name); - await this.zigbee.createGroup(group.ID); + this.zigbee.createGroup(group.ID); logger.info(`Added group '${name}'`); } @@ -218,7 +218,7 @@ class BridgeConfig extends BaseExtension { } async removeOrBan(ban, message) { - const entity = await this.zigbee.resolveEntity(message); + const entity = this.zigbee.resolveEntity(message); const cleanup = () => { // Remove from configuration.yaml diff --git a/lib/extension/deviceAvailability.js b/lib/extension/deviceAvailability.js index 298a6306c..298e5caf5 100644 --- a/lib/extension/deviceAvailability.js +++ b/lib/extension/deviceAvailability.js @@ -46,18 +46,17 @@ class DeviceAvailability extends BaseExtension { return result; } - async getAllPingableDevices() { - return (await this.zigbee.getClients()).filter((d) => this.isPingable(d)); + getAllPingableDevices() { + return this.zigbee.getClients().filter((d) => this.isPingable(d)); } - async onMQTTConnected() { + onMQTTConnected() { // As some devices are not checked for availability (e.g. battery powered devices) // we mark all device as online by default. - (await this.zigbee.getClients()) - .forEach((device) => this.publishAvailability(device, true)); + this.zigbee.getClients().forEach((device) => this.publishAvailability(device, true)); // Start timers for all devices - (await this.getAllPingableDevices()).forEach((device) => this.setTimer(device)); + this.getAllPingableDevices().forEach((device) => this.setTimer(device)); } async handleInterval(device) { @@ -91,7 +90,7 @@ class DeviceAvailability extends BaseExtension { clearTimeout(timer); } - (await this.zigbee.getClients()).forEach((device) => this.publishAvailability(device, false)); + this.zigbee.getClients().forEach((device) => this.publishAvailability(device, false)); } async onReconnect(device) { diff --git a/lib/extension/deviceBind.js b/lib/extension/deviceBind.js index ca2e35c5e..520c781fe 100644 --- a/lib/extension/deviceBind.js +++ b/lib/extension/deviceBind.js @@ -26,9 +26,9 @@ class DeviceBind extends BaseExtension { const targetKey = message; // Find source; can only be a device and target - const source = await this.zigbee.resolveEntity(sourceKey); + const source = this.zigbee.resolveEntity(sourceKey); assert(source != null && source.type === 'device', 'Source undefined or not a device'); - const target = await this.zigbee.resolveEntity(targetKey); + const target = this.zigbee.resolveEntity(targetKey); assert(target != null, 'Target is unknown'); const sourceName = source.settings.friendlyName; diff --git a/lib/extension/deviceConfigure.js b/lib/extension/deviceConfigure.js index d11876ac8..8272a1a6d 100644 --- a/lib/extension/deviceConfigure.js +++ b/lib/extension/deviceConfigure.js @@ -32,10 +32,9 @@ class DeviceConfigure extends BaseExtension { } async onZigbeeStarted() { - this.coordinatorEndpoint = (await this.zigbee.getDevice({type: 'Coordinator'})).endpoints[0]; + this.coordinatorEndpoint = this.zigbee.getDevicesByType('Coordinator')[0].endpoints[0]; - const devices = await this.zigbee.getClients(); - for (const device of devices) { + for (const device of this.zigbee.getClients()) { const mappedDevice = zigbeeHerdsmanConverters.findByZigbeeModel(device.modelID); const settingsDevice = settings.getDevice(device.ieeeAddr); if (this.shouldConfigure(device, mappedDevice)) { diff --git a/lib/extension/deviceEvent.js b/lib/extension/deviceEvent.js index 9df889829..1e54c71e1 100644 --- a/lib/extension/deviceEvent.js +++ b/lib/extension/deviceEvent.js @@ -3,7 +3,7 @@ const zigbeeHerdsmanConverters = require('zigbee-herdsman-converters'); class DeviceEvent extends BaseExtension { async onZigbeeStarted() { - for (const device of await this.zigbee.getClients()) { + for (const device of this.zigbee.getClients()) { this.callOnEvent(device, 'start', {}); } } @@ -15,7 +15,7 @@ class DeviceEvent extends BaseExtension { } async stop() { - for (const device of await this.zigbee.getClients()) { + for (const device of this.zigbee.getClients()) { this.callOnEvent(device, 'stop', {}); } } diff --git a/lib/extension/deviceGroupMembership.js b/lib/extension/deviceGroupMembership.js index 2dbbd3f34..a4e778129 100644 --- a/lib/extension/deviceGroupMembership.js +++ b/lib/extension/deviceGroupMembership.js @@ -16,7 +16,7 @@ class DeviceGroupMembership extends BaseExtension { return null; } - const entity = await this.zigbee.resolveEntity(match[1]); + const entity = this.zigbee.resolveEntity(match[1]); if (!entity || entity.type !== 'device') { logger.error(`Device '${match[1]}' does not exist`); return; diff --git a/lib/extension/deviceReceive.js b/lib/extension/deviceReceive.js index 43beba78b..502a4ce01 100644 --- a/lib/extension/deviceReceive.js +++ b/lib/extension/deviceReceive.js @@ -13,7 +13,7 @@ class DeviceReceive extends BaseExtension { } async onZigbeeStarted() { - this.coordinator = await this.zigbee.getDevice({type: 'Coordinator'}); + this.coordinator = this.zigbee.getDevicesByType('Coordinator')[0]; } publishDebounce(ieeeAddr, payload, time) { diff --git a/lib/extension/deviceReport.js b/lib/extension/deviceReport.js index a73e76b4b..8a459753e 100644 --- a/lib/extension/deviceReport.js +++ b/lib/extension/deviceReport.js @@ -81,9 +81,9 @@ class DeviceReport extends BaseExtension { } async onZigbeeStarted() { - this.coordinatorEndpoint = (await this.zigbee.getDevice({type: 'Coordinator'})).endpoints[0]; + this.coordinatorEndpoint = this.zigbee.getDevicesByType('Coordinator')[0].endpoints[0]; - for (const device of await this.zigbee.getClients()) { + for (const device of this.zigbee.getClients()) { const mappedDevice = zigbeeHerdsmanConverters.findByZigbeeModel(device.modelID); if (this.shouldSetupReporting(mappedDevice, device, null)) { this.setupReporting(device); diff --git a/lib/extension/entityPublish.js b/lib/extension/entityPublish.js index a2c0610dd..0fdd025fa 100644 --- a/lib/extension/entityPublish.js +++ b/lib/extension/entityPublish.js @@ -52,7 +52,7 @@ class EntityPublish extends BaseExtension { } const entityName = `${topic.ID}` + (topic.postfix ? `/${topic.postfix}` : ''); - const entity = await this.zigbee.resolveEntity(entityName); + const entity = this.zigbee.resolveEntity(entityName); if (!entity) { this.mqtt.log('entity_not_found', {friendly_name: entityName}); diff --git a/lib/extension/groups.js b/lib/extension/groups.js index 176033eb4..df6d03ac4 100644 --- a/lib/extension/groups.js +++ b/lib/extension/groups.js @@ -25,16 +25,15 @@ class Groups extends BaseExtension { async syncGroupsWithSettings() { const settingsGroups = settings.getGroups(); - const zigbeeGroups = await this.zigbee.getGroups({}); + const zigbeeGroups = this.zigbee.getGroups(); for (const settingGroup of settingsGroups) { const groupID = settingGroup.ID; - const zigbeeGroup = zigbeeGroups.find((g) => g.groupID === groupID) || - (await this.zigbee.createGroup(groupID)); - const settingsEntity = (await Promise.all(settingGroup.devices.map(async (d) => { - const entity = await this.zigbee.resolveEntity(d); + const zigbeeGroup = zigbeeGroups.find((g) => g.groupID === groupID) || this.zigbee.createGroup(groupID); + const settingsEntity = settingGroup.devices.map((d) => { + const entity = this.zigbee.resolveEntity(d); if (!entity) logger.error(`Cannot find '${d}' of group '${settingGroup.friendlyName}'`); return entity; - }))).filter((e) => e != null); + }).filter((e) => e != null); // In settings but not in zigbee for (const entity of settingsEntity) { @@ -77,12 +76,12 @@ class Groups extends BaseExtension { }); if (Object.keys(payload).length) { - const entity = await this.zigbee.resolveEntity(data.ID); + const entity = this.zigbee.resolveEntity(data.ID); if (entity.type !== 'device') { return; } - const zigbeeGroups = await this.zigbee.getGroups({}); + const zigbeeGroups = this.zigbee.getGroups(); for (const zigbeeGroup of zigbeeGroups) { const settingsGroup = settings.getGroup(zigbeeGroup.groupID); if (settingsGroup && settingsGroup.optimistic && zigbeeGroup.hasMember(entity.endpoint)) { @@ -97,7 +96,7 @@ class Groups extends BaseExtension { let group; const topicMatch = topic.match(topicRegex); if (topicMatch) { - group = await this.zigbee.resolveEntity(topicMatch[1]); + group = this.zigbee.resolveEntity(topicMatch[1]); type = topicMatch[2]; if (!group || group.type !== 'group') { @@ -110,7 +109,7 @@ class Groups extends BaseExtension { return; } - const entity = await this.zigbee.resolveEntity(message); + const entity = this.zigbee.resolveEntity(message); if (!entity || !entity.type === 'device') { logger.error(`Device '${message}' does not exist`); return; diff --git a/lib/extension/homeassistant.js b/lib/extension/homeassistant.js index 866bc8d3a..577f52755 100644 --- a/lib/extension/homeassistant.js +++ b/lib/extension/homeassistant.js @@ -928,7 +928,7 @@ class HomeAssistant extends BaseExtension { this.mqtt.subscribe(this.statusTopic); // MQTT discovery of all paired devices on startup. - for (const device of await this.zigbee.getClients()) { + for (const device of this.zigbee.getClients()) { const mappedModel = zigbeeHerdsmanConverters.findByZigbeeModel(device.modelID); if (mappedModel) { this.discover(device.ieeeAddr, mappedModel, true); @@ -1100,7 +1100,7 @@ class HomeAssistant extends BaseExtension { if (message.toLowerCase() === 'online') { const timer = setTimeout(async () => { // Publish all device states. - for (const device of await this.zigbee.getClients()) { + for (const device of this.zigbee.getClients()) { if (this.state.exists(device.ieeeAddr)) { this.publishEntityState(device.ieeeAddr, this.state.get(device.ieeeAddr)); } diff --git a/lib/extension/networkMap.js b/lib/extension/networkMap.js index 5b9602ba0..6c6c6be8d 100644 --- a/lib/extension/networkMap.js +++ b/lib/extension/networkMap.js @@ -120,14 +120,14 @@ class NetworkMap extends BaseExtension { async networkScan(includeRoutes) { logger.info(`Starting network scan (includeRoutes '${includeRoutes}')`); - const devices = await this.zigbee.getDevices({}); + const devices = this.zigbee.getDevices(); const lqis = new Map(); const routingTables = new Map(); const failed = new Map(); for (const device of devices.filter((d) => d.type != 'EndDevice')) { failed.set(device, []); - const resolved = await this.zigbee.resolveEntity(device); + const resolved = this.zigbee.resolveEntity(device); try { const result = await device.lqi(); lqis.set(device, result); @@ -154,7 +154,7 @@ class NetworkMap extends BaseExtension { const networkMap = {nodes: [], links: []}; // Add nodes for (const device of devices) { - const resolved = await this.zigbee.resolveEntity(device); + const resolved = this.zigbee.resolveEntity(device); networkMap.nodes.push({ ieeeAddr: device.ieeeAddr, friendlyName: resolved.name, type: device.type, networkAddress: device.networkAddress, manufacturerName: device.manufacturerName, diff --git a/lib/zigbee.js b/lib/zigbee.js index d36ba4a5d..5c9d975bf 100644 --- a/lib/zigbee.js +++ b/lib/zigbee.js @@ -58,7 +58,7 @@ class Zigbee extends events.EventEmitter { logger.info(`Coordinator firmware version: '${JSON.stringify(await this.getCoordinatorVersion())}'`); logger.debug(`Zigbee network parameters: ${JSON.stringify(await this.herdsman.getNetworkParameters())}`); - for (const device of await this.getClients()) { + for (const device of this.getClients()) { // If a whitelist is used, all other device will be removed from the network. if (settings.get().whitelist.length > 0) { if (!settings.get().whitelist.includes(device.ieeeAddr)) { @@ -102,20 +102,23 @@ class Zigbee extends events.EventEmitter { return this.herdsman.getPermitJoin(); } - async getClients() { - const devices = await this.herdsman.getDevices({}); - return devices.filter((device) => device.type !== 'Coordinator'); + getClients() { + return this.herdsman.getDevices().filter((device) => device.type !== 'Coordinator'); } - async getDevices(query) { - return this.herdsman.getDevices(query); + getDevices() { + return this.herdsman.getDevices(); } - async getDevice(query) { - return this.herdsman.getDevice(query); + getDeviceByIeeeAddr(ieeeAddr) { + return this.herdsman.getDeviceByIeeeAddr(ieeeAddr); } - async resolveEntity(key) { + getDevicesByType(type) { + return this.herdsman.getDevicesByType(type); + } + + resolveEntity(key) { assert( typeof key === 'string' || typeof key === 'number' || key.constructor.name === 'Device', `Wrong type '${typeof key}'` @@ -127,7 +130,7 @@ class Zigbee extends events.EventEmitter { } if (key === 'coordinator') { - const coordinator = await this.getDevice({type: 'Coordinator'}); + const coordinator = this.getDevicesByType('Coordinator')[0]; return { type: 'device', device: coordinator, @@ -150,7 +153,7 @@ class Zigbee extends events.EventEmitter { if (!entity) { return null; } else if (entity.type === 'device') { - const device = await this.getDevice({ieeeAddr: entity.ID}); + const device = this.getDeviceByIeeeAddr(entity.ID); const mapped = zigbeeHerdsmanConverters.findByZigbeeModel(device.modelID); const endpoints = mapped && mapped.endpoint ? mapped.endpoint(device) : null; let isDefaultEndpoint = true; @@ -178,8 +181,8 @@ class Zigbee extends events.EventEmitter { isDefaultEndpoint, endpointName, }; } else { - let group = await this.getGroup({groupID: entity.ID}); - if (!group) group = await this.createGroup(entity.ID); + let group = this.getGroupByID(entity.ID); + if (!group) group = this.createGroup(entity.ID); return {type: 'group', group, settings: entity, name: entity.friendlyName}; } } else { @@ -194,16 +197,16 @@ class Zigbee extends events.EventEmitter { } } - async getGroup(query) { - return this.herdsman.getGroup(query); + getGroupByID(ID) { + return this.herdsman.getGroupByID(ID); } - async getGroups(query) { - return this.herdsman.getGroups(query); + getGroups() { + return this.herdsman.getGroups(); } - async createGroup(groupID) { - return await this.herdsman.createGroup(groupID); + createGroup(groupID) { + return this.herdsman.createGroup(groupID); } // TODO diff --git a/npm-shrinkwrap.json b/npm-shrinkwrap.json index deba44e34..9746b2fba 100644 --- a/npm-shrinkwrap.json +++ b/npm-shrinkwrap.json @@ -1362,9 +1362,9 @@ "dev": true }, "end-of-stream": { - "version": "1.4.1", - "resolved": "https://registry.npmjs.org/end-of-stream/-/end-of-stream-1.4.1.tgz", - "integrity": "sha512-1MkrZNvWTKCaigbn+W15elq2BB/L22nqrSY5DKlo3X6+vclJm8Bb5djXJBmEX6fS3+zCh/F4VBK5Z2KxJt4s2Q==", + "version": "1.4.2", + "resolved": "https://registry.npmjs.org/end-of-stream/-/end-of-stream-1.4.2.tgz", + "integrity": "sha512-gUSUszrsxlDnUbUwEI9Oygyrk4ZEWtVaHQc+uZHphVeNxl+qeqMV/jDWoTkjN1RmGlZ5QWAP7o458p/JMlikQg==", "requires": { "once": "^1.4.0" } @@ -5938,14 +5938,13 @@ } }, "zigbee-herdsman": { - "version": "0.6.18", - "resolved": "https://registry.npmjs.org/zigbee-herdsman/-/zigbee-herdsman-0.6.18.tgz", - "integrity": "sha512-LgTCgbN0tYwoBqDWg7ogOOCuKSlsQ31q4gX8Dohewbs9n8NFCum6z3PA2hvM7zYcW6RvjWp5FfCDU/do6BQyxw==", + "version": "0.7.0", + "resolved": "https://registry.npmjs.org/zigbee-herdsman/-/zigbee-herdsman-0.7.0.tgz", + "integrity": "sha512-1f/E4EL/WH4ETIysgo8RJU+hWDhFHlYxjfAAN2I1cIycpvwtZtZ/vhPyT0JdGRfpusHAJxRtAm8GZ/aMxKf08Q==", "requires": { "debug": "^4.1.1", "fast-deep-equal": "^2.0.1", "mixin-deep": "^2.0.1", - "nedb": "^1.8.0", "serialport": "8.0.1" }, "dependencies": { @@ -6727,13 +6726,6 @@ "requires": { "exec-sh": "^0.3.2", "minimist": "^1.2.0" - }, - "dependencies": { - "minimist": { - "version": "1.2.0", - "resolved": "https://registry.npmjs.org/minimist/-/minimist-1.2.0.tgz", - "integrity": "sha1-o1AIsg9BOD7sH7kU9M1d95omQoQ=" - } } }, "@jest/console": { @@ -7129,11 +7121,11 @@ "integrity": "sha512-gCubfBUZ6KxzoibJ+SCUc/57Ms1jz5NjHe4+dI2krNmU5zCPAphyLJYyTOg06ueIyfj+SaCUqmzun7ImlxDcKg==" }, "@typescript-eslint/eslint-plugin": { - "version": "2.3.0", - "resolved": "https://registry.npmjs.org/@typescript-eslint/eslint-plugin/-/eslint-plugin-2.3.0.tgz", - "integrity": "sha512-QgO/qmNye+rKsU7dan6pkBTSfpbyrHJidsw9bR3gZCrQNTB9eWQ5+UDkrrev/fu9xg6Qh7ebbx03IVuGnGRmEw==", + "version": "2.3.1", + "resolved": "https://registry.npmjs.org/@typescript-eslint/eslint-plugin/-/eslint-plugin-2.3.1.tgz", + "integrity": "sha512-VqVNEsvemviajlaWm03kVMabc6S3xCHGYuY0fReTrIIOZg+3WzB+wfw6fD3KYKerw5lYxmzogmHOZ0i7YKnuwA==", "requires": { - "@typescript-eslint/experimental-utils": "2.3.0", + "@typescript-eslint/experimental-utils": "2.3.1", "eslint-utils": "^1.4.2", "functional-red-black-tree": "^1.0.1", "regexpp": "^2.0.1", @@ -7141,30 +7133,30 @@ } }, "@typescript-eslint/experimental-utils": { - "version": "2.3.0", - "resolved": "https://registry.npmjs.org/@typescript-eslint/experimental-utils/-/experimental-utils-2.3.0.tgz", - "integrity": "sha512-ry+fgd0Hh33LyzS30bIhX/a1HJpvtnecjQjWxxsZTavrRa1ymdmX7tz+7lPrPAxB018jnNzwNtog6s3OhxPTAg==", + "version": "2.3.1", + "resolved": "https://registry.npmjs.org/@typescript-eslint/experimental-utils/-/experimental-utils-2.3.1.tgz", + "integrity": "sha512-FaZEj73o4h6Wd0Lg+R4pZiJGdR0ZYbJr+O2+RbQ1aZjX8bZcfkVDtD+qm74Dv77rfSKkDKE64UTziLBo9UYHQA==", "requires": { "@types/json-schema": "^7.0.3", - "@typescript-eslint/typescript-estree": "2.3.0", + "@typescript-eslint/typescript-estree": "2.3.1", "eslint-scope": "^5.0.0" } }, "@typescript-eslint/parser": { - "version": "2.3.0", - "resolved": "https://registry.npmjs.org/@typescript-eslint/parser/-/parser-2.3.0.tgz", - "integrity": "sha512-Dc+LAtHts0yDuusxG0NVjGvrpPy2kZauxqPbfFs0fmcMB4JhNs+WwIDMFGWeKjbGoPt/SIUC9XJ7E0ZD/f8InQ==", + "version": "2.3.1", + "resolved": "https://registry.npmjs.org/@typescript-eslint/parser/-/parser-2.3.1.tgz", + "integrity": "sha512-ZlWdzhCJ2iZnSp/VBAJ/sowFbyHycIux8t0UEH0JsKgQvfSf7949hLYFMwTXdCMeEnpP1zRTHimrR+YHzs8LIw==", "requires": { "@types/eslint-visitor-keys": "^1.0.0", - "@typescript-eslint/experimental-utils": "2.3.0", - "@typescript-eslint/typescript-estree": "2.3.0", + "@typescript-eslint/experimental-utils": "2.3.1", + "@typescript-eslint/typescript-estree": "2.3.1", "eslint-visitor-keys": "^1.1.0" } }, "@typescript-eslint/typescript-estree": { - "version": "2.3.0", - "resolved": "https://registry.npmjs.org/@typescript-eslint/typescript-estree/-/typescript-estree-2.3.0.tgz", - "integrity": "sha512-WBxfwsTeCOsmQ7cLjow7lgysviBKUW34npShu7dxJYUQCbSG5nfZWZTgmQPKEc+3flpbSM7tjXjQOgETYp+njQ==", + "version": "2.3.1", + "resolved": "https://registry.npmjs.org/@typescript-eslint/typescript-estree/-/typescript-estree-2.3.1.tgz", + "integrity": "sha512-9SFhUgFuePJBB6jlLkOPPhMkZNiDCr+S8Ft7yAkkP2c5x5bxPhG3pe/exMiQaF8IGyVMDW6Ul0q4/cZ+uF3uog==", "requires": { "glob": "^7.1.4", "is-glob": "^4.0.1", @@ -7353,11 +7345,6 @@ "resolved": "https://registry.npmjs.org/astral-regex/-/astral-regex-1.0.0.tgz", "integrity": "sha512-+Ryf6g3BKoRc7jfp7ad8tM4TtMiaWvbF/1/sQcZPkkS7ag3D5nMBCe2UfOTONtAkaG0tO0ij3C5Lwmf1EiyjHg==" }, - "async": { - "version": "0.2.10", - "resolved": "https://registry.npmjs.org/async/-/async-0.2.10.tgz", - "integrity": "sha1-trvgsGdLnXGXCMo43owjfLUmw9E=" - }, "async-each": { "version": "1.0.3", "resolved": "https://registry.npmjs.org/async-each/-/async-each-1.0.3.tgz", @@ -7525,14 +7512,6 @@ "integrity": "sha512-Un7MIEDdUC5gNpcGDV97op1Ywk748MpHcFTHoYs6qnj1Z3j7I53VG3nwZhKzoBZmbdRNnb6WRdFlwl7tSDuZGw==", "optional": true }, - "binary-search-tree": { - "version": "0.2.5", - "resolved": "https://registry.npmjs.org/binary-search-tree/-/binary-search-tree-0.2.5.tgz", - "integrity": "sha1-fbs7IQ/coIJFDa0jNMMErzm9x4Q=", - "requires": { - "underscore": "~1.4.4" - } - }, "bindings": { "version": "1.5.0", "resolved": "https://registry.npmjs.org/bindings/-/bindings-1.5.0.tgz", @@ -8187,9 +8166,9 @@ "integrity": "sha512-Dj6Wk3tWyTE+Fo1rW8v0Xhwk80um6yFYKbuAxc9c3EZxIHFDYwbi34Uk42u1CdnIiVorvt4RmlSDjIPyzGC2ew==" }, "dmd": { - "version": "4.0.3", - "resolved": "https://registry.npmjs.org/dmd/-/dmd-4.0.3.tgz", - "integrity": "sha512-qU9jcZQCxfLlTbZU1e5jROXVkTsn9q3s1FmnOPFWo9tfDol3cSt0AZREiXCsgmSaS5L/AXXQqcZiR7YjFNAL1g==", + "version": "4.0.4", + "resolved": "https://registry.npmjs.org/dmd/-/dmd-4.0.4.tgz", + "integrity": "sha512-ZbHUPKUp5Tl8nVVMZw8rc/MQmFVKusvfR10X/lPAXjBUc/LRW7AaXnYrK2LnVIPfTGEw7T6OmsxkvNRX7GnjIQ==", "requires": { "array-back": "^4.0.0", "cache-point": "^0.4.1", @@ -8238,9 +8217,9 @@ } }, "electron-to-chromium": { - "version": "1.3.261", - "resolved": "https://registry.npmjs.org/electron-to-chromium/-/electron-to-chromium-1.3.261.tgz", - "integrity": "sha512-nA9xFj1SgHXlW/6T4+udW2u/Ic/bne25UoFsddoNM7Ut2bgNGLLQUhLhk+vQlbKh9WiRgDDlHaC36Oy7AgRR9w==" + "version": "1.3.264", + "resolved": "https://registry.npmjs.org/electron-to-chromium/-/electron-to-chromium-1.3.264.tgz", + "integrity": "sha512-z8E7WkrrquCuGYv+kKyybuZIbdms+4PeHp7Zm2uIgEhAigP0bOwqXILItwj0YO73o+QyHY/7XtEfP5DsHOWQgQ==" }, "emoji-regex": { "version": "7.0.3", @@ -8248,9 +8227,9 @@ "integrity": "sha512-CwBLREIQ7LvYFB0WyRvwhq5N5qPhc6PMjD6bYggFlI5YyDgl+0vxq5VHbMOFqLg7hfWzmu8T5Z1QofhmTIhItA==" }, "end-of-stream": { - "version": "1.4.1", - "resolved": "https://registry.npmjs.org/end-of-stream/-/end-of-stream-1.4.1.tgz", - "integrity": "sha512-1MkrZNvWTKCaigbn+W15elq2BB/L22nqrSY5DKlo3X6+vclJm8Bb5djXJBmEX6fS3+zCh/F4VBK5Z2KxJt4s2Q==", + "version": "1.4.2", + "resolved": "https://registry.npmjs.org/end-of-stream/-/end-of-stream-1.4.2.tgz", + "integrity": "sha512-gUSUszrsxlDnUbUwEI9Oygyrk4ZEWtVaHQc+uZHphVeNxl+qeqMV/jDWoTkjN1RmGlZ5QWAP7o458p/JMlikQg==", "requires": { "once": "^1.4.0" } @@ -8375,9 +8354,9 @@ "integrity": "sha512-1apePfXM1UOSqw0o9IiFAovVz9M5S1Dg+4TrDwfMewQ6p/rmMueb7tWZjQ1rx4Loy1ArBggoqGpfqqdI4rondg==" }, "glob-parent": { - "version": "5.0.0", - "resolved": "https://registry.npmjs.org/glob-parent/-/glob-parent-5.0.0.tgz", - "integrity": "sha512-Z2RwiujPRGluePM6j699ktJYxmPpJKCfpGA13jz2hmFZC7gKetzrWvg5KN3+OsIFmydGyZ1AVwERCq1w/ZZwRg==", + "version": "5.1.0", + "resolved": "https://registry.npmjs.org/glob-parent/-/glob-parent-5.1.0.tgz", + "integrity": "sha512-qjtRgnIVmOfnKUE3NJAQEdk+lKrxfw8t5ke7SXtfMTHcjsBfOfWXCQfdb30zfDoZQ2IRSIiidmjtbHZPZ++Ihw==", "requires": { "is-glob": "^4.0.1" } @@ -9417,9 +9396,9 @@ "integrity": "sha1-8QdIy+dq+WS3yWyTxrzCivEgwIE=" }, "handlebars": { - "version": "4.2.0", - "resolved": "https://registry.npmjs.org/handlebars/-/handlebars-4.2.0.tgz", - "integrity": "sha512-Kb4xn5Qh1cxAKvQnzNWZ512DhABzyFNmsaJf3OAkWNa4NkaqWcNI8Tao8Tasi0/F4JD9oyG0YxuFyvyR57d+Gw==", + "version": "4.2.1", + "resolved": "https://registry.npmjs.org/handlebars/-/handlebars-4.2.1.tgz", + "integrity": "sha512-bqPIlDk06UWbVEIFoYj+LVo42WhK96J+b25l7hbFDpxrOXMphFM3fNIm+cluwg4Pk2jiLjWU5nHQY7igGE75NQ==", "requires": { "neo-async": "^2.6.0", "optimist": "^0.6.1", @@ -9536,11 +9515,6 @@ "resolved": "https://registry.npmjs.org/ignore/-/ignore-4.0.6.tgz", "integrity": "sha512-cyFDKrqc/YdcWFniJhzI42+AzS+gNwmUzOSFcRCQYwySuBBBy/KjuxWLZ/FHEH6Moq1NizMOBWyTcv8O4OZIMg==" }, - "immediate": { - "version": "3.0.6", - "resolved": "https://registry.npmjs.org/immediate/-/immediate-3.0.6.tgz", - "integrity": "sha1-nbHb0Pr43m++D13V5Wu2BigN5ps=" - }, "import-fresh": { "version": "3.1.0", "resolved": "https://registry.npmjs.org/import-fresh/-/import-fresh-3.1.0.tgz", @@ -10408,11 +10382,6 @@ "version": "3.0.1", "resolved": "https://registry.npmjs.org/strip-json-comments/-/strip-json-comments-3.0.1.tgz", "integrity": "sha512-VTyMAUfdm047mwKl+u79WIdrZxtFtn+nBxHeb844XBQ9uMNTuTHdx2hc5RiAJYqwTj3wc/xe5HLSdJSkJ+WfZw==" - }, - "underscore": { - "version": "1.9.1", - "resolved": "https://registry.npmjs.org/underscore/-/underscore-1.9.1.tgz", - "integrity": "sha512-5/4etnCkd9c8gwgowi5/om/mYO5ajCaOgdzj/oW+0eQV9WxKBDZw5+ycmKmeaTXjInS/W0BzpGLo2xR2aBwZdg==" } } }, @@ -10549,13 +10518,6 @@ "integrity": "sha512-8Mh9h6xViijj36g7Dxi+Y4S6hNGV96vcJZr/SrlHh1LR/pEn/8j/+qIBbs44YKl69Lrfctp4QD+AdWLTMqEZAQ==", "requires": { "minimist": "^1.2.0" - }, - "dependencies": { - "minimist": { - "version": "1.2.0", - "resolved": "https://registry.npmjs.org/minimist/-/minimist-1.2.0.tgz", - "integrity": "sha1-o1AIsg9BOD7sH7kU9M1d95omQoQ=" - } } }, "jsprim": { @@ -10606,14 +10568,6 @@ "type-check": "~0.3.2" } }, - "lie": { - "version": "3.1.1", - "resolved": "https://registry.npmjs.org/lie/-/lie-3.1.1.tgz", - "integrity": "sha1-mkNrLMd0bKWd56QfpGmz77dr2H4=", - "requires": { - "immediate": "~3.0.5" - } - }, "linkify-it": { "version": "2.2.0", "resolved": "https://registry.npmjs.org/linkify-it/-/linkify-it-2.2.0.tgz", @@ -10633,14 +10587,6 @@ "strip-bom": "^3.0.0" } }, - "localforage": { - "version": "1.7.3", - "resolved": "https://registry.npmjs.org/localforage/-/localforage-1.7.3.tgz", - "integrity": "sha512-1TulyYfc4udS7ECSBT2vwJksWbkwwTX8BzeUIiq8Y07Riy7bDAAnxDaPU/tWyOVmQAcWJIEIFP9lPfBGqVoPgQ==", - "requires": { - "lie": "3.1.1" - } - }, "locate-path": { "version": "3.0.0", "resolved": "https://registry.npmjs.org/locate-path/-/locate-path-3.0.0.tgz", @@ -10814,9 +10760,9 @@ } }, "minimist": { - "version": "0.0.8", - "resolved": "https://registry.npmjs.org/minimist/-/minimist-0.0.8.tgz", - "integrity": "sha1-hX/Kv8M5fSYluCKCYuhqp6ARsF0=" + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/minimist/-/minimist-1.2.0.tgz", + "integrity": "sha1-o1AIsg9BOD7sH7kU9M1d95omQoQ=" }, "mixin-deep": { "version": "2.0.1", @@ -10829,6 +10775,13 @@ "integrity": "sha1-MAV0OOrGz3+MR2fzhkjWaX11yQM=", "requires": { "minimist": "0.0.8" + }, + "dependencies": { + "minimist": { + "version": "0.0.8", + "resolved": "https://registry.npmjs.org/minimist/-/minimist-0.0.8.tgz", + "integrity": "sha1-hX/Kv8M5fSYluCKCYuhqp6ARsF0=" + } } }, "mkdirp2": { @@ -10879,18 +10832,6 @@ "resolved": "https://registry.npmjs.org/natural-compare/-/natural-compare-1.4.0.tgz", "integrity": "sha1-Sr6/7tdUHywnrPspvbvRXI1bpPc=" }, - "nedb": { - "version": "1.8.0", - "resolved": "https://registry.npmjs.org/nedb/-/nedb-1.8.0.tgz", - "integrity": "sha1-DjUCzYLABNU1WkPJ5VV3vXvZHYg=", - "requires": { - "async": "0.2.10", - "binary-search-tree": "0.2.5", - "localforage": "^1.3.0", - "mkdirp": "~0.5.1", - "underscore": "~1.4.4" - } - }, "neo-async": { "version": "2.6.1", "resolved": "https://registry.npmjs.org/neo-async/-/neo-async-2.6.1.tgz", @@ -11109,6 +11050,11 @@ "wordwrap": "~0.0.2" }, "dependencies": { + "minimist": { + "version": "0.0.10", + "resolved": "https://registry.npmjs.org/minimist/-/minimist-0.0.10.tgz", + "integrity": "sha1-3j+YVD2/lggr5IrRoMfNqDYwHc8=" + }, "wordwrap": { "version": "0.0.3", "resolved": "https://registry.npmjs.org/wordwrap/-/wordwrap-0.0.3.tgz", @@ -11300,13 +11246,6 @@ "tar-fs": "^2.0.0", "tunnel-agent": "^0.6.0", "which-pm-runs": "^1.0.0" - }, - "dependencies": { - "minimist": { - "version": "1.2.0", - "resolved": "https://registry.npmjs.org/minimist/-/minimist-1.2.0.tgz", - "integrity": "sha1-o1AIsg9BOD7sH7kU9M1d95omQoQ=" - } } }, "prelude-ls": { @@ -11389,13 +11328,6 @@ "ini": "~1.3.0", "minimist": "^1.2.0", "strip-json-comments": "~2.0.1" - }, - "dependencies": { - "minimist": { - "version": "1.2.0", - "resolved": "https://registry.npmjs.org/minimist/-/minimist-1.2.0.tgz", - "integrity": "sha1-o1AIsg9BOD7sH7kU9M1d95omQoQ=" - } } }, "react-is": { @@ -11799,13 +11731,6 @@ "micromatch": "^3.1.4", "minimist": "^1.1.1", "walker": "~1.0.5" - }, - "dependencies": { - "minimist": { - "version": "1.2.0", - "resolved": "https://registry.npmjs.org/minimist/-/minimist-1.2.0.tgz", - "integrity": "sha1-o1AIsg9BOD7sH7kU9M1d95omQoQ=" - } } }, "sax": { @@ -12598,9 +12523,9 @@ } }, "underscore": { - "version": "1.4.4", - "resolved": "https://registry.npmjs.org/underscore/-/underscore-1.4.4.tgz", - "integrity": "sha1-YaajIBBiKvoHljvzJSA88SI51gQ=" + "version": "1.9.1", + "resolved": "https://registry.npmjs.org/underscore/-/underscore-1.9.1.tgz", + "integrity": "sha512-5/4etnCkd9c8gwgowi5/om/mYO5ajCaOgdzj/oW+0eQV9WxKBDZw5+ycmKmeaTXjInS/W0BzpGLo2xR2aBwZdg==" }, "unicode-canonical-property-names-ecmascript": { "version": "1.0.4", diff --git a/package.json b/package.json index 64aa840f3..cf9471289 100644 --- a/package.json +++ b/package.json @@ -43,7 +43,7 @@ "rimraf": "*", "semver": "*", "winston": "2.4.2", - "zigbee-herdsman": "0.6.18", + "zigbee-herdsman": "0.7.0", "zigbee-herdsman-converters": "11.1.4" }, "devDependencies": { diff --git a/test/controller.test.js b/test/controller.test.js index c5414374e..6a49d59f7 100644 --- a/test/controller.test.js +++ b/test/controller.test.js @@ -290,7 +290,7 @@ describe('Controller', () => { expect(MQTT.publish).toHaveBeenCalledWith("zigbee2mqtt/bulb/dummy-2", 'no', {"qos": 0, "retain": true}, expect.any(Function)); }); - it('Publish entity state with device information', async () => { + it('onlythis Publish entity state with device information', async () => { await controller.start(); settings.set(['mqtt', 'include_device_information'], true); MQTT.publish.mockClear(); diff --git a/test/deviceEvent.test.js b/test/deviceEvent.test.js index 5b5333a63..3d5ebf4f6 100644 --- a/test/deviceEvent.test.js +++ b/test/deviceEvent.test.js @@ -16,7 +16,7 @@ const mockOnEvent = jest.fn(); const mappedLivolo = zigbeeHerdsmanConverters.findByZigbeeModel(zigbeeHerdsman.devices.LIVOLO.modelID); mappedLivolo.onEvent = mockOnEvent; -describe('onlythis Device event', () => { +describe('Device event', () => { let controller; const device = zigbeeHerdsman.devices.LIVOLO; diff --git a/test/stub/zigbeeHerdsman.js b/test/stub/zigbeeHerdsman.js index fea612c25..883ecf190 100644 --- a/test/stub/zigbeeHerdsman.js +++ b/test/stub/zigbeeHerdsman.js @@ -85,10 +85,6 @@ class Device { getEndpoints() { return this.endpoints; } - - isType(type) { - return type === 'device'; - } } const returnDevices = []; @@ -140,23 +136,20 @@ const mock = { }, stop: jest.fn(), disableLED: jest.fn(), - getDevices: jest.fn().mockImplementation((query) => { - return Object.values(devices).filter((d) => returnDevices.length === 0 || returnDevices.includes(d.ieeeAddr)) + getDevices: jest.fn().mockImplementation(() => { + return Object.values(devices).filter((d) => returnDevices.length === 0 || returnDevices.includes(d.ieeeAddr)); }), - getDevice: jest.fn().mockImplementation((query) => { - return Object.values(devices).filter((d) => returnDevices.length === 0 || returnDevices.includes(d.ieeeAddr)) - .find((d) => { - return (!query.hasOwnProperty('ieeeAddr') || query.ieeeAddr === d.ieeeAddr) && - (!query.hasOwnProperty('type') || query.type === d.type); - }) + getDevicesByType: jest.fn().mockImplementation((type) => { + return Object.values(devices).filter((d) => returnDevices.length === 0 || returnDevices.includes(d.ieeeAddr)).filter((d) => d.type === type); + }), + getDeviceByIeeeAddr: jest.fn().mockImplementation((ieeeAddr) => { + return Object.values(devices).filter((d) => returnDevices.length === 0 || returnDevices.includes(d.ieeeAddr)).find((d) => d.ieeeAddr === ieeeAddr); }), getGroups: jest.fn().mockImplementation((query) => { return Object.values(groups); }), - getGroup: jest.fn().mockImplementation((query) => { - return Object.values(groups).find((g) => { - return (!query.hasOwnProperty('groupID') || g.groupID === query.groupID); - }) + getGroupByID: jest.fn().mockImplementation((groupID) => { + return Object.values(groups).find((d) => d.groupID === groupID); }), getPermitJoin: jest.fn().mockReturnValue(false), softReset: jest.fn(),