From 056bc8065722f2847a41dde2b0356994f8d53a94 Mon Sep 17 00:00:00 2001 From: Martin Murray Date: Fri, 5 Mar 2021 02:40:49 -0500 Subject: [PATCH] fix: show hex number along with the `unknown` strings (#801) * 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 --- lib/ZwaveClient.js | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/lib/ZwaveClient.js b/lib/ZwaveClient.js index 5754bb736d5..dd0cb0e9b04 100644 --- a/lib/ZwaveClient.js +++ b/lib/ZwaveClient.js @@ -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 || { @@ -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) }