athombv / node-homey-zwavedriver

Generic class to map Z-Wave CommandClasses to Homey capabilities
https://athombv.github.io/node-homey-zwavedriver
GNU General Public License v3.0
6 stars 11 forks source link

Support for command class METER V6 #121

Open jghaanstra opened 1 year ago

jghaanstra commented 1 year ago

It seems the driver only supports up to METER command class V4. I'm supposed to integrate some new Shelly Zwave device that use METER command class V6 which is returning errors when doing this.registerCapability('meter_power', 'METER'); and this.registerCapability('measure_power', 'METER');

The errors are:

2023-07-26T18:07:04.756Z [err] [ManagerDrivers] [Driver:shelly_wave_1pm] [Device:8e8f8f94-054d-46f1-9c30-7743e777e1fa] Error: capability get command failed {
  capabilityId: 'meter_power',
  commandClassId: 'METER',
  parsedPayload: { Properties1: { 'Rate Type': 'Import', Scale: 0 }, 'Scale 2': 0 }
} TypeError [ERR_INVALID_ARG_TYPE]: The "byteLength" argument must be of type number. Received undefined
    at new NodeError (node:internal/errors:399:5)
    at validateNumber (node:internal/validators:178:11)
    at boundsError (node:internal/buffer:81:5)
    at Buffer.readIntBE (node:internal/buffer:447:3)
    at module.exports (/app/node_modules/homey-zwavedriver/lib/system/commandclasses/METER/index.js:65:50)
    at METER (/app/node_modules/homey-zwavedriver/lib/ZwaveDevice.js:10:61)
    at ShellyZwaveDevice._parseCommandClassPayload (/app/node_modules/homey-zwavedriver/lib/ZwaveDevice.js:615:24)
    at ShellyZwaveDevice._onReport (/app/node_modules/homey-zwavedriver/lib/ZwaveDevice.js:588:44)
    at ShellyZwaveDevice._getCapabilityValue (/app/node_modules/homey-zwavedriver/lib/ZwaveDevice.js:446:27)
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5) {
  code: 'ERR_INVALID_ARG_TYPE'
}

2023-07-29T18:25:01.373Z [err] [ManagerDrivers] [Driver:shelly_wave_1pm] [Device:8e8f8f94-054d-46f1-9c30-7743e777e1fa] Could not get capability value for capabilityId: meter_power TypeError [ERR_INVALID_ARG_TYPE]: The "byteLength" argument must be of type number. Received undefined
    at new NodeError (node:internal/errors:399:5)
    at validateNumber (node:internal/validators:178:11)
    at boundsError (node:internal/buffer:81:5)
    at Buffer.readIntBE (node:internal/buffer:447:3)
    at module.exports (/app/node_modules/homey-zwavedriver/lib/system/commandclasses/METER/index.js:65:50)
    at METER (/app/node_modules/homey-zwavedriver/lib/ZwaveDevice.js:10:61)
    at ShellyWave1PMDevice._parseCommandClassPayload (/app/node_modules/homey-zwavedriver/lib/ZwaveDevice.js:615:24)
    at ShellyWave1PMDevice._onReport (/app/node_modules/homey-zwavedriver/lib/ZwaveDevice.js:588:44)
    at ShellyWave1PMDevice._getCapabilityValue (/app/node_modules/homey-zwavedriver/lib/ZwaveDevice.js:446:27)
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5) {
  code: 'ERR_INVALID_ARG_TYPE'
}

The device is documented here: https://kb.shelly.cloud/knowledge-base/wave-1pm

jghaanstra commented 1 year ago

I tested the device with the developer tools. This is the output when the device is switched.

023-08-03T14:35:24.973Z | Node[6]: [COMMAND_CLASS_SWITCH_BINARY] {"Current Value (Raw)":{"type":"Buffer","data":[255]},"Current Value":"on/enable","Target Value (Raw)":{"type":"Buffer","data":[255]},"Target Value":"on/enable","Duration (Raw)":{"type":"Buffer","data":[0]},"Duration":"Already at the Target Value"}
2023-08-03T14:35:26.742Z | Node[6]: [COMMAND_CLASS_METER] {"Meter Type (Raw)":{"type":"Buffer","data":[33]},"Meter Type":33,"Properties1 (Raw)":{"type":"Buffer","data":[52]},"Properties1":{"Size":4,"Scale":2,"Precision":1},"Meter Value (Raw)":{"type":"Buffer","data":[0,0,0,61]},"Meter Value":{"type":"Buffer","data":[0,0,0,61]}}
2023-08-03T14:35:56.653Z | Node[6]: [COMMAND_CLASS_METER] {"Meter Type (Raw)":{"type":"Buffer","data":[33]},"Meter Type":33,"Properties1 (Raw)":{"type":"Buffer","data":[52]},"Properties1":{"Size":4,"Scale":2,"Precision":1},"Meter Value (Raw)":{"type":"Buffer","data":[0,0,0,146]},"Meter Value":{"type":"Buffer","data":[0,0,0,146]}}

Just a hunch, could it be that node-homey-zwavedriver is expecting parsed values in the report which arent present?