Skip to content

Commit

Permalink
fix: writeValue logs undefined valueId
Browse files Browse the repository at this point in the history
  • Loading branch information
robertsLando committed Dec 23, 2020
1 parent 03f5610 commit e1bcbcb
Showing 1 changed file with 9 additions and 9 deletions.
18 changes: 9 additions & 9 deletions lib/ZwaveClient.js
Original file line number Diff line number Diff line change
Expand Up @@ -761,7 +761,7 @@ function removeValue (zwaveNode, args) {
/**
* Get the device id of a specific node
*
* @param {Object} node Internal node object
* @param {any} node Internal node object
* @returns A string in the format `<manufacturerId>-<productId>-<producttype>` that unique identifhy a zwave device
*/
function getDeviceID (node) {
Expand Down Expand Up @@ -789,8 +789,8 @@ function findTargetValue (zwaveValue, definedValueIds) {
/**
* Get a valueId from a valueId object
*
* @param {Object} v Zwave valueId object
* @param {Boolean} nodeId Add node identifier
* @param {any} v Zwave valueId object
* @param {boolean} nodeId Add node identifier
* @returns The value id unique identifier
*/
function getValueID (v, withNode) {
Expand Down Expand Up @@ -933,9 +933,9 @@ ZwaveClient.prototype.heal = function () {
/**
* Used to Update an hass device of a specific node
*
* @param {Object} hassDevice The Hass device
* @param {Integer} nodeId The nodeid
* @param {Boolean} deleteDevice True to remove the hass device from node hass devices
* @param {any} hassDevice The Hass device
* @param {number} nodeId The nodeid
* @param {boolean} deleteDevice True to remove the hass device from node hass devices
*/
ZwaveClient.prototype.updateDevice = function (
hassDevice,
Expand Down Expand Up @@ -1890,7 +1890,7 @@ ZwaveClient.prototype.callApi = async function (apiName, ...args) {
*/
ZwaveClient.prototype.writeValue = async function (valueId, value) {
if (this.driverReady) {
logger.info(`Writing ${value} to ${valueId.id}`)
logger.info(`Writing ${value} to ${getValueID(valueId)}`)

let result = false

Expand Down Expand Up @@ -1923,13 +1923,13 @@ ZwaveClient.prototype.writeValue = async function (valueId, value) {
}
} catch (error) {
logger.error(
`Error while writing ${value} on ${valueId.id}: ${error.message}`,
`Error while writing ${value} on ${getValueID(valueId)}: ${error.message}`,
error
)
}
// https://zwave-js.github.io/node-zwave-js/#/api/node?id=setvalue
if (result === false) {
logger.error(`Unable to write ${value} on ${valueId.id}`)
logger.error(`Unable to write ${value} on ${getValueID(valueId)}`)
}
}
}
Expand Down

0 comments on commit e1bcbcb

Please sign in to comment.