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

This commit is contained in:
Koen Kanters committed 2021-05-07 19:03:44 +02:00
1 parent a893cac951
commit 6bbe738f91
1 file changed
+2 -1
+2 -1
View File
@@ -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));