event handling

Discussions about RaZberry - Z-Wave board for Raspberry computer
krambriw
Posts: 46
Joined: 03 Apr 2013 18:14

I figured out,,,,

Post by krambriw »

that 2) is like

system("python /home/pi/Desktop/network_send.py", this.value, arg2, arg3 etc);

For nbr 1) I meant something like

zway.devices[*].instances[*].*.data.level.bind(function()

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

No, it is not possible, but

Post by PoltoS »

No, it is not possible, but you can do instead:var cbk = function(type, arg) {
var val = this.value;
...
};

function attachToDataHolder(element) {
element.bind(cbk);
for (var key in element) {
if (element[key] && element[key].name !== undefined) {
// this is a child element - descend inside
attachToDataHolder(element[key]);
}
}
}

for (var devId in zway.devices) {
var dev = zway.devices[devId];
attachToDataHolder(dev.data);
for (var instId in dev.instances) {
var inst = dev.instances[instId];
attachToDataHolder(inst.data);
for (var ccId in inst.commandClasses) {
var cc = inst.commandClasses[ccId];
attachToDataHolder(cc.data);
}
}
}This code crosses all data holder elements of all devices, instances and command classes to bind one single functions for all.Instead of doing attachToDataHolder() function recursive it is much better to use a flag to bind: function attachToDataHolder(element) {
element.bind(cbk, null, true); // watch this element and children
}The type in cbk() function can be tested to be from child element (type & 0x80), but the this object will still refer to the root data tree, so you will need to check update/invalidate time to know which element was updated. This is certainly to be changed to return the changed object in this object.To be able to attach to newly added devices usezway.bind(function(type, nodeId, instanceId, commandClassId) {}, [mask = 0xffff])
krambriw
Posts: 46
Joined: 03 Apr 2013 18:14

Thank you very, very much!

Post by krambriw »

Thank you very, very much!
zoic22
Posts: 45
Joined: 04 Apr 2014 14:21

Re: event handling

Post by zoic22 »

Hi,

I test this but I can not get inclusion/exclusion event, it's normal ? How can I get this ?
Post Reply