Skip to content

Commit

Permalink
fix: show hex number along with the unknown strings (#801)
Browse files Browse the repository at this point in the history
* Use hex for unknown manufacturer, product IDs in UI

* Add missing 0x prefix to hexadecimal output

* Use existing hex formatting method instead.

* refactor: rearrange to reuse existing values

Per request from @robertsLando, evaluation of hexIds is moved above
the initialization of deviceConfig. Backtick templates used to generate
labels in place of string concatenation to remain consistent with
surrounding code.

Co-authored-by: Daniel Lando <[email protected]>
  • Loading branch information
murrayma and robertsLando authored Mar 5, 2021
1 parent 561ac3e commit 056bc80
Showing 1 changed file with 11 additions and 11 deletions.
22 changes: 11 additions & 11 deletions lib/ZwaveClient.js
Original file line number Diff line number Diff line change
Expand Up @@ -866,10 +866,18 @@ function initNode (zwaveNode) {

const node = this.nodes.get(nodeId)

const hexIds = [
utils.num2hex(zwaveNode.manufacturerId),
utils.num2hex(zwaveNode.productId),
utils.num2hex(zwaveNode.productType)
]
node.hexId = `${hexIds[0]}-${hexIds[2]}-${hexIds[1]}`
node.dbLink = `https://devices.zwave-js.io/?jumpTo=${hexIds[0]}:${hexIds[2]}:${hexIds[1]}:${node.firmwareVersion}`

const deviceConfig = zwaveNode.deviceConfig || {
label: 'Unknown product ' + zwaveNode.productId,
description: zwaveNode.productType,
manufacturer: 'Unknown manufacturer ' + zwaveNode.manufacturerId
label: `Unknown product ${hexIds[1]}`,
description: hexIds[2],
manufacturer: `Unknown manufacturer ${hexIds[0]}`
}

const deviceClass = zwaveNode.deviceClass || {
Expand Down Expand Up @@ -928,14 +936,6 @@ function initNode (zwaveNode) {

node.deviceId = getDeviceID(node)

const hexIds = [
utils.num2hex(node.manufacturerId),
utils.num2hex(node.productId),
utils.num2hex(node.productType)
]
node.hexId = `${hexIds[0]}-${hexIds[2]}-${hexIds[1]}`
node.dbLink = `https://devices.zwave-js.io/?jumpTo=${hexIds[0]}:${hexIds[2]}:${hexIds[1]}:${node.firmwareVersion}`

this.getGroups(zwaveNode.id, true)
}

Expand Down

0 comments on commit 056bc80

Please sign in to comment.