Problem with Javascript Code execution from Z-Way

Discussions about Z-Way software and Z-Wave technology in general
Post Reply
jstaffon
Posts: 80
Joined: 29 May 2015 04:47

Problem with Javascript Code execution from Z-Way

Post by jstaffon »

I've used the Javascript code execution app in previous versions with much success but am having problems with v2.2.2 running on jessie. I've done some diagnostics by adding code that prints to a file in /tmp to try and troubleshoot. Below is my javascript code, followed by the bash script called with the "system" command.

Javascript code
---
zway.devices[5].instances[0].commandClasses[48].data[1].level.bind(function() {
if (this.value == true)
system('/opt/z-way-server/automation/userModules/movement.bash');
});
---

movement.bash code
---
#!/bin/bash

/usr/bin/mail -s "Security Alert from Brandon-Pi" <cellnumber>@vtext.com < ./movement.message
date > /tmp/tmpfile
---

If I log in as the user "pi" via ssh and execute the "movement.bash" script, everything works like it should. If I run the script as "root", it too works like it should. But if I trigger my motion detector, the script gets executed, the date gets copied to the tmpfile but the mail message doesn't get sent to my cell phone. Because of this, I know the movement.bash script is getting called properly and executed. Right now, I only have the movement.bash name in the .syscommands file. I tried adding /usr/bin/mail but is doesn't make any difference. I'm sure it's a linux issue but I'm hoping I've forgotten something in ZWay so this forum can help. Thanks in advance.
User avatar
PoltoS
Posts: 7601
Joined: 26 Jan 2011 19:36

Re: Problem with Javascript Code execution from Z-Way

Post by PoltoS »

Make sure to have in .syscommands:
/opt/z-way-server/automation/userModules/movement.bash

Also put a console.log in the bind callback function to check that this code executes.

Also make sure zwya object is already loaded when this code executes
EcoMan
Posts: 2
Joined: 18 Jun 2016 21:19

Re: Problem with Javascript Code execution from Z-Way

Post by EcoMan »

Excuse me =) I am beginner and can't find where the command "console.log" write the output results. Thank you.
pz1
Posts: 2053
Joined: 08 Apr 2012 13:44

Re: Problem with Javascript Code execution from Z-Way

Post by pz1 »

EcoMan wrote:Excuse me =) I am beginner and can't find where the command "console.log" write the output results. Thank you.
/var/log/z-way-server.log
Post Reply