binding self setting prior to new setting

Discussions about Z-Way software and Z-Wave technology in general
Post Reply
jtylerhall
Posts: 11
Joined: 07 Feb 2013 17:59

binding self setting prior to new setting

Post by jtylerhall »

I'm not sure how to deal with this problem.

I'm using the bind function to build automation scripts.

For example, based on some input I dynamically construct a script that I store and load on the Z-way server. All of this works.

However, I'm finding that most of my bindings trigger multiple times and often times the previous value triggers first. Of course, I can generate a solution to handle this myself, since its all in the global namespace, however it seems like a bit of a hack to me.

I would expect, that if I bind a thermostat as follows.

zway.devices[4].instances[0].commandClasses[64].data.mode.bind(function(){
if(this.value==3){
zway.devices[10].instances[0].commandClasses[38].Set(255);
}
})
then when I set the thermostat to auto, the switch is turned on. This occurs correctly when changing from heat,cool or off to auto, or when changing from heat,cool or off to heat cool or off. But when changing from auto to heat,cool or off the switch still comes on.

in order to rule out the possibility that I was somehow triggering it myself multiple times I added some functions to record each time the binding is triggered. I then triggered from a url window only the switch coming on and noted that the switch, received updates to its commandClass[38].data.level 6 times, despite the set Command only being made once. Similarly, despite only 1 set call to the thermostats mode, setting it to mode=1 (cool), prior to setting to mode=1 triggered the binding to mode=3 (auto).

This seems like incorrect behavior to me. I understand the binding trigger multiple times if I were to make the set call multiple times with the same value, but I do not understand why the binding would set itself to its current value prior to setting itself to a new value.

Is this intended behavior or a bug? Either way I'll have to devise a way to make it work in its current state unless the most recent release candidate deals with it. Any advice in the matter would be appreciated.


User avatar
PoltoS
Posts: 7579
Joined: 26 Jan 2011 19:36

If you are changing the more

Post by PoltoS »

If you are changing the more from Z-Way, it will send Set and invalidate the value - this is a "value change" for bind() function. You an check this by also outputing the result of (this.invalidateTime > this.updateTime). Hence, you et the last value as "invalidated".

Then the Report comes back, you will get the value changed and updateTime updated - hence the value will be "valid".

So, you already know how to filter the first.

Also taki in mind that if you will manually change the mode (or from other device by Z-Wave), you will not have invalidate state, but will immediately receive unsolicited Report and get only one value change.
Post Reply