Accessing Extra Information from Philips Hue Motion Sensors in Home Assistant

2017-07-16 in Home Automation using tags HomeAssistant , Hue

I use a Philips Hue motion sensor on my front deck to turn on some Hue lights in the front deck and driveway after the sun goes down. It’s cheap and despite it not being rated for outdoors it has had no issues surviving a winter outside under the edge of my front decks roof.

I wanted to be able to directly integrate this into Home Assistant, but while it supports the lights I couldn’t find a way to have it integrate the motion sensors. It turns out the API can be easily accessed at the URL http://yourhuebridgeaddress/api/yourusername/sensors/. You will need to follow the instructions from Philips to setup your own userid but it’s pretty simple. This will then expose a simple JSON output that Home Assistant can easily parse with its RESTful sensor component. Polling is not ideal for motion detection, but it hasn’t been an issue so far.

The first thing I noticed was that there were a lot more sensors showing up than just the motion portion I expected. It seems that this sensor has a daylight sensor and temperature sensor built in that aren’t really exposed well even in the Hue app.

One thing to note as well is that the temperature sensor presents the data as an integer despite it including two decimals of precision so you need to make sure to account for that in your sensor by dividing by 100. Example would be:

- platform: rest
  resource: "http://yourhuebridgeaddress/api/yourusername/sensors/sensornumber"
  name: "Hue Motion Sensor Temperature"
  value_template: '{{ value_json.state.temperature / 100 }}'
  scan_interval: 1
  unit_of_measurement: "°C"

You can get the light level like so:

- platform: rest
  resource: "http://yourhuebridgeaddress/api/yourusername/sensors/sensornumber"
  name: "Hue Motion Sensor Light Level"
  value_template: '{{ value_json.state.presence }}'
  scan_interval: 1

And of course the motion detection that this device is supposed to be used for:

- platform: rest
  resource: "http://yourhuebridgeaddress/api/yourusername/sensors/sensornumber"
  name: "Hue Motion Sensor Motion"
  value_template: '{{ value_json.state.status }}'
  scan_interval: 1