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()
event handling
No, it is not possible, but
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])
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])
Thank you very, very much!
Thank you very, very much!
Re: event handling
Hi,
I test this but I can not get inclusion/exclusion event, it's normal ? How can I get this ?
I test this but I can not get inclusion/exclusion event, it's normal ? How can I get this ?