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.
Problem with Javascript Code execution from Z-Way
Re: Problem with Javascript Code execution from Z-Way
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
/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
Re: Problem with Javascript Code execution from Z-Way
Excuse me =) I am beginner and can't find where the command "console.log" write the output results. Thank you.
Re: Problem with Javascript Code execution from Z-Way
/var/log/z-way-server.logEcoMan wrote:Excuse me =) I am beginner and can't find where the command "console.log" write the output results. Thank you.