Why is metric update triggered twice

Discussions about Z-Way software and Z-Wave technology in general
Post Reply
Rklootwijk
Posts: 15
Joined: 05 Jan 2015 21:52

Why is metric update triggered twice

Post by Rklootwijk »

When I register a handler in an automation module for changes in the level metrics of all devices using the following line:

Code: Select all

self.controller.devices.on('change:metrics:level', self.handleDevUpdates);
The handler is called twice when I switch a binarySwitch via the Expert Interface. This is what ends up the logs:

Code: Select all

[2015-01-05 21:51:36.811] [I] [zway] Adding job: SwitchBinary Set
[2015-01-05 21:51:36.812] [I] [zway] Adding job: SwitchBinary Get
[2015-01-05 21:51:36.840] [I] [zway] Job 0x13 (SwitchBinary Set): Delivered
[2015-01-05 21:51:36.842] [I] [zway] Removing job: SwitchBinary Set
[2015-01-05 21:51:36.849] [I] [core] IHouseEventForwarder: Device update {"creatorId":4,"deviceType":"switchBinary","id":"ZWayVDev_zway_2-6-37","location":null,"metrics":{"icon":"switch","title":"Switch 2-6","level":"on"},"permanently_hidden":false,"tags":[],"updateTime":1420494696}
[2015-01-05 21:51:36.927] [I] [zway] Job 0x13 (SwitchBinary Get): Delivered
[2015-01-05 21:51:36.928] [I] [zway] Removing job: SwitchBinary Get
[2015-01-05 21:51:36.958] [I] [core] IHouseEventForwarder: Device update {"creatorId":4,"deviceType":"switchBinary","id":"ZWayVDev_zway_2-6-37","location":null,"metrics":{"icon":"switch","title":"Switch 2-6","level":"off"},"permanently_hidden":false,"tags":[],"updateTime":1420494696}
The IHouseEventForwarder line is logged from within my handler. The first time the handler is called it is with the current value of the switch, the second time it is with the new value of the switch. I would expect the handler is only called with the new value of the switch.
User avatar
PoltoS
Posts: 7649
Joined: 26 Jan 2011 19:36

Re: Why is metric update triggered twice

Post by PoltoS »

Can you show arguments it was triggered with? What was in the type of event? on which DH are you listening on?
Rklootwijk
Posts: 15
Joined: 05 Jan 2015 21:52

Re: Why is metric update triggered twice

Post by Rklootwijk »

It is all in the logs, I log the complete vDev object. When I turn off a powerswitch the first time it triggers the object is:

Code: Select all

{"creatorId":4,"deviceType":"switchBinary","id":"ZWayVDev_zway_2-6-37","location":null,"metrics":{"icon":"switch","title":"Switch 2-6","level":"on"},"permanently_hidden":false,"tags":[],"updateTime":1420494696}
and the second time:

Code: Select all

{"creatorId":4,"deviceType":"switchBinary","id":"ZWayVDev_zway_2-6-37","location":null,"metrics":{"icon":"switch","title":"Switch 2-6","level":"off"},"permanently_hidden":false,"tags":[],"updateTime":1420494696}
I now notice that on a switch which does not report its state automatically but needs to be polled (Greenwave Powerbar) the behaviour is as described above. On a switch that reports its state automatically AN158, the trigger occurs 3 times, the first time with the current value and then two times with the new value.

What do you mean by DH?
User avatar
PoltoS
Posts: 7649
Joined: 26 Jan 2011 19:36

Re: Why is metric update triggered twice

Post by PoltoS »

DH is DataHolder in Z-Way (one level lower). I believe this is because Get invalidate the DH and this propagates to the Z-Way HA level. We will fix this.

https://github.com/Z-Wave-Me/home-autom ... /issues/63
Rklootwijk
Posts: 15
Joined: 05 Jan 2015 21:52

Re: Why is metric update triggered twice

Post by Rklootwijk »

Great!

I have found also a bug in the expert ui. When I go to the sensor and meter view of a Greenwave Power bar the sensor and meter linked to each outlet shows the correct value. However, when you do an update, all sensors and meters are showing the same value. See the attached screenshots.
Attachments
Meter initial view
Meter initial view
Screen Shot 2015-01-07 at 09.06.51.png (147.31 KiB) Viewed 11057 times
Sensor view after update
Sensor view after update
Screen Shot 2015-01-07 at 09.06.41.png (131.02 KiB) Viewed 11057 times
Sensor initial view
Sensor initial view
Screen Shot 2015-01-07 at 09.06.16.png (131.17 KiB) Viewed 11057 times
pz1
Posts: 2053
Joined: 08 Apr 2012 13:44

Re: Why is metric update triggered twice

Post by pz1 »

I can confirm the update error in new export UI for both my Fibaro Universal Sensors. Old Expert UI displays them correctly
Since 29-12-2016 I am no longer a moderator for this forum
User avatar
PoltoS
Posts: 7649
Joined: 26 Jan 2011 19:36

Re: Why is metric update triggered twice

Post by PoltoS »

Pieter, please suggest how to reproduce with some more common device than GreenWave (we don't have it)
pz1
Posts: 2053
Joined: 08 Apr 2012 13:44

Re: Why is metric update triggered twice

Post by pz1 »

Well I have two of these Fibaro Universal sensors with four temperature sensors each. When I first go to the new expert interface to Control/Sensors, all eight sensors display the same values as in the old expert UI. The problem arises with the update buttons from the new user interface.
If I push update on a random one of the four sensors, this one get a new value, but the other three do get that same value assigned. Behaviour is the same with the other FUS all get a new value, but the value sets are different at both FUS devices. The old Expert UI does not show this behaviour

I do have Fibaro Wall plug which lets the Wattage display as Power and Electric levels are different quite often. I only checked once just now. They don't seem to have that behaviour.
Hope this helps
Since 29-12-2016 I am no longer a moderator for this forum
Rklootwijk
Posts: 15
Joined: 05 Jan 2015 21:52

Re: Why is metric update triggered twice

Post by Rklootwijk »

The row id of all rows in the sensor and meter views is wrong. It is Meter_undefined_x where x is the nodeId. In htdocs/expert/app/controllers/controllers.js the rowId is calculated as follows: meters.name + '_' + meter.name + '_' + k. However meter.name does not exist.
Post Reply