source of a bind() information push

Discussions about Z-Way software and Z-Wave technology in general
Post Reply
dirkx
Posts: 13
Joined: 03 Nov 2013 20:52

source of a bind() information push

Post by dirkx »

I have a number of devices that sent out temperature updates/sets - that I'd like to run some code on (a PID controller and a calendar based override).

What is the proper way to get the zDeviceID et.al. ? The naive code below is obviously not working ?

Thanks,

Dw.

PS: Also wondering if there is a way to trigger z-way to reload a *.js file (and give line numbers for errors) on the fly.


// File: /opt/z-way-server/automation/test.js
//
for(var i =2; i < 10; i++) {
console.log("registering "+i);
zway.devices.instances[0].ThermostatSetPoint.data[1].val.bind(function () {
console.log("Device ?? got set to " + this);
});
zway.devices.instances[0].SensorMultilevel.data[1].val.bind(function (somearg) {
console.log("Device "+somearg+" read value " + this);
});
}
// Does not yet exit this early?
// zway.dataUpdate.bind(function(a,b,c,d) { console.log("Some dataUpate "+a+"/"+b+"/"+c+"/"+d+" = "+this); });

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

New 1.4.1 release provides

Post by PoltoS »

New 1.4.1 release provides lines and stack trace for errors.


You need to add one more param to the second bind() that will be passed as somearg in your function.

Also make sure that all devices from 2 to 9 contains ThermostatSetPoint and SensorMutilevel, otherwise the code will fail.
dirkx
Posts: 13
Joined: 03 Nov 2013 20:52

Thanks!

Post by dirkx »

That works most splendidly. The second (and in case of a set, third/this) argument are the device ID passed during registration and the temperature in case of a SET.

What is the first argument passed ? An argument count ?
User avatar
PoltoS
Posts: 7586
Joined: 26 Jan 2011 19:36

No, it is type of change (see

Post by PoltoS »

No, it is type of change (see C headers to find them out - search for "Phantom" word)
Post Reply