Skip to content

Commit

Permalink
fix: bug when importing nodes.json (#768)
Browse files Browse the repository at this point in the history
  • Loading branch information
osenft authored Mar 1, 2021
1 parent 2f42da3 commit 84550f2
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions app.js
Original file line number Diff line number Diff line change
Expand Up @@ -723,16 +723,18 @@ app.post('/api/importConfig', apisLimiter, isAuthenticated, async function (
const node = config[nodeId]
if (!node || typeof node !== 'object') continue

// All API calls expect nodeId to be a number, so convert it here.
const nodeIdNumber = Number(nodeId)
if (utils.hasProperty(node, 'name')) {
await gw.zwave.callApi('setNodeName', nodeId, node.name || '')
await gw.zwave.callApi('setNodeName', nodeIdNumber, node.name || '')
}

if (utils.hasProperty(node, 'loc')) {
await gw.zwave.callApi('setNodeLocation', nodeId, node.loc || '')
await gw.zwave.callApi('setNodeLocation', nodeIdNumber, node.loc || '')
}

if (node.hassDevices) {
await gw.zwave.storeDevices(node.hassDevices, nodeId, false)
await gw.zwave.storeDevices(node.hassDevices, nodeIdNumber, false)
}
}

Expand Down

0 comments on commit 84550f2

Please sign in to comment.