Skip to content

Commit

Permalink
fix: revert PR #920 "use prefixed node.id in mqtt discovery topic" (#951
Browse files Browse the repository at this point in the history
)
  • Loading branch information
robertsLando authored Mar 26, 2021
1 parent d6098c1 commit 2595701
Showing 1 changed file with 4 additions and 6 deletions.
10 changes: 4 additions & 6 deletions lib/Gateway.js
Original file line number Diff line number Diff line change
Expand Up @@ -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`
}

/**
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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 || []
Expand Down

0 comments on commit 2595701

Please sign in to comment.