Skip to content

Commit

Permalink
fix: convert nodeId to number in importConfig before calling API
Browse files Browse the repository at this point in the history
  • Loading branch information
osenft committed Feb 28, 2021
1 parent c2e3e82 commit de689df
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 de689df

Please sign in to comment.