Skip to content

Commit

Permalink
feat: getNodes api to get nodes array fix #281
Browse files Browse the repository at this point in the history
  • Loading branch information
robertsLando committed Mar 2, 2020
1 parent 622d240 commit cccd17e
Showing 1 changed file with 5 additions and 8 deletions.
13 changes: 5 additions & 8 deletions lib/ZwaveClient.js
Original file line number Diff line number Diff line change
Expand Up @@ -386,13 +386,6 @@ function valueAdded (nodeid, comclass, valueId) {
debug('ValueAdded: %s %s', valueId.value_id, valueId.label)
var id = getValueID(valueId)

// if (valueId.type === 'list') {
// for (let i = 0; i < valueId.values.length; i++) {
// let fix = valueId.values[i].indexOf('|') >= 0
// if (fix) valueId.values[i] = valueId.values[i].split('|').pop()
// }
// }

ozwnode.values[id] = valueId

if (comclass === 0x86) { // version
Expand Down Expand Up @@ -1146,6 +1139,10 @@ ZwaveClient.prototype._activateScene = function (sceneId) {
return true
}

ZwaveClient.prototype.getNodes = function () {
return this.nodes
}

/**
* Calls a specific `client` or `ZwaveClient` method based on `apiName`
* ZwaveClients methods used are the ones that overrides default Zwave methods
Expand All @@ -1171,7 +1168,7 @@ ZwaveClient.prototype.callApi = async function (apiName, ...args) {
}

// Check if I need to call a zwave client function or a custom function
var useCustom = typeof this[apiName] === 'function' && ((apiName.toLowerCase().includes('scene') && apiName.startsWith('_')) || apiName === '_setNodeName' || apiName === '_setNodeLocation' || apiName === 'refreshNeighborns')
var useCustom = typeof this[apiName] === 'function' && ((apiName.toLowerCase().includes('scene') && apiName.startsWith('_')) || apiName === '_setNodeName' || apiName === '_setNodeLocation' || apiName === 'refreshNeighborns' || apiName === 'getNodes')

// Send raw data expects a buffer as the fifth argument, which JSON does not support, so we convert an array of bytes into a buffer.
if (apiName === 'sendRawData') {
Expand Down

0 comments on commit cccd17e

Please sign in to comment.