Pepper illuminates your home with IoT

Controlling a Philips hue lamp with a simple robotic app
Pepper illuminates your home with IoT

Light up your living room just by greeting Pepper when coming home thanks to IoT (Internet of Things). There is a large variety of connected objects such as lamps, boilers, presence sensors, radiators and much more you can try to connect to your Pepper. You could imagine Pepper being the interface to your home’s devices and control them.Let’s connect Pepper to a Philips Hue lamp in the first place.

This article is part of the API Challenge: Quentin, an intern at SBRE, is plugging various third-party technologies (web services or IoT devices) into Pepper. For each technology, he has one week to test it, make a demo on Pepper, and write up his experience. This is a way of checking how easy it is to integrate technology with Pepper.

My third mission in the course of the API Challenge was to enable my Pepper to connect to an IoT device. In my workspace storage, I found a Philips Hue lamp and its bridge, a device needed to connect most IoT items to the local network and to the Internet. I aimed at enabling my Pepper to connect to the bridge and control the lamp as I talk to my robot.

1. Setting the Philips Hue lamps, the Hue Bridge and the API

The Philips Hue API website is clear and well guided and the API is easy to use, working with REST requests which are starting to be familiar around here.

First of all, following the steps given on the Get started page of the lamps website, I installed the Philips Hue app on my phone to ensure that the bridge and lamp were functioning and get the bridge IP for later use.

Then, I used the Philips API debugging tool (provided in the Getting Started) and registered as a new user to obtain an authentication token to be able to send basic Get and Put requests to the bridge to check and change the lamp’s state: it’s on/off state, hue, brightness and saturation.

So at this point I can check and change the lamp’s state by sending requests to the debugging tool. But I want now to control the lamps with Pepper’s help. To do so, I will trigger actions using those requests inside a robotic application.

2. Using code to trigger actions

After making sure I was sending the right requests with the debugging tool, I had to transfer all of that to a robotified android app to allow Pepper to interact with the Hue Bridge. I have been using retrofit (a standard REST request java library for android) to send Put requests to this URL:


I then created a class containing the instructions needed to access the API, meaning the base Url, the retrofit build and the interface below:

class PhilipsHueControl {
    private var base_URL = "https://$bridgeIP"
    //build the retrofit client
    interface LampControl {
        fun updateLampState(@Path("username") username: String, @Body state:RequestBody): Call<ResponseBody>
    val serviceControl = retrofit.create(!!


I used another class containing all the functions to control the light and made them voice-triggered with qiChat executors (see the related Dev center’s lesson). As a simple example, the switchOn function:

fun switchOn(){
   on = true
   val requestBody = RequestBody.create(JSON, "{\"on\":$on}")
   val responseControl = philipsHueControl.serviceControl.updateLampState(username,requestBody).execute()

In theory, this should be perfectly functional, but when I executed a test supposed to turn the light on, I got this error message: unable to find valid certification path to requested target

In order to workaround, this trivial security matter I used "http" URLs instead of "https" URLs and everything worked as it should. Obviously, this should not be done if you ever want your app to be distributed, but it is not really important if you created it for personal or educational purposes.

So at this point, and with the security matter out of the way I was able to ask Pepper to switch the light on and off, modulate its brightness and change its color.

3. Automating the URL connection

As you surely noticed, my app is a bit sloppy since it is only functional with one specific bridge and one specific lamp, all because I entered the IP address and the username contained in the request URL by hand. But we could make it usable with any bridge and lamp! How shall we proceed? Well, there is a variety of Philips hue compatible discovery methods we can use to get the app to find the bridge and lamp.

I first tried to implement the UPnP discovery method to my app, even so, the Philips website specifies it is not very functional with the bridge anymore, but it is the simplest one and I wanted to give it a try. Well, the only device I found using this method is a coffee machine… but at least I found something.

Trying something else, I focused on the mDNS discovery method, after finding some documentation and an adapted library on GitHub, I managed to find my bridge, along with every printer of the building. I then retrieved its IP address to use it in the request URL and sent a request to it to create a new username. With this process, I can now get my Pepper to connect to any other bridge that would be on the same local network as the robot!

After the basics of my mission were accomplished, I had a little fun enhancing the possibilities offered by the app I just created. I added a little demo mode using a single executor class to show all the different functionalities of my app.

4. Sheding light on what we did

Let’s quickly review what we did here. By first using the Philips hue app I ensured the bridge and lamp were functioning and got the bridge IP. I then used the debugger tool of the API to send REST requests checking and changing the lamp’s state before implementing the process inside my app’s code. Then I created a few functions and linked them to a qiChat so that Pepper would control the light when I speak before, as a final touch, allowing my robot to connect to other bridges by implementing a device-finding method. In the end, we have a fully voice controlled light thanks to the help of our robotic assistant.Also, we know how to control a variety of IoT items with Pepper, the next step would be to connect multiple devices at the same time and make the robot some kind of hub, receiving data and sending appropriate orders to all home devices, turning Pepper into your personal butler.

List of the references that has been used to solve this API Challenge