mirror of
https://github.com/Koenkk/zigbee2mqtt.git
synced 2026-10-22 05:52:20 +00:00
Support both DeviceID and FriendlyName in device control topic (#476)
This commit is contained in:
1 parent
61c4ff33e0
commit
1e7f985d4e
1 file changed
+3
-7
@@ -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);
|
||||
|
||||
Reference in new issue
Block a user