Z-Wave app: can't get power metering to work

Update
Adding this update a few months later in case it is helpful to those finding this in the future. Athom has improved the functionality of their built-in generic Z-Wave driver so that it now allows the use of both power and energy metering, and this is working great with my Zooz Zen15 switches. Even advanced flow triggers like detecting power changes instantly are working. I hope this means they have fixed the underlying issues I was having while trying to create my own app, but it also eliminates the need for me to create an app at all, so I won’t be trying to fix it. Thanks Athom!

Original post below

Hi Homeys,

(I have no idea if that’s how Homey fans refer to each other but I really hope so)

I am attempting to write an app to connect some of my Zooz Z-Wave devices to my Homey Pro (2023). There is not yet an official Zooz app yet, so I am happy to publish this app for others to use once it’s working (or add my drivers to another Zooz community app like the one by @Johan_Rossouw ), but have run into some difficulties.

The device I am trying to integrate first is the Zooz Zen15 Power Switch. This is a basic Z-Wave smart plug and the on-off function does actually work with the built-in generic driver, but I would like to enable energy metering and power-based flow triggering, of which the device should be capable. I have been able to get the device connected and on-off and energy metering functionality working, but can’t get the power metering to work.

It looks like it should be pretty simple - Athom provides easy-to-use abstractions for all the ZWave command classes. I used the Homey CLI to create a new Homey app and a new Z-Wave driver. I made a couple basic changes like updating the manufacturer and product IDs, and added a few lines of code to register the capabilities of the device following the model of several examples (here’s one for a Fibaro switch).

I also verified the advanced settings with the Zooz manual and they all seem identical to the default settings in Athom’s template.

The Homey app recognizes the capabilities claimed by the device driver and the energy metering seems to work, but no number is reported for power. The only hint I can find for why this might be is an error on the console output:

2023-09-29T03:42:34.278Z [err] [ManagerDrivers] [Driver:zen15-power-switch] [Device:4daffcc8-83db-4758-8c57-c1d70ccf20f5] CommandClass: SENSOR_MULTILEVEL in main node undefined

But I have no idea why SENSOR_MULTILEVEL would be undefined, if it works in all the examples and the other command classes seem to work fine. Anyone have any ideas on what I might be doing wrong here? Has anyone else gotten power metering to work in a custom app?

Here is my device.js file in case that is helpful to see.

Thanks,
JD

Hi,

Not possible yet. You’d make a request @ Athom support I guess.

Known issues:
Energy measuring for Shelly Wave 1PM/2PM not implemented. The library that Athom maintains for including Zwave devices has not been updated for a while and currently does not support Zwave command class METER V6. Therefor energy capabilities of the Shelly Wave 1PM/2PM have nog been implemented yet

.
Source (ignore the first sentence :stuck_out_tongue_winking_eye: ):

Thanks for the response! That is disappointing if that is really the cause - I assumed the problem is my code and not Athom lacking fundamental Z-Wave functionality.

Would that mean that there are NO Z-Wave smart plugs that can do power measuring, since they all (presumably) rely on the same ZWave libraries?

The Coolcam smart plugs do report.
image

Energy meter does not work with Athoms zwave driver for command class METER V6. Since the topic starter is a able to get power metering which probably uses the METER command class as well it’s not using V6. So this is not the reason he can not get it to work and is not the same as with the Shelly Qubino Wave devices.

1 Like

Thanks @wayupnorthguy for the example, and @Phuturist for the correction!

You are correct that I am using the METER command class, which actually seems to work for energy metering (can’t guarantee there aren’t errors but it is at least reporting a number and that number changes if I attach a load). For the Power metering (i.e. instantaneous power draw rather than cumulative) I am using the SENSOR_MULTILEVEL command class, which is the one that seems to cause problems. I am new to both Homey and Z-Wave programming, so I chose that based purely on example code - I will take some time this weekend to dig into the documentation and better understand the different command classes and how homey-zwavedriver implements them. Below is the relevant section of code - only the second registerCapability seems to have the error:

const { ZwaveDevice } = require('homey-zwavedriver');

class Zen15 extends ZwaveDevice {

  /**
   * onNodeInit is called when the device is initialized.
   */
  async onNodeInit() {
    this.log('Zooz Zen15 Power Switch has been initialized');

    this.registerCapability('onoff', 'SWITCH_BINARY');
    this.registerCapability('measure_power', 'SENSOR_MULTILEVEL');
    this.registerCapability('meter_power', 'METER');
  }

@Phuturist, since it seems like you have some experience with integrating zwave devices into Homey - have you successfully used the SENSOR_MULTILEVEL command class on any of your projects?

Sorry to disappoint you but I have next to zero experience myself. Recently added my first zwave devices only to find out that the Athom library for doing so is outdated and they don’t think it’s important enough to stay up to date. Go figure the issues they are having in trying to create a stable platform.

Ha, fair enough. Well thanks for the help anyway!

You may already know, but I would like to point out that in the latest experimental firmware the “Command Class Meter V6” for Z-Wave devices has been added.

Thanks for the heads up! I did not know that it had been integrated - after sinking several more hours into this and not getting it to work I eventually gave up. Maybe now I should give it another go.

I just noticed another note in the changelog for v10.1.0-rc.2:

Adds power measurement capabilities to unknown Z-Wave devices (if supported by the device).

So it’s possible this functionality might now work without a custom driver at all! I’m out of town for the next few weeks but I’ll play around with this in December and report back.

:+1:t2: