From 03f56107d8ef5163d7c67dba5bc41b6ab48ec8e6 Mon Sep 17 00:00:00 2001 From: Daniel Lando Date: Tue, 22 Dec 2020 14:34:02 +0100 Subject: [PATCH] fix: read only list values in UI and better logging (#102) * fix: undefined values * fix: add more logging * fix(ui): show read only list values --- app.js | 2 +- lib/ZwaveClient.js | 8 +++++--- src/components/ControlPanel.vue | 1 + src/components/ValueId.vue | 9 +++++---- 4 files changed, 12 insertions(+), 8 deletions(-) diff --git a/app.js b/app.js index 9d0c3fe9a98..b2541c816f9 100644 --- a/app.js +++ b/app.js @@ -170,7 +170,7 @@ function setupSocket (server) { }) socketManager.on(inboundEvents.zwave, async function (socket, data) { - logger.info(`Zwave api call: ${data.api} ${data.args}`) + logger.info(`Zwave api call: ${data.api} ${JSON.stringify(data.args)}`) if (gw.zwave) { const result = await gw.zwave.callApi(data.api, ...data.args) result.api = data.api diff --git a/lib/ZwaveClient.js b/lib/ZwaveClient.js index 952cb771552..455c1b6393c 100644 --- a/lib/ZwaveClient.js +++ b/lib/ZwaveClient.js @@ -423,7 +423,7 @@ function onNodeValueRemoved (zwaveNode, args) { } function onNodeMetadataUpdated (zwaveNode, args) { - const valueId = initValue.call(this, zwaveNode, args, args.metadata) + const valueId = parseValue.call(this, zwaveNode, args, args.metadata) logger.info(`Node ${valueId.nodeId}: metadata updated: ${getValueID(args)}`) this.emit( 'event', @@ -691,7 +691,7 @@ function addValue (zwaveNode, zwaveValue) { } else { const zwaveValueMeta = zwaveNode.getValueMetadata(zwaveValue) - const valueId = initValue.call(this, zwaveNode, zwaveValue, zwaveValueMeta) + const valueId = parseValue.call(this, zwaveNode, zwaveValue, zwaveValueMeta) logger.info( `Node ${zwaveNode.id}: value added ${valueId.id} => ${valueId.value}` @@ -701,7 +701,7 @@ function addValue (zwaveNode, zwaveValue) { } } -function initValue (zwaveNode, zwaveValue, zwaveValueMeta) { +function parseValue (zwaveNode, zwaveValue, zwaveValueMeta) { const node = this.nodes[zwaveNode.id] const valueId = updateValueMetadata.call( this, @@ -1890,6 +1890,8 @@ ZwaveClient.prototype.callApi = async function (apiName, ...args) { */ ZwaveClient.prototype.writeValue = async function (valueId, value) { if (this.driverReady) { + logger.info(`Writing ${value} to ${valueId.id}`) + let result = false if ( diff --git a/src/components/ControlPanel.vue b/src/components/ControlPanel.vue index 5ccae14f747..df92f35380e 100644 --- a/src/components/ControlPanel.vue +++ b/src/components/ControlPanel.vue @@ -1329,6 +1329,7 @@ export default { }, initNode (n) { var values = [] + // transform object in array for (var k in n.values) { n.values[k].newValue = n.values[k].value values.push(n.values[k]) diff --git a/src/components/ValueId.vue b/src/components/ValueId.vue index 13569dac78d..220a9159abe 100644 --- a/src/components/ValueId.vue +++ b/src/components/ValueId.vue @@ -1,5 +1,5 @@