Page 1 of 1

UserModule change:metrics:level

Posted: 29 Jun 2015 22:39
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?

Re: UserModule change:metrics:level

Posted: 30 Jun 2015 02:07
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.

Re: UserModule change:metrics:level

Posted: 30 Jun 2015 09:05
by Isaksson
Is there a good reason why it triggers twice both with old and new value if update with expert GUI?

Re: UserModule change:metrics:level

Posted: 01 Jul 2015 04:38
by PoltoS
may be first time the Z-Wave value is "invalidated" and that also triggers an update in HA?