From 2c8bccb4caec55e7bc9f1a596dd746969dcd3119 Mon Sep 17 00:00:00 2001 From: Thomas Maroschik Date: Mon, 22 Mar 2021 09:16:04 +0100 Subject: [PATCH] fix: use prefixed node.id in mqtt discovery topic (#920) --- lib/Gateway.js | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/lib/Gateway.js b/lib/Gateway.js index 01ba23cc2a8..eae11364241 100755 --- a/lib/Gateway.js +++ b/lib/Gateway.js @@ -676,8 +676,10 @@ function deviceInfo (node, nodeName) { * @param {string} nodeName Node name from getNodeName function * @returns The topic string for this device discovery */ -function getDiscoveryTopic (hassDevice, nodeName) { - return `${hassDevice.type}/${nodeName}/${hassDevice.object_id}/config` +function getDiscoveryTopic (hassDevice, nodeId) { + return `${hassDevice.type}/${NODE_PREFIX + nodeId}/${ + hassDevice.object_id + }/config` } /** @@ -1456,7 +1458,7 @@ Gateway.prototype.discoverDevice = function (node, hassDevice) { '_' + hassDevice.object_id - const discoveryTopic = getDiscoveryTopic(hassDevice, nodeName) + const discoveryTopic = getDiscoveryTopic(hassDevice, node.id) hassDevice.discoveryTopic = discoveryTopic // This configuration is not stored in nodes.json @@ -2157,7 +2159,7 @@ Gateway.prototype.discoverValue = function (node, vId) { '_' + utils.sanitizeTopic(valueId.id, true) - const discoveryTopic = getDiscoveryTopic(cfg, nodeName) + const discoveryTopic = getDiscoveryTopic(cfg, node.id) cfg.discoveryTopic = discoveryTopic cfg.values = cfg.values || []