Hacking Philips Hue: Hue V2 and Arduino?

Hacking Philips Hue: Hue V2 and Arduino?

In order to change the colors of the gradient lightstrip, I NEED to use V2 of the Philips Hue API because V1 of the API is unaware of the gradient functionality. It just doesn't see it.  

After following the tutorial, I was able to get the unique ID of my Gradient Lightstrip (It's no longer a simple number like on V1- it used to be "25" now it's a very long string of "blah!"). Then, I could use both the Postman software or the CLIP API Debugger to concoct the correct URL and message to fiddle with my gradient lights.  

I could then send the JSON required to change the gradient points:

I thought that this would be easy to use the same JSON string making and sending skills that I learned from the Arduino Hue example in the ArduinoHttpClient library. 

Not so fast.

In V2, the api key is placed in the header, not in the url (there's a spot for it in the form above). And that's causing me much trouble! I was hoping to just place the url for V2 in the same spot as V1 in my Arduino code, and add the new JSON for the gradient, and hoped it would work.  It did not. 

I tried all of the examples in the httpClient library (or at least my best guess at using them) and came up with no luck.  I would just get a 405 error. 

After much trying, I either get a 405 "Not Allowed" or a 404 that returns back a webpage telling me that "oops! there appears to be no lighting here" in html. 

So nothing worked.  ... THEN I REMEMBERED When I was going through the tutorial, I was instructed to make sure "SSL certificate verification" was turned off. If I go back in the Postman software and turn it on, it doesn't work. 

Furthermore, when using the CLIP API Debugger, it also works but if you look at the top it has cancelled the "HTTPS" and is "not secure". 

So my question is: 

  • Can the Arduino turn off SSL certificate verification? Or send requests without it?
  • Or, can the Arduino HttpClient library even send the headers in a way that they can be read in this system?

Two more things to try:

Changing from "WiFiClient" to "WiFiSSLClient" and from port 80 to port 443. 

*The following code DOES NOT WORK, posting for personal reference 

= This version hangs for awhile then returns error code "-2"

Reformatting the PUT request to include the headers written out individually (instead of using the PUT request function with 3 arguments). 

*The following code DOES NOT WORK, posting for personal reference 

= This version hangs for awhile then returns error code "-3"

Can my request be "insecure?" 

I think changing to the WifiSSLClient was the right move, but it's not enough. The web browser and the Postman software are capable of sending "insecure" requests, and my Arduino code isn't doing that. 

How can my Arduino send the "insecure" message just like Postman? What is it actually sending?

Here's the info from the API reference showing the difference between V1 and V2:

So, I've been looking into sending "insecure" requests with Arduino. I haven't found a solution that works with my Arduino Wifi 1010 yet, but here are some posts that I've found to try to learn more about how that all works:

  • Arduino Bear SSL - This library seems to allow me to set my request to "insecure", but I haven't been able to combine my hue example with the example here. It might be possible, and if you know that it is please let me know! 

Well, I know I'm onto something because I know what message needs to be sent - it's just about how to get it there. 

I tried using terminal to send the request hoping to uncover what was needed. I used the suggested path from the Hue API V2.

It works if you start by saying "curl --insecure" but not without it. You can alco use "curl -k" but the arduino library doesn't do this. 

I just found one that does - Arduino Bridge Library But I'm not really up for learning a whole new library and rewriting everything. I think I'm going to have to take a rest. 

Maybe next time. 

Since I found out that there isn't an easy way to separate the sections of the LEDs in a way that will look nice in my kitchen, learning this whole new library and updating everything seemed like a task that was going to be too much work for the mediocre result I would get from it. 

I decided that I would be happy with just the motion sensors activating all the lights at once. 

comment (1)

  • avatar

    on May 8, 2023 17:59

    I am currently trying to find a solution to this exact problem. There are two paths to a possible solution:
    1) Make an insecure connection as you have been trying to do. Unfortunately I also have not been able to accomplish this with the existing WiFiNINA library.
    With the ESP8266 library it was a breeze, as you just need to call setInsecure on the WiFiSSLClient before starting your connection
    2) Make an actual secure connection. For this the root certificate of the hue bridge must be installed onto the WiFi module first. The root certificate itself is found in the hue v2 documentation under the section Using HTTPS. For the upload there is a a tool in the Arduino IDE that allows us to upload certificates as explained here: https://docs.arduino.cc/software/ide-v2/tutorials/ide-v2-fw-cert-uploader (There is also a command line tool that pretty much does the same thing)
    However even after uploading my SSL certificates I was not able get this thing to work. Well let’s keep digging.
    However after installing the root certificate

Leave a comment

Please note, comments must be approved before they are published

We use cookies to improve your experience on our website. By browsing this website, you agree to our use of cookies. Accept