All credits go to nicky2b who wrote this tutorial in Dutch and approved me translating it and posting it here.
How to get the Lux and Temperature sensor in HASS, as well as a binary Motion sensor.
To get this working you’ll need:
- HASS (Home Assistant)
- API-key/User of the Hue bridge (register here and read how to get your API Key and create a user: http://www.developers.meethue.com/documentation/getting-started)
- Web browser (to work with the CLIP API Debugger
Of course you first need to link your Motion sensor to the Philips Hue Controller and create a User and API-key
Lightsensor and temperature sensor:
It’s quite easy to add these to HASS using the REST platform.
Open the CLIP API debugger in a browser: http://YOUR HUE BRIDGE CONTROLLER/debug/clip.html
and do a GET on /api//sensors.
This gives you a list of all your Hue sensors. Look up the lightsensor (ZLLLightLevel) and temperature sensor
(ZLLTemperature) and write down the id numbers.
Now you can create the sensor in HASS:
- platform: rest
resource: http://[bridge IP]/api/[API-key]/sensors/[sensor id]
value_template: '{{ value_json.state.lightlevel }}'
unit_of_measurement: Lux
name: 'Living Room Lux'
- platform: rest
resource: http://[bridge IP]/api/[API-key]/sensors/[sensor id]
value_template: '{{ value_json.state.temperature | float / 100 }}'
unit_of_measurement: °C
name: 'Living Room Temperature'
Of course fill in your bridge ip address, API Key and sensor id’s in the right place.
Motion Sensor:
Now because the motion sensor will only report to the bridge and not to HASS, so you will need to poll the bridge from HASS.
To get this polling working you will need to add some rules to the bridge using the CLIP API Debugger.
First add a virtual motion sensor:
Do a POST on the following url /api/APIKEY/sensors with this body, to create a virtual motion sensor. You can change the names if you want:
{
"name": "LivR.Presence",
"type": "CLIPGenericStatus",
"modelid": "PHA_STATE",
"manufacturername": "Philips",
"swversion": "1.0",
"uniqueid": "LivR.Presence",
"recycle": false
}
Write down the id that you get back. That’s the virtual motion sensor ID.
Link the physical to the virtual motion sensor:
For instance my physical motion sensor id is: 8
My virtual motion sensor id is: 17
Do a POST on the following url: /api/APIKEY/rules with this body to add the rules to your bridge.
Of course change the ID’s with your ID’s:
{
"name": "Wnk.Presence",
"conditions": [
{
"address": "/sensors/8/state/presence",
"operator": "eq",
"value": "true"
},
{
"address": "/sensors/8/state/presence",
"operator": "dx"
}
],
"actions": [
{
"address": "/sensors/17/state",
"method": "PUT",
"body": {
"status": 1
}
}
]
}
Rule for automatic resetting (duration after no motion was detected) of the virtual motion sensor:
Do a POST on the following url: /api/APIKEY/rules with this body to add the rules to your bridge.
This will reset the virtual motion sensor after 5 minutes of no motion detected.
Of course change the ID’s with your ID’s:
{
"name": "Wnk.Presence.Reset",
"conditions": [
{
"address": "/sensors/8/state/presence",
"operator": "eq",
"value": "false"
},
{
"address": "/sensors/8/state/presence",
"operator": "ddx",
"value": "PT00:05:00"
}
],
"actions": [
{
"address": "/sensors/17/state",
"method": "PUT",
"body": {
"status": 0
}
}
]
}
Now the virtual motion sensor should switch on together with with the physical motion sensor and switch off after 5 minutes.
Adding the virtual switch to HASS:
Last step is to add the virtual switch to HASS like this:
- platform: rest
resource: http://[bridge IP]/api/[API-key]/sensors/[sensor id]
value_template: '{{ value_json.state.status }}'
name: 'Livingroom Motion'
Now you can use the sensors within HASS for other automations. Like non Hue lights, or alarms (motion detected while you’re not at home? Probably a burglar) or what not.