Skip to content

Commit

Permalink
fix: read only list values in UI and better logging (#102)
Browse files Browse the repository at this point in the history
* fix: undefined values

* fix: add more logging

* fix(ui): show read only list values
  • Loading branch information
robertsLando authored Dec 22, 2020
1 parent ffa300b commit 03f5610
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 8 deletions.
2 changes: 1 addition & 1 deletion app.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
8 changes: 5 additions & 3 deletions lib/ZwaveClient.js
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down Expand Up @@ -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}`
Expand All @@ -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,
Expand Down Expand Up @@ -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 (
Expand Down
1 change: 1 addition & 0 deletions src/components/ControlPanel.vue
Original file line number Diff line number Diff line change
Expand Up @@ -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])
Expand Down
9 changes: 5 additions & 4 deletions src/components/ValueId.vue
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<template>
<div v-if="!value.writeable">
<div v-if="!value.writeable && !value.list">
<v-text-field
:label="value.label + ' (' + value.id + ')'"
readonly
Expand All @@ -18,11 +18,11 @@
value.type === 'any')
"
:label="value.label + ' (' + value.id + ')'"
:type="value.type === 'string' ? 'text' : 'number'"
:type="value.type === 'number' ? 'number' : 'text'"
:append-outer-icon="!disable_send ? 'send' : null"
:suffix="value.units"
:min="value.min != value.max ? value.min : null"
:step="value.type == 'decimal' ? 0.1 : 1"
:step="1"
:max="value.min != value.max ? value.max : null"
:hint="value.description || ''"
v-model="value.newValue"
Expand All @@ -34,8 +34,9 @@
:items="value.states"
:label="value.label + ' (' + value.id + ')'"
:hint="value.description || ''"
:append-outer-icon="!disable_send ? 'send' : null"
:append-outer-icon="!disable_send || value.writeable ? 'send' : null"
v-model="value.newValue"
:readonly="!value.writeable"
@click:append-outer="updateValue(value)"
></v-select>

Expand Down

0 comments on commit 03f5610

Please sign in to comment.