Your Universal Remote Control Center
RemoteCentral.com
Philips Pronto Professional Forum - View Post
Up level
Up level
The following page was printed from RemoteCentral.com:

Login:
Pass:
 
 

Original thread:
Post 5 made on Saturday March 19, 2022 at 00:01
Lyndel McGee
RC Moderator
Joined:
Posts:
August 2001
12,999
On March 15, 2022 at 21:37, laalves said...
So, I want to build an interface in my wall mounted TSU9800 with buttons to send on/off commands to devices in Hubitat, just that. Given the infinite possibilities of the Hubitat system, this would be really neat.

I have no experience with Pronto Script although I have many years with Prontos

Now, building on other posts in this forum I adapted somebody else's script to work with a GET command like the below which I simply pasted into the Actions field of a button (after clicking "Use Pronto Script"):

var socket = new TCPSocket(false);
socket.onConnect = function()
{
socket.write("GET /apps/api/150/devices/1153/on?access_token=a43ebdcb-bc49-4a37-a419-b30304277ed6 HTTP/1.1\r\n\r\n")
socket.close();
};
socket.onClose = function()
{
};
socket.onIOError = function(e)
{
label = "Error: " + e;
};
socket.connect('192.168.70.100’,80);

The Hubitat's IP is 192.168.70.100 and when using the string 192.168.70.100:80/apps/api/150/devices/1153/on?access_token=a43ebdcb-bc49-4a37-a419-b30304277ed6 in a browser it works just fine, i.e, the device 1153 turns ON. However, the script does not work. Nothing shows up in the logs of the Hubitat, so I assume that the command is not reaching it.

Looking at the script, what possible failures can you spot and what could I try different?

You did not declare a variable named label.

var label = "";

Failure to do this will result in an error should the socket encounter an issue.

If you "really" want to learn ProntoScript, I strongly recommend reading chapters 1-9 of David Flanagan javascript book (I think 5th edition) which is named in the Dev Guide. Also reading up in the Dev Guide and trying the examples there as well might help you become more familiar.
Lyndel McGee
Philips Pronto Addict/Beta Tester


Hosting Services by ipHouse