UserModule change:metrics:level

Discussions about Z-Way software and Z-Wave technology in general
Post Reply
Isaksson
Posts: 133
Joined: 10 Apr 2013 09:43

UserModule change:metrics:level

Post by Isaksson »

Hello.

This is something that i find strange.

I add a listener for change:metrics:level

Code: Select all

this.controller.devices.on(this.config.device, 'change:metrics:level', this.handler);
and a handler

Code: Select all

this.handler = function (vDev) {
        var value = vDev.get("metrics:level");
   
    };
This will not only get called on change of the device status.
If I in the expert GUI change the state for the device that i am listening to then i will get two responses, first the value the device had and then the value it became.
This means if the device was On and a changed it in GUI to Off then i will get this
value = On
value = Off

And my listener also get called every time i push the update for that device in Expert GUI.

So my question is, what should i listen on to only get the actual change of an device and not every update on same state?
User avatar
PoltoS
Posts: 7649
Joined: 26 Jan 2011 19:36

Re: UserModule change:metrics:level

Post by PoltoS »

This listener is called every time the value is updated. Even if it was same, the value is updated. You can save previous value and compare if you need it.
Isaksson
Posts: 133
Joined: 10 Apr 2013 09:43

Re: UserModule change:metrics:level

Post by Isaksson »

Is there a good reason why it triggers twice both with old and new value if update with expert GUI?
User avatar
PoltoS
Posts: 7649
Joined: 26 Jan 2011 19:36

Re: UserModule change:metrics:level

Post by PoltoS »

may be first time the Z-Wave value is "invalidated" and that also triggers an update in HA?
Post Reply