Command line examples for triggers

Discussions about RaZberry - Z-Wave board for Raspberry computer
McD
Posts: 17
Joined: 28 Mar 2013 14:15

Command line examples for triggers

Post by McD »

Is it somehow possible to setup the RaZberry to receive events of an EZmotion sensor and call some bash scripts?
In the documentation I find some trigger info, but I can not understand how to link the parts together?


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

Try something like this: zway

Post by PoltoS »

Try something like this: zway.devices[X].instances[0].commandClasses.SwtichBinary.data.level.bind(function() {system("echo " + this.value);});
McD
Posts: 17
Joined: 28 Mar 2013 14:15

not working....

Post by McD »

after much trying I can not make it work.

I am calling:

$/usr/bin/curl -s -LN --globoff 'http://__ipaddress__:8083/ZWaveAPI/Run/devices[X].instances[0].commandClasses[49].data[1].val.bind(function(){system("echo "+this.value);});'

and I only get:

>JavaScript compilation error: Uncaught SyntaxError: Unexpected token ILLEGAL

If i leave the system empty, like ....system();.... or I just do ...system("echo").... it does not give the error. Always if i put spaces or "this.value" into the function, this error occures.
If I just put the "echo" in, if the event is triggered the script is not run.

On the other hand

$/usr/bin/curl -s -LN --globoff 'http://:8083/ZWaveAPI/Run/devices[X].instances[0].commandClasses[49].data[1].val.unbind()'
>null

seems to work.

What am I doing wrong?

Very confusing is the log output. It almost shows in real time events that are received via the z-wave system, but these binds are just shown like 5-10 mins. later in a batch of messages. This is wanted behaviour?
User avatar
PoltoS
Posts: 7579
Joined: 26 Jan 2011 19:36

Make sure to URL encode "+"

Post by PoltoS »

Make sure to URL encode "+" sign into "%2B".

As for the delay in logs, the JS logging is buffered and appears once enough data is collected. We will try to change this in future.
McD
Posts: 17
Joined: 28 Mar 2013 14:15

This was a good tip, but one

Post by McD »

This was a good tip, but one has to URL encode the whole thing:

$/usr/bin/curl -s -LN --globoff 'http://__ipaddress__:8083/ZWaveAPI/Run/devices[3].instances[0].commandClasses[48].data.level.bind(function()%20%7B%0Asystem(%22/usr/local/bin/test%20%22%20%2B%20this.value)%3B%0A%7D);'
>null

This is not really desireable because it makes administration very hard. Even think of more difficult js scripts which should be triggered...

Do you see a different way to approach this?

Secondly the bind does not really work:

After the bind I get this in the log:
[2013-03-29 ] RECEIVED: ( 01 09 00 04 00 03 03 20 01 FF 2C )
[2013-03-29 ] SENT ACK
[2013-03-29 ] SETDATA devices.3.data.lastReceived = 0 (0x00000000)
[2013-03-29 ] SETDATA devices.3.instances.0.commandClasses.48.data.level = True

That's it. The execution of the binded function is not logged...and did not really work therefore.

But then... I waited again and I received the following message in the log:
>Callback execution error: Uncaught System commands are not configured

(These buffered JS log entries are really0 not helping...)

Can you please tell me, what this means and how to avoid it, so that the trigger works?
User avatar
PoltoS
Posts: 7579
Joined: 26 Jan 2011 19:36

Well, in your case URL

Post by PoltoS »

Well, in your case URL encoding is not fully done by curl. This has nothing to do with z-way.

For convenience you can put the script on a file and use executeJS to load it instead of doing it in the URL.

As for the bind call, it should work. Might it be that it works, but you don't see the result in the log due to cache? Please try to write some file on the disk from this system call.
User avatar
PoltoS
Posts: 7579
Joined: 26 Jan 2011 19:36

By the way, our programmer

Post by PoltoS »

By the way, our programmer suggests to create the file of allowed commands .syscommands

Please refer to the manual for more info
michap
Posts: 442
Joined: 26 Mar 2013 10:35
Contact:

> Please refer to the manual

Post by michap »

> Please refer to the manual for more info (about "..to create the file of allowed commands .syscommands")
What manual do you mean?
http://en.z-wave.me/docs/zway_manual_en.pdf ?
remecz
Posts: 4
Joined: 19 Mar 2013 21:16

.syscommands location and syntax

Post by remecz »

I'm also interested in using command line triggers but can't seem to find info about the .syscommands file in the manual (http://en.z-wave.me/docs/zway_manual_en.pdf). Can you give some directions? Thanks!
pz1
Posts: 2053
Joined: 08 Apr 2012 13:44

Afaik that manual is for Z

Post by pz1 »

Afaik that manual is for Z-Cloud not Razberry. The 70+ page detailed manual that used to be on the Razberry website has been withdrawn and replaced by a 4 page summary.
Since 29-12-2016 I am no longer a moderator for this forum
Post Reply