Hi, I have been running the event callbacks succesfully for about 20 hours and then it stops (tried this 3 times now). It might of course be something with my python script that I have overlooked.To get it working again, I need to restart Z-WayAny hint appreciated.Best regards, WalterHere is my pythonscript: # Call this python script with parameters:# eventString, this.value, host, port, password# As an example:# var host = '192.168.10.110';# var port = 1024;# var password = '';## zway.devices[2].instances[1].SwitchBinary.data.level.bind(function() {# state = 'on';# if (this.value == '0')# state = 'off';# eventString = 'Device_2_Instance_1_' + state; # try {# system(# "python /home/pi/Desktop/network_send.py",# eventString,# this.value,# host,# port,# password# );# } catch(err) {# debugPrint("Failed to execute script system call: " + err);# }# });# After any changes, restart Z-Way : /etc/init.d/Z-Way restarttry: dummyexcept NameError: dummy = 0 import socket from hashlib import md5 import sys sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM) sock.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1) sock.settimeout(2.0) host = str(sys.argv[3])port = int(sys.argv[4])eventString = str(sys.argv[1])password = ''try: password = str(sys.argv[5])except: passpayloadString = ''try: payloadString = str(sys.argv[2])except: passtry: sock.connect((host, port)) sock.sendall("quintessence
") cookie = sock.recv(128) cookie = cookie.strip() token = cookie + ":" + password digest = md5(token).hexdigest() digest = digest + "
" sock.sendall(digest) answer = sock.recv(512) if (answer.strip() != "accept"): sock.close()# sock.sendall(str(sys.argv) + "
") sock.sendall('payload ' + payloadString + '
') sock.sendall(eventString + "
") sock.sendall("close
") sock.close()except: sock.close() Here is my javascript:
var host = '192.168.10.110';var port = 1024;var password = '';zway.devices[2].instances[1].SwitchBinary.data.level.bind(function() { state = 'on'; if (this.value == '0') state = 'off'; eventString = 'Device_2_Instance_1_' + state; try { system( "python /home/pi/Desktop/network_send.py", eventString, this.value, host, port, password ); } catch(err) { debugPrint("Failed to execute script system call: " + err); } }); zway.devices[2].instances[2].SwitchBinary.data.level.bind(function() { state = 'on'; if (this.value == '0') state = 'off'; eventString = 'Device_2_Instance_2_' + state; try { system( "python /home/pi/Desktop/network_send.py", eventString, this.value, host, port, password ); } catch(err) { debugPrint("Failed to execute script system call: " + err); } }); zway.devices[6].instances[1].commandClasses.SensorBinary.data.level.bind(function() { eventString = 'Device_6_Instance_1'; try { system( "python /home/pi/Desktop/network_send.py", eventString, this.value, host, port, password ); system("python /home/pi/Desktop/network_send.py", eventString, this.value, host, port, password); } catch(err) { debugPrint("Failed to execute script system call: " + err); } });zway.devices[6].instances[2].commandClasses.SensorBinary.data.level.bind(function() { eventString = 'Device_6_Instance_2'; try { system( "python /home/pi/Desktop/network_send.py", eventString, this.value, host, port, password ); } catch(err) { debugPrint("Failed to execute script system call: " + err); } });zway.devices[6].instances[3].commandClasses.SensorMultilevel.data[1].val.bind(function() { eventString = 'Device_6_Instance_3_temperature' try { system( "python /home/pi/Desktop/network_send.py", eventString, this.value, host, port, password ); } catch(err) { debugPrint("Failed to execute script system call: " + err); } });
Event callbacks stops working after approx 20 hours...
Too many open files?
Hi krambriw,
I am experiencing the same. I guess that your problem has to do with "too many open files".
First, try to do the following:
tail -500 /var/log/z-way-server.log
If you see the output "Failed to execute command: Too many open files", you are experience the same as already discussed in the topic "Too many open files".
It seems, that the system() function is someway broken as it leaves tons of still opened files until the z-way-server reaches its limit.
You can verify this by doing the following:
(if not already done)
sudo apt-get install lsof
then
sudo lsof | grep z-way-ser
If the output now shows endless pages of FIFO pipes, you are definitely facing the same problem...
Greets,
Stefan
I am experiencing the same. I guess that your problem has to do with "too many open files".
First, try to do the following:
tail -500 /var/log/z-way-server.log
If you see the output "Failed to execute command: Too many open files", you are experience the same as already discussed in the topic "Too many open files".
It seems, that the system() function is someway broken as it leaves tons of still opened files until the z-way-server reaches its limit.
You can verify this by doing the following:
(if not already done)
sudo apt-get install lsof
then
sudo lsof | grep z-way-ser
If the output now shows endless pages of FIFO pipes, you are definitely facing the same problem...
Greets,
Stefan
You are so correct, it is the same problem for me,,,
I see in the z-way log when the event callbacks is not appearing anymore:[2013-04-21 15:04:25.394] RECEIVED: ( 01 12 00 04 00 06 0C 60 0D 03 03 31 05 01 44 00 00 09 EF 19 )[2013-04-21 15:04:25.395] SENT ACK[2013-04-21 15:04:25.396] SETDATA devices.6.data.lastReceived = 0 (0x00000000)[2013-04-21 15:04:25.396] SETDATA devices.6.instances.3.commandClasses.49.data.1.deviceScale = 0 (0x00000000)[2013-04-21 15:04:25.397] SETDATA devices.6.instances.3.commandClasses.49.data.1.scale = 0 (0x00000000)[2013-04-21 15:04:25.397] SETDATA devices.6.instances.3.commandClasses.49.data.1.val = 25.430000[2013-04-21 15:04:25.406] SETDATA devices.6.instances.3.commandClasses.49.data.1.scaleString = "°C"[2013-04-21 15:04:25.407] SETDATA devices.6.instances.3.commandClasses.49.data.1 = Empty[2013-04-21 15:07:55.407] RECEIVED: ( 01 12 00 04 00 06 0C 60 0D 03 03 31 05 01 44 00 00 09 EF 19 )[2013-04-21 15:07:55.408] SENT ACK[2013-04-21 15:07:55.408] SETDATA devices.6.data.lastReceived = 0 (0x00000000)[2013-04-21 15:07:55.409] SETDATA devices.6.instances.3.commandClasses.49.data.1.deviceScale = 0 (0x00000000)[2013-04-21 15:07:55.410] SETDATA devices.6.instances.3.commandClasses.49.data.1.scale = 0 (0x00000000)[2013-04-21 15:07:55.410] SETDATA devices.6.instances.3.commandClasses.49.data.1.val = 25.430000[2013-04-21 15:07:55.411] SETDATA devices.6.instances.3.commandClasses.49.data.1.scaleString = "°C"[2013-04-21 15:07:55.412] SETDATA devices.6.instances.3.commandClasses.49.data.1 = EmptyFailed to execute script system call: Too many open files[2013-04-21 15:11:04.429] RECEIVED: ( 01 12 00 04 00 06 0C 60 0D 03 03 31 05 01 44 00 00 09 EF 19 )[2013-04-21 15:11:04.430] SENT ACK[2013-04-21 15:11:04.430] SETDATA devices.6.data.lastReceived = 0 (0x00000000)[2013-04-21 15:11:04.430] SETDATA devices.6.instances.3.commandClasses.49.data.1.deviceScale = 0 (0x00000000)[2013-04-21 15:11:04.431] SETDATA devices.6.instances.3.commandClasses.49.data.1.scale = 0 (0x00000000)[2013-04-21 15:11:04.432] SETDATA devices.6.instances.3.commandClasses.49.data.1.val = 25.430000[2013-04-21 15:11:04.433] SETDATA devices.6.instances.3.commandClasses.49.data.1.scaleString = "°C"[2013-04-21 15:11:04.433] SETDATA devices.6.instances.3.commandClasses.49.data.1 = EmptyFailed to execute script system call: Too many open files
Testing additionally
In the above python and javascript code I have added the below just to test if it makes any difference. I need to run it for a day to see if it helps.In the python code, added 'sys.exit(0)' try: sock.connect((host, port)) sock.sendall("quintessence
") cookie = sock.recv(128) cookie = cookie.strip() token = cookie + ":" + password digest = md5(token).hexdigest() digest = digest + "
" sock.sendall(digest) answer = sock.recv(512) if (answer.strip() != "accept"): sock.close()# sock.sendall(str(sys.argv) + "
") sock.sendall('payload ' + payloadString + '
') sock.sendall(eventString + "
") sock.sendall("close
") sock.close() sys.exit(0)except: sock.close()
In the javascript code, added 'return;' try { system( "python /home/pi/Desktop/network_send.py", eventString, this.value, host, port, password ); return; } catch(err) { debugPrint("Failed to execute script system call: " + err); }
") cookie = sock.recv(128) cookie = cookie.strip() token = cookie + ":" + password digest = md5(token).hexdigest() digest = digest + "
" sock.sendall(digest) answer = sock.recv(512) if (answer.strip() != "accept"): sock.close()# sock.sendall(str(sys.argv) + "
") sock.sendall('payload ' + payloadString + '
') sock.sendall(eventString + "
") sock.sendall("close
") sock.close() sys.exit(0)except: sock.close()
In the javascript code, added 'return;' try { system( "python /home/pi/Desktop/network_send.py", eventString, this.value, host, port, password ); return; } catch(err) { debugPrint("Failed to execute script system call: " + err); }
We have found a problem in
We have found a problem in system() call in our JavaScript API. This was fixed, but will apear in future release. We hope to get it released by the end of month.