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));