From 1e7f985d4e40510f0659a52c23947598958a3a5c Mon Sep 17 00:00:00 2001 From: Stanislav Demydiuk Date: Tue, 30 Oct 2018 22:23:34 +0200 Subject: [PATCH] Support both DeviceID and FriendlyName in device control topic (#476) --- lib/extension/deviceCommand.js | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/lib/extension/deviceCommand.js b/lib/extension/deviceCommand.js index 7ab36eaa5..94223031d 100644 --- a/lib/extension/deviceCommand.js +++ b/lib/extension/deviceCommand.js @@ -42,15 +42,11 @@ class DeviceCommand { // Parse topic const hasPrefix = topic.match(setWithPrefixTopic); - const friendlyName = topic.split('/').slice(hasPrefix ? -3 : -2)[0]; + const deviceKey = topic.split('/').slice(hasPrefix ? -3 : -2)[0]; // Could be friendlyName or ieeeAddr const prefix = hasPrefix ? topic.split('/').slice(-2)[0] : ''; - // Map friendlyName to ieeeAddr. - const ieeeAddr = settings.getIeeAddrByFriendlyName(friendlyName); - if (!ieeeAddr) { - logger.error(`Cannot handle '${topic}' because ieeAddr of '${friendlyName}' cannot be found`); - return; - } + // Map friendlyName to ieeeAddr if possible. + const ieeeAddr = settings.getIeeAddrByFriendlyName(deviceKey) || deviceKey; // Get device const device = this.zigbee.getDevice(ieeeAddr);