Philips Hue and Home Assistant

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.

Background

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.

hue_starter_kit.jpg

A Philips Hue bridge and two warm white smart E27 bulbs

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

Authorization

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.

clip_api_debugger_new_user

The built-in api debugger for a Philips Hue bridge

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:

configurator_philips_hue_entity

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:

philips_hue_configurator

Press Configure. When the registration dialog appears, press the button on the Hue bridge.

philips_hue_ha_registration

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:

philips_light_entities

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:

garage_group_with_philips_hue

Now I can manually turn off all garage hue lights with a toggle switch in Home Assistant!

Automation

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:

https://github.com/LarsBergqvist/Home-Assistant_configuration

Make your own Philips Hue app

In my next post, I will show how you can make your own web application for Philips Hue with React and JavaScript.

A React app for Philips Hue lights

 

Advertisements

4 Comments

  1. Hej Lars!

    Quick tip: I was going for Philips Hue but its like really expensive if you have 2 floors + basement + garage + huge garden – so I found Xiaomi’s smart wifi RGB bulbs – YeeLight (120SEK/st) no bridge needed. Xiaomi also has a number of smart sensors (button, motion, temp, cameras etc) all talk zigbee and cost like 70kr/st – and the gateway is only like 250kr – and it works over HomeAssistant (there is a even a plugin available).
    I bought my gear on gearbest.com. Before that I was doing my own sensors but its way quicker, looks nicer and almost the same price with Xiaomi’s stuff.

    Like

    Reply

  2. Hey,
    The bridge got discovered. But “configurator.philips_hue” is not shown in the entity list. Can you please guide me?

    Like

    Reply

    1. Hi, the Philips Hue integration for Home Assistant might have changed since I wrote the blog post. Do any light entities from the hub appear in the entity list?

      Like

      Reply

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

w

Connecting to %s