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

Login:
Pass:
 
 

Topic:
Connect to Philips Hue from ProntoScript
This thread has 6 replies. Displaying all posts.
Post 1 made on March 21, 2026 at 22:24
M
mpg7321
Long Time Member
Joined:
Posts:
RC XP:
June 2020
167
95⭐︎
var bridgeIP = "192.168.1.18";
var username = "Y1Vpd5qwJVnjsRIdxFThJR0jxcrnZaEvrQVe0NYM";
var lightID = "1";


var url = "http://" + bridgeIP + "/api/" + username + "/lights/" + lightID + "/state";

// JSON body to turn the light ON
var body = '{"on": true,"bri":244}';

// Send PUT request
CF.request(url, "PUT", {"Content-Type": "application/json"}, body, function(status, headers, data) {
if (status == 200) {
CF.log("Light turned on successfully");
} else {
CF.log("Error turning on light: " + status);
}
});

this should turn a bulb on and to full brightness, any thoughts on why it does not?

Last edited by Lyndel McGee (moderator) on April 4, 2026 17:23.
Post 2 made on March 22, 2026 at 18:49
L
MOD
Lyndel McGee
RC Moderator
Joined:
Posts:
RC XP:
August 2001
13,142
464⭐︎
Before I get accused of flaming, I did answer the questions as to why what was posted does not work below.

1. The source code above is not adding necessary request headers such as Content-Length for the Post body. Also maybe a HOST header as well? Not sure if this will be required.

2. No idea what HTTP library you are expecting to use but looks as though you are expecting philips to support the Node JS engine which did not exist during the the lifespan of the Prontos.

FYI, philips does not support request or xmlhttprequest. These calls are done best through a library.

CF.request is not a function and as such will never work. What you are posting looks exactly like a Node JS sample using an HTTP Request.

Please confirm this is for Philips Hue.

[Link: stackoverflow.com]

If you are using the Philips Http library, you'd need to be doing some things very differently.

Does the above command work through Postman or Bruno? Once you have it working there, you can then look at the headers and body that are being sent and emulate that with a raw socket call in ProntoScript if you choose. Not sure the Philips HttpLibrary will completely do what you need.

Also, please consider editing your title to a more appropriate topic to give us some context?

Regards,
Lyndel

Lyndel McGee
Philips Pronto Addict/Beta Tester
OP | Post 3 made on March 31, 2026 at 11:45
M
mpg7321
Long Time Member
Joined:
Posts:
RC XP:
June 2020
167
95⭐︎
No worries changed my approach and got everything working.

Thanks
Mike

Post 4 made on April 3, 2026 at 13:04
L
MOD
Lyndel McGee
RC Moderator
Joined:
Posts:
RC XP:
August 2001
13,142
464⭐︎
Care to share your solution? Im interested.
Lyndel McGee
Philips Pronto Addict/Beta Tester
OP | Post 5 made on April 3, 2026 at 19:01
M
mpg7321
Long Time Member
Joined:
Posts:
RC XP:
June 2020
167
95⭐︎
var socket = new TCPSocket(false);
var JSON_on = '{"on":true,"bri":255}';
var bridgeIP = CF.widget("Hue_URL","HUE").label;
var port = 80;
var groupID = 1;


// Function to send the PUT request over the socket
function sendHueCommand(commandJSON) {
var httpRequest =
'PUT /api/Y1Vpd5qwJVnjsRIdxFThJR0jxcrnZaEvrQVe0NYM/groups/' + groupID + '/action HTTP/1.1\r\n' +
'Host: ' + bridgeIP + '\r\n' +
'User-Agent: ProntoTSU9600\r\n' +
'Content-Type: application/json\r\n' +
'Content-Length: ' + commandJSON.length + '\r\n' +
'\r\n' +
commandJSON;

socket.write(httpRequest);

// Update the widget label for feedback
CF.widget(bri).label = JSON.parse(commandJSON).bri;

// Properly close the socket after sending
socket.close();
}

// When socket connects, send the command
socket.onConnect = function() {
sendHueCommand(JSON_on);
};

// Handle socket errors
socket.onError = function(err) {
CF.log("Socket error: " + err);
};

// Connect to the Hue Bridge
socket.connect(bridgeIP, port, 3000);

Last edited by mpg7321 on April 4, 2026 15:16.
Post 6 made on April 4, 2026 at 17:22
L
MOD
Lyndel McGee
RC Moderator
Joined:
Posts:
RC XP:
August 2001
13,142
464⭐︎
On April 3, 2026 at 19:01, mpg7321 said...
var socket = new TCPSocket(false);
var JSON_on = '{"on":true,"bri":255}';
var bridgeIP = CF.widget("Hue_URL","HUE").label;
var port = 80;
var groupID = 1;

// Function to send the PUT request over the socket
function sendHueCommand(commandJSON) {
var httpRequest =
'PUT /api/Y1Vpd5qwJVnjsRIdxFThJR0jxcrnZaEvrQVe0NYM/groups/' + groupID + '/action HTTP/1.1\r\n' +
'Host: ' + bridgeIP + '\r\n' +
'User-Agent: ProntoTSU9600\r\n' +
'Content-Type: application/json\r\n' +
'Content-Length: ' + commandJSON.length + '\r\n' +
'\r\n' +
commandJSON;

socket.write(httpRequest);

// Update the widget label for feedback
CF.widget(bri).label = JSON.parse(commandJSON).bri;

// Properly close the socket after sending
socket.close();
}

// When socket connects, send the command
socket.onConnect = function() {
sendHueCommand(JSON_on);
};

// Handle socket errors
socket.onError = function(err) {
CF.log("Socket error: " + err);
};

// Connect to the Hue Bridge
socket.connect(bridgeIP, port, 3000);


Mike,
Many Thanks! For other users, note that the link above will have to be changed to add your user token. The group may also need to be changed.
Lyndel McGee
Philips Pronto Addict/Beta Tester
OP | Post 7 made on April 4, 2026 at 21:33
M
mpg7321
Long Time Member
Joined:
Posts:
RC XP:
June 2020
167
95⭐︎
For those that would like to turn on one bulb, you would have to change,

'PUT /api/Y1Vpd5qwJVnjsRIdxFThJR0jxcrnZaEvrQVe0NYM/groups/' + groupID + '/action

to

'PUT /api/Y1Vpd5qwJVnjsRIdxFThJR0jxcrnZaEvrQVe0NYM/lights/' + groupID + '/action

Jump to


Protected Feature Before you can reply to a message...
You must first register for a Remote Central user account - it's fast and free! Or, if you already have an account, please login now.

Please read the following: Unsolicited commercial advertisements are absolutely not permitted on this forum. Other private buy & sell messages should be posted to our Marketplace. For information on how to advertise your service or product click here. Remote Central reserves the right to remove or modify any post that is deemed inappropriate.