Why is metric update triggered twice
Posted: 06 Jan 2015 00:55
When I register a handler in an automation module for changes in the level metrics of all devices using the following line:
The handler is called twice when I switch a binarySwitch via the Expert Interface. This is what ends up the logs:
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.
Code: Select all
self.controller.devices.on('change:metrics:level', self.handleDevUpdates);
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}