mirror of
https://github.com/Koenkk/zigbee2mqtt.git
synced 2026-09-01 16:48:31 +00:00
Support both DeviceID and FriendlyName in device control topic (#476)
This commit is contained in:
committed by
Koen Kanters
parent
61c4ff33e0
commit
1e7f985d4e
@@ -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