MoreHue.com

For everything you need to know about smart homes, home automation, Philip Hue and much more.

Guides

Add Light with Serial Number via Philips Hue Api

Add Light with Serial Number via Philips Hue Api

Hue light (by @jeremybezanger on Unsplash)

Adding lights to your hue bridge can be quite a hassle. Sometimes your bridge can’t find the lights you want to add or they are still connected to another bridge. One of the options I described in my guide of adding a light to your bridge was by using the serial number.

But what if you have more than 50 lights and want to move like half of them to a second bridge? Adding all lights separately within the app will take quite some time. So in this guide, I will help you add Philips Hue lights to your switch with the serial numbers via the Hue API.

This guide will use the Philips Hue API v1 as this is not yet available in v2.

TL;DR;

In this guide, I assume that you already know how to use the Philips Hue API v1. If not, please read the up until part 2 of this guide.

  • Get your list of serial numbers
  • Create your request to add the lights
  • Run the request untill all lights are added

Get your list of serial numbers

Hopefully, you have a list of all the serial numbers from the lights you want to move over to your new bridge. If not I have bad news for you. Unfortunately, you are not able to extract the serial number of your lights with the Philips Hue API as it’s simply not stored within the light. This also means that this feature won’t come in the near future as well.

If you do have this list, you can move on with this guide. If not, you will need to need to unscrew the lights you want to move and write down the serial numbers.

TIP: Please write the serial numbers of these lights down in a document with the position of your light so you have easy access to them if you ever need them again.

Create your request to add the lights

With your authenticated username, we can get all the lights currently connected to our bridge. To do this send a new GET request in de API sandbox to:

https://<bridge_ip_address>/api/<authenticated_username>/lights

This will give you a JSON response with all the lights in your system. All these lights will have the same name corresponding to them as you will see in the Hue app. We will use the same URL to add lights to the selected bridge but instead of doing a GET request we will do a POST request with the following body:

{"deviceid":["45AF34","Serial number 2","Serial number 3"]}

Run the request untill all lights are added

Now that we have created our request to add lights to the bridge, it’s time to actually run it. It is important to note that you can only enter up to 10 serial numbers per request. When running the request, the bridge will open the network for 40 seconds. The overall search might take longer since the configuration of (multiple) new devices can take longer. If many devices are found the command will have to be issued a second time after discovery time has elapsed. If the command is received again during the search the search will continue for at least an additional 40s.

When the search has finished, new lights will be available using the get new lights command. Repeat the GET request from before and check whether your lights are now found by your bridge. Repeat this step until all your lights are added to the bridge.

That’s it! You have now added your lights to your bridge with the help of the Philips Hue API and the serial numbers of your lights. And remember to save your serial number the serial numbers of your lights as there is no way of fetching them from the API.

If you want to learn more about the Hue API v1 I highly recommend the official documentation. If you want to learn about the Philips Hue API v2 I recommend reading this article.

Share this post

About the author

Leave a Reply

Your email address will not be published.

Hey, wait!Join our community

Join our community and subscribe to the newsletter to receive the latest and greatest updates about smartening up your home.