Skip to content

Commit

Permalink
fix: correclty parse durations
Browse files Browse the repository at this point in the history
Fixes #185
  • Loading branch information
robertsLando committed Jan 12, 2021
1 parent af41778 commit 595b97e
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions lib/ZwaveClient.js
Original file line number Diff line number Diff line change
Expand Up @@ -909,6 +909,8 @@ function parseValue (zwaveNode, zwaveValue, zwaveValueMeta) {
}
}

parseDurations(valueId)

node.values[vID] = valueId

return valueId
Expand All @@ -932,6 +934,8 @@ function updateValue (zwaveNode, args) {
valueId.value = args.newValue
valueId.stateless = !!args.stateless

parseDurations(valueId)

this.emit('valueChanged', valueId, node, args.prevValue !== args.newValue)

const self = this
Expand Down Expand Up @@ -982,6 +986,16 @@ function parseNotification (parameters) {
}
}

function parseDurations (valueId) {
// support for duration valueIds
if (valueId.value instanceof Duration) {
valueId.type = 'number'
valueId.isDuration = true
valueId.unit = valueId.value.unit
valueId.value = valueId.value.value
}
}

/**
* Get the device id of a specific node
*
Expand Down

0 comments on commit 595b97e

Please sign in to comment.