Hue Lights Setup

Before your can control our lights with the PyPortal, we'll need to set which lights we'd like to control within the code ( 

Open the Philips Hue application on your phone/tablet.

Navigate to Settings->Light Setup

The number next to the light is the light identifier. You'll be using this value in the code to refer to the light which you're setting.

  • Tapping the next to the light's name will bring up more information about it - like which room/group it's assigned to and the full name.

Next, you'll modify the following lines of code to correspond with the light identifier you're controlling.

For example, if you are setting up a lamp an identifier of 3 and a living room light with an identifier of 1, edit the following line in from:

hue_lights={'lamp': 1, 'livingroom': 2}


hue_lights={'lamp': 3, 'livingroom': 1}

Code Usage

From the Mu Editor, click the Serial button to open the REPL. You should see the REPL display the code's status as it loads the interface.

Select a light by tapping the name of the light you'd like to control. The code will default to the first light specified within the hue_lights list.

Tap the on/off button to toggle the power of the light you selected. 

  • Buttons invert their color while they make a request to the Hue Bridge. Once the request is complete, the button changes back to its original color. 
  • If you're having issues with your light not responding: Scroll down to the Diagnosing Errors section below.

Diagnosing Errors

Tapping a color button will set the light to the button's fill color.

  • We used the Hue library's rgb_to_hsv method to set different colors for the buttons. For more information about this method and how the code works, navigate to the Code Walkthrough page for this guide.

This guide was first published on Apr 19, 2019. It was last updated on Apr 19, 2019.

This page (Code Usage) was last updated on Apr 12, 2019.

Text editor powered by tinymce.