Using UDP datagrams to send status updates

Discussions about RaZberry - Z-Wave board for Raspberry computer
pz1
Posts: 2053
Joined: 08 Apr 2012 13:44

Re: Using UDP datagrams to send status updates

Post by pz1 » 07 Dec 2014 15:07

You are absolutely right. I double checked with my running code.
A closing bracket has not survived a recent editing operation in the Recipe
viewtopic.php?f=3424&t=20849&p=53205#p53205
Has been corected now. Thanks.
Since 29-12-2016 I am no longer a moderator for this forum

hpd
Posts: 34
Joined: 20 Mar 2014 12:03

Re: Using UDP datagrams to send status updates

Post by hpd » 07 Dec 2014 18:51

Thanks!

Btw. I appreciate your continous effort for this forum.
Z-Way 2.0.0-final on Raspberry Pi

pz1
Posts: 2053
Joined: 08 Apr 2012 13:44

Re: Using UDP datagrams to send status updates

Post by pz1 » 09 Dec 2014 11:43

Since my upgrade from rc30 to final v2.0.0 it seems that my javascript code is is no longer working can´t find any trace of the file name in the logs. And of course openremote sensors are no longer updated. The image below shows all selected modules
SelectedModules.PNG
SelectedModules.PNG (13.98 KiB) Viewed 6295 times
Attachments
z-way-log.zip
(458.34 KiB) Downloaded 214 times
Since 29-12-2016 I am no longer a moderator for this forum

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

Re: Using UDP datagrams to send status updates

Post by PoltoS » 09 Dec 2014 12:02

I don't see your code, but it might be that it looks only on creation of zway instance (and not on already running), you you should remove Z-Wave Binding and add it after UDP listener. Your code needs to be updated a bit to work in all cases

digitaldan
Posts: 11
Joined: 11 Sep 2014 18:53

Re: Using UDP datagrams to send status updates

Post by digitaldan » 09 Dec 2014 19:13

I use the following code to register my function "registerBinding" during boot up or if the file is loaded while zway is running, so far so good:

Code: Select all

this.regesterBinding = function(zwayName) {
  if (zwayName != "zway") return;
  debugPrint("Binding enabled");
}

if(typeof global.ZWave == 'undefined'){
  global.controller.on("ZWave.register", this.regesterBinding);
} else {
  this.regesterBinding("zway");
}

pz1
Posts: 2053
Joined: 08 Apr 2012 13:44

Re: Using UDP datagrams to send status updates

Post by pz1 » 10 Dec 2014 06:58

PoltoS wrote:I don't see your code, but it might be that it looks only on creation of zway instance (and not on already running), you you should remove Z-Wave Binding and add it after UDP listener.

I have changed the order of modules in the automation preferences. It seems to function now properly. I've updated the description in the Recipes section. I did not have to change the code.
Your code needs to be updated a bit to work in all cases
This is a bit cryptic to me. Does that mean adaptations which makes it independent from the order in which the modules are specified in the -preferences-automation window? (the actual code is on Recipe page as well)
Since 29-12-2016 I am no longer a moderator for this forum

pofs
Posts: 688
Joined: 25 Mar 2011 19:03

Re: Using UDP datagrams to send status updates

Post by pofs » 10 Dec 2014 09:48

digitaldan wrote:I use the following code to register my function "registerBinding" during boot up or if the file is loaded while zway is running, so far so good:

Code: Select all

this.regesterBinding = function(zwayName) {
  if (zwayName != "zway") return;
  debugPrint("Binding enabled");
}

if(typeof global.ZWave == 'undefined'){
  global.controller.on("ZWave.register", this.regesterBinding);
} else {
  this.regesterBinding("zway");
}
This is a bit inaccurate. The correct way should be:

Code: Select all

this.registerBinding = function(zwayName) {
  if (zwayName != "zway") return;
  debugPrint("Binding enabled");
}

// process all active bindings
if (global.ZWave) {
  global.ZWave().forEach(this.registerBinding);
}
// and listen for future ones
global.controller.on("ZWave.register", this.registerBinding);

digitaldan
Posts: 11
Joined: 11 Sep 2014 18:53

Re: Using UDP datagrams to send status updates

Post by digitaldan » 10 Dec 2014 17:46

Awesome, thanks for the tip.
pofs wrote:
digitaldan wrote:I use the following code to register my function "registerBinding" during boot up or if the file is loaded while zway is running, so far so good:

Code: Select all

this.regesterBinding = function(zwayName) {
  if (zwayName != "zway") return;
  debugPrint("Binding enabled");
}

if(typeof global.ZWave == 'undefined'){
  global.controller.on("ZWave.register", this.regesterBinding);
} else {
  this.regesterBinding("zway");
}
This is a bit inaccurate. The correct way should be:

Code: Select all

this.registerBinding = function(zwayName) {
  if (zwayName != "zway") return;
  debugPrint("Binding enabled");
}

// process all active bindings
if (global.ZWave) {
  global.ZWave().forEach(this.registerBinding);
}
// and listen for future ones
global.controller.on("ZWave.register", this.registerBinding);

Post Reply