State change in RaZ webapp to exec console (bash) command?

Discussions about RaZberry - Z-Wave board for Raspberry computer
Post Reply
anom3
Posts: 72
Joined: 21 Sep 2016 08:53

State change in RaZ webapp to exec console (bash) command?

Post by anom3 »

Hi.

I have yet to even start digging in, but thought it would better to ask before I start:

I would like to have a z-wave device state change (as shown in the web app) execute a bash command line. What is the proper way of going at this? Should I just be pooling the API?

Thanks!
anom3
Posts: 72
Joined: 21 Sep 2016 08:53

Re: State change in RaZ webapp to exec console (bash) comman

Post by anom3 »

A bit more info:

A) If the states of the devices are stored anywhere on the filesystem that would be better then going via the API.
B) Ideally, having a trigger -> execute command line would be the best.
pz1
Posts: 2053
Joined: 08 Apr 2012 13:44

Re: State change in RaZ webapp to exec console (bash) comman

Post by pz1 »

anom3 wrote:I would like to have a z-wave device state change (as shown in the web app) execute a bash command line. What is the proper way of going at this? Should I just be pooling the API?
Except for a few older (mostly USA) Z-wave devices, most do signal a state change to the controller. So no need to do costly polling.

I would try something along this (not tested)

- Use app CodedDevice to make a Toggle device and enter the Javascript code system("yourbash.sh")
- Add the name of yourbash.sh to file /opt/z-way-server/automation/.syscommands
- Use app IFTHEN or LogicalRule that fires on your event and activate.

If you run into trouble, search this forum. There are more examples of using bash commands here. Alternatively see the DevelopersManual
Post Reply