From 2595701ca933c16247b0057d500805b209651344 Mon Sep 17 00:00:00 2001 From: Daniel Lando Date: Fri, 26 Mar 2021 08:24:10 +0100 Subject: [PATCH] fix: revert PR #920 "use prefixed node.id in mqtt discovery topic" (#951) --- lib/Gateway.js | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/lib/Gateway.js b/lib/Gateway.js index 62b2b76c99d..cb85f0bf56b 100755 --- a/lib/Gateway.js +++ b/lib/Gateway.js @@ -668,10 +668,8 @@ function deviceInfo (node, nodeName) { * @param {string} nodeName Node name from getNodeName function * @returns The topic string for this device discovery */ -function getDiscoveryTopic (hassDevice, nodeId) { - return `${hassDevice.type}/${NODE_PREFIX + nodeId}/${ - hassDevice.object_id - }/config` +function getDiscoveryTopic (hassDevice, nodeName) { + return `${hassDevice.type}/${nodeName}/${hassDevice.object_id}/config` } /** @@ -1450,7 +1448,7 @@ Gateway.prototype.discoverDevice = function (node, hassDevice) { '_' + hassDevice.object_id - const discoveryTopic = getDiscoveryTopic(hassDevice, node.id) + const discoveryTopic = getDiscoveryTopic(hassDevice, nodeName) hassDevice.discoveryTopic = discoveryTopic // This configuration is not stored in nodes.json @@ -2151,7 +2149,7 @@ Gateway.prototype.discoverValue = function (node, vId) { '_' + utils.sanitizeTopic(valueId.id, true) - const discoveryTopic = getDiscoveryTopic(cfg, node.id) + const discoveryTopic = getDiscoveryTopic(cfg, nodeName) cfg.discoveryTopic = discoveryTopic cfg.values = cfg.values || []