Philips Hue is a line of wireless light bulbs that are controlled with Zigbee signals from a LAN-attached Philips Hue bridge. With the Philips Hue app it is very easy to set up a new system and adding new light sources is a breeze. There is a large set of 3rd party apps that can be used for interacting with the Hue system, but as my home automation system is based on Home Assistant, I use HA as the main controller for Hue. In this post I will show how I have configured Home Assistant for controlling my Philips Hue lights with automation. In an upcoming post I will describe how you can make your own web app for interacting with the light sources via the Hue API.
We live in the countryside – no street lights and with neighbours quite far away. We love the peace of living close to nature, but during a few months of the year it’s really pitch black outside for most of the day. To remedy Darkness, we have many light sources that brighten up the garden, garage and the house. The indoor- and garden lights are automated by 433MHz outlets as described in this post: Home Assistant – integrating RESTful switches, but the lights sources mounted on the outside of the house and the garage (7 in total) had no automation until a few weeks ago. I considered mounting Qubino Z-wave relays but as I don’t like messing around with 220V cables I decided to try out some remote-controlled light bulbs instead. I started out with two warm white Philips Hue bulbs and a Philips Hue bridge. I was surprised at how straightforward it was to configure the system and after testing that the light bulbs worked fine in in sub-zero temperatures, I decided to invest in Hue light bulbs for all of my so-far-not-remotely-controlled outdoor light sources.
The Philips Hue system
The Philips Hue system consists of a LAN-attached bridge and a set of light bulbs. The Hue bridge has a REST api that is used by different apps (like the official Hue app) for controlling the lights. The bridge communicates with the light bulbs with Zigbee signals. As the light bulbs are using Zigbee and are not WiFi connected, the power consumption for the bulbs while they are idle is quite low. Another benefit with Zigbee bulbs compared to WiFi bulbs is that Zigbee bulbs can have a better operating range as they use a mesh network that can relay signals from other Zigbee nodes. The Hue system can be extended with light switches, dimmers and sensors (that are connect with Zigbee), but I use only software for controlling my lights.
There are different types of Philips Hue bulbs. The more advanced have can shift color or change the type of white light that is emitted. My bulbs are the least expensive: warm white lights that can be dimmed.
Philips Hue and Home Assistant
The operations through the Philips Hue API require a valid user-token. A new user resource is generated by the API if you press the button on the bridge and then make a special post request to the API. See https://developers.meethue.com/documentation/getting-started. The response from the request returns a guid-like username. This username can then be used in the API-calls.
Register Home Assistant with the Philips Hue bridge
Home Assistant has some built in functionality for generating a new user and connecting to a Hue system. You have to turn on the discovery component:
Then, restart HA and check that the configurator.philips_hue entity in present in the entity list:
Add this entity to the the default view in Home Assistant and restart HA again:
This will bring up a Philips Hue configurator in the HA GUI:
Press Configure. When the registration dialog appears, press the button on the Hue bridge.
This will create a phue.conf file in the Home Assistant directory. It contains the IP address of the Hue bridge and a new user resource/token. Home Assistant will use this configuration file when communicating with the Hue bridge.
See https://home-assistant.io/components/light.hue/ for details.
Using light entities with Home Assistant
After the phue.conf file has been created, restart HA again. Now you should have a set of light entities discovered by Home Assistant:
If you have set up your Hue system with groups, both light entities and light group entities will appear in the entity list.
To make the light entities appear in the HA GUI, simply add them to a view in the Home Assistant configuration. The example below has the light.garage entity included in my Home Assistant garage group and the garage group is then included in the default view in Home Assistant:
The light.garage entity is a Hue group that groups three Hue lights. With this configuration, I get this GUI in Home Assistant:
Now I can manually turn off all garage hue lights with a toggle switch in Home Assistant!
Having the ability of manual remote control of the lights is nice but with automation we can skip the manual toggling of lights altogether.
With Home Assistant’s automation rules it is possible to automate the Hue lights. I want to turn on my garage lights slightly after sunset and turn them off an hour before sunrise. This automation configuration does the trick for me:
My Home Assistant configuration
My complete Home Assistant configuration is available from GitHub:
Make your own Philips Hue app