whizzosoftware / WZWave

A native Java library for interfacing with Z-Wave PC controllers
Eclipse Public License 1.0
33 stars 22 forks source link

Support for PAN11 Power seitch with energy meter #5

Closed Brimstedt closed 7 years ago

Brimstedt commented 7 years ago

Quite new to ZWave and WZWave, but managed to get my switch with meter running. According to some docs I found it was a multilevelsensor and a meter, so adding those commandclasses to BinaryPowerSwitch. It works for me and my device, but not sure if all Binary Power Switches are Meters ?

whizzosoftware commented 7 years ago

Hi Brimstedt,

Thank you for your contribution to WZWave. I've just reviewed your changes.

Your changes to ProductRegistry looks good!

As far as your change for BinaryPowerSwitch, if you take a look at the Binary Power Switch specific device class in the Z-Wave Device Class Specification (http://z-wave.sigmadesigns.com/wp-content/uploads/2016/08/SDS10242-29-Z-Wave-Device-Class-Specification.pdf) you will see the mandatory command classes are "all switch" (which I interpret to mean the Basic and Binary Switch command classes). It also mentions the "Protection" and "Clock" command classes are optional but recommended.

That would tell me that Binary Power Switches do not always have Meters and I know for certain they don't always have Multilevel Sensors since I have at least one Z-Wave device that reports itself as a binary power switch and doesn't report the MultilevelSensor command class. Therefore, it's not appropriate to add them for all binary power switches.

Having said that, you're device should have indicated that it had both the Meter and MultilevelSensor command classes when it was interviewed by WZWave. So, you should be able to call the getCommandClass() method on your ZWaveNode to obtain the MeterCommandClass and MultilevelSensorCommandClass objects and then call their getCurrentValue() and getValues() methods respectively.

So let me know if you want to create a new pull request without the BinaryPowerSwitch change or I can merge in the ProductRegistry and .gitignore updates manually.

Thanks again and let me know if you have any questions!

Brimstedt commented 7 years ago

Thanks for reviewing!

So, what you're telling me is I do not need to add the commandclasses in constructor of BinaryPowerSwitch: addCommandClass(MeterCommandClass.ID, new MeterCommandClass()); addCommandClass(MultilevelSensorCommandClass.ID, new MultilevelSensorCommandClass());

But should getCurrentValue() still remainor are there other ways to get the actual data?

br

whizzosoftware commented 7 years ago

None of the changes to BinaryPowerSwitch are needed.

You should be able to get the current device values by calling (where "node" below is the appropriate ZWaveNode):

node.getCommandClass(MeterCommandClass.ID).getCurrentValue() node.getCommandClass(MultilevelSensorCommandClass.ID).getValues()

Just make sure those calls are made after WZWave has interviewed the node (e.g. anytime during or after your listener's onZWaveNodeAdded() callback method is invoked).

coveralls commented 7 years ago

Coverage Status

Coverage decreased (-0.1%) to 58.81% when pulling 4d1659e781f21561c3ec0e7b6e68c0668dee2d0f on Brimstedt:master into 34b3cd99e48bf94fea10ef3fd974cefa809895e2 on whizzosoftware:master.