Philips Pronto Professional Forum - View Post
The following page was printed from RemoteCentral.com:
Post 1 made on Sunday January 17, 2021 at 14:15
kapsreiter
Long Time Member
Joined: Posts: November 2006 48
sorry for my english i have 2 working pronto scripts but find no way to get a script to a macro so is there a way to combine this 2 scripts in 1 script block i am not a programmer may be someone could edit it for me? script 1 __________________________________ var socket = new TCPSocket(false); var result=""; var JSON_on='{"on":true}'; function getInfos(commands) { socket.write('PUT /api/lVfthQzyz9ZbNsUyndnZT9WBBOQ852HY3fEcPUVg/groups/1/action HTTP/1.1\r\nHost: 10.0.0.2\r\nUser-Agent: ProntoTSU9600\r\nContent-Length: '+commands.length+'\r\n\r\n'+commands); } socket.onConnect = function() { getInfos(JSON_on); }; socket.onData = function() { }; socket.onClose = function() { socket = null } socket.onIOerror = function() { System.print("error"); try { socket.close() socket = null } catch(e) {} } socket.connect('10.0.0.2', 80, 3000); script 2 __________________________________ var result = ""; var socket = new TCPSocket(false); var t1,t2,t3,t4,t5; var event1,event2; var descrip1, descrip2; socket.onConnect = function() { socket.write("GET /relay/0?turn=on HTTP/1.0\r\n"); socket.write("Accept: */*\r\n"); socket.write("Host: 10.0.0.249\r\n"); socket.write("Connection: close\r\n"); socket.write("\r\n"); }; socket.onData = function() { //result += socket.read(5000,1000); t0 = result.indexOf("class=\"time\">", 0)+13; t10 = result.indexOf("/span>",t0)-1; tijd1 = result.substring(t0,t10); t1 = result.indexOf("class=\"event\">", 0)+14; t2 = result.indexOf("/span>",t1)-1; event1 = result.substring(t1,t2); CF.widget("channel1").label=event1; t4 = result.indexOf("class=\"description\">", t2)+20; t5 = result.indexOf("/span>",t4)-1; t6 = result.indexOf("class=\"event\">", t5)+14; t7 = result.indexOf("/span>",t6)-1; event2 = result.substring(t6,t7); CF.widget("channel2").label=event2; }; socket.onClose = function() { }; socket.onIOError = function(e) { }; if(socket.connected == false) { socket.connect('10.0.0.194', 80, 3000); }; ____________________________________ thank you tom