Hi,
this is working for me (just a simple sample) :
create test1.js and place it into automation directory
content of test1.js:
zway.devices[5].instances[0].commandClasses[48].data.level.bind(function() {
try {
system("sh /opt/test.sh " + this.value);
} catch(err) {
debugPrint("Failed to execute command: " + err);
}
});
(if any error you will see it in log)
-----------
edit the config.xml in /opt/z-way-server/:
..
automation/test1.js
..
-----------
create test.sh:
TODAY=`date '+%F %H:%M:%S'`
echo "$TODAY - param1: $1" >> /var/log/test.txt
-----------
in /opt/z-way-server/htdocs create the file .syscommands with one line only:
sh
-----------
restart Z-Way : /etc/init.d/Z-Way restart
-----------
you will get in test.txt (for motion sensor):
2013-04-03 09:29:29 - param1: true
2013-04-03 09:29:48 - param1: false
Hope this helps
Access ZWaveAPI through Python script on Raspberry
It will be easier for you to
It will be easier for you to use resquests module in python
Just to do :
requests.get("...")
Just to do :
requests.get("...")
You had to replace the line
You had to replace the line in config.xml. Current is quite useless for now.
getting stored values works
getting stored values works perfect!
-- response = requests.post("http://.../ZWaveAPI/Run/devices[3].data.isFailed.value")
But how would I get a fresh value(like temperature) in python?
Because this returns just the last value I got when getting the value vie the demo UI:
-- .instances[0].commandClasses[48].data.level.value
-- response = requests.post("http://.../ZWaveAPI/Run/devices[3].data.isFailed.value")
But how would I get a fresh value(like temperature) in python?
Because this returns just the last value I got when getting the value vie the demo UI:
-- .instances[0].commandClasses[48].data.level.value
yes, preplacing the line
yes, preplacing the line worked. It seems like I can't ask for another value via http request
while I'm in the event handler script? I tried to make a curl request to read the status of a
binary switch. But it always returned null (empty string). Outside the event script the curl
request works fine.
while I'm in the event handler script? I tried to make a curl request to read the status of a
binary switch. But it always returned null (empty string). Outside the event script the curl
request works fine.
Either the device will send
Either the device will send you the temperature periodcally, or yu need to poll it using a .Get() function
Same with python script - what is wrong here?
I am trying the same with a python script and a sensor value but somehow fail. I do this:
1.)--------Write automation file my_main.js --------------------
zway.devices[2].instances[1].commandClasses[0x31].data[4].val.bind(function() {
try {
system("python /home/pi/Desktop/my_script.py " + this.value);
} catch(err) {
debugPrint("Failed to execute script system call: " + err);
}
});
2.) --------------replace main.js in config.xml with my_main.js--------
3.)-----------create .syscommands line --------------
I put the python script file pathname in the .syscommands file:
/home/pi/Desktop/my_script.py
4.) -------- restart Z-Way server --------
However my_script.py gets never called. Where would I find the errorlog of the system call?
I there anything fundamentally wrong with my approach above?
I am bit lost .
1.)--------Write automation file my_main.js --------------------
zway.devices[2].instances[1].commandClasses[0x31].data[4].val.bind(function() {
try {
system("python /home/pi/Desktop/my_script.py " + this.value);
} catch(err) {
debugPrint("Failed to execute script system call: " + err);
}
});
2.) --------------replace main.js in config.xml with my_main.js--------
3.)-----------create .syscommands line --------------
I put the python script file pathname in the .syscommands file:
/home/pi/Desktop/my_script.py
4.) -------- restart Z-Way server --------
However my_script.py gets never called. Where would I find the errorlog of the system call?
I there anything fundamentally wrong with my approach above?
I am bit lost .
Please try
Please trysystem("python /home/pi/Desktop/my_script.py", this.value);and edit .syscommandspython /home/pi/Desktop/my_script.pyThe path in .syscommands should match the first argument passed to system.This was my error - I mislead people on the forum with a wrong exmaple.