Event callbacks stops working after approx 20 hours...
Posted: 20 Apr 2013 15:36
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); } });
") 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); } });