From 6bbe738f91673e7775f3157cb1c01b707b83068b Mon Sep 17 00:00:00 2001 From: Koen Kanters Date: Fri, 7 May 2021 19:03:44 +0200 Subject: [PATCH] Fix controlling of different endpoint names in one message not working when endpoints have same ID. https://github.com/Koenkk/zigbee-herdsman-converters/pull/2545 --- lib/extension/publish.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/lib/extension/publish.js b/lib/extension/publish.js index d286a15f2..380f50500 100644 --- a/lib/extension/publish.js +++ b/lib/extension/publish.js @@ -163,6 +163,7 @@ class EntityPublish extends Extension { for (let [key, value] of entries) { let endpointName = topic.endpointName; let actualTarget = target; + let endpointOrGroupID = actualTarget.constructor.name == 'Group' ? actualTarget.groupID : actualTarget.ID; // When the key has a endpointName included (e.g. state_right), this will override the target. if (resolvedEntity.type === 'device' && key.includes('_')) { @@ -173,6 +174,7 @@ class EntityPublish extends Extension { const device = target.getDevice(); actualTarget = device.getEndpoint(definition.endpoint(device)[endpointName]); + endpointOrGroupID = endpointName; if (!actualTarget) { logger.error(`Device '${resolvedEntity.name}' has no endpoint '${endpointName}'`); continue; @@ -180,7 +182,6 @@ class EntityPublish extends Extension { } } - const endpointOrGroupID = actualTarget.constructor.name == 'Group' ? actualTarget.groupID : actualTarget.ID; if (!usedConverters.hasOwnProperty(endpointOrGroupID)) usedConverters[endpointOrGroupID] = []; const converter = converters.find((c) => c.key.includes(key));