Tutorial adding HUE Motion sensor (Lux,Temp and Motion)

I have tried to follow the tutorial with:

  1. Going to the CLIP API debugger of my Hue Bridge2 ( http://192.168.1.101/debug/clip.html ) and doing af GET with “/api/TheNumbersAndLettersInMyAPIKey/sensors”

  2. Reading the output, finding the relevant information - for example the temperature sensor:

“name”: “Hue temperature sensor 1”,
“type”: “ZLLTemperature”,
“modelid”: “SML001”,
“manufacturername”: “Philips”,
“swversion”: “6.1.0.18912”,
“uniqueid”: “00:16:89:11:32:01:d6:c1-04-0202”

  1. And with that information adding the following to my sensors.yaml:

(not a bullit before “platform: rest” - this is some autoformatting on this website)

I think this should be following the tutorial, but I get this error in my home-assistant.log:

17-01-24 18:18:21 homeassistant.helpers.template: Error parsing value: 'list object' has no attribute 'state' (value: [{"error":{"type":3,"address":"/sensors/00:16:89:11:32:01:d6:c1-04-0202","description":"resourc$

This error goes for all the sensors (three errors when trying all three at once).

What am I doing wrong?
(I have changed/anonymized my hue-IP, API-key and sensor ID in the descriptions above).

It’s a pity I can’t update the initial post anymore to make things even clearer but the ID is what is before the item is mentioned.
So for instance:

	"10": {
		"state": {
			"presence": false,
			"lastupdated": "2017-01-24T20:10:19"
		},
		"config": {
			"on": true,
			"battery": 100,
			"reachable": true,
			"alert": "none",
			"ledindication": false,
			"usertest": false,
			"sensitivity": 2,
			"sensitivitymax": 2,
			"pending": []
		},
		"name": "Woonkamer sensor",
		"type": "ZLLPresence",
		"modelid": "SML001",
		"manufacturername": "Philips",
		"swversion": "6.1.0.18912",
		"uniqueid": "00:17:88:01:02:00:xxxxxx"
	},

then the id is 10 !
NOT the “uniqueid”
So you will use 10 for the Reset rule.

2 Likes

Just to say thanks this is working well… tested only for one night though…I didn’t do any of this virtual switch business, seems like overly complex to me. I guess it would be better if we didn’t have to poll the hue hub every 2 seconds but hey, it works and the pi3 where my Ha runs seems perfectly happy. Now I need to do some cool stuff with it and maybe buy some more hue sensors and bulbs (why is it sooooooo expensive). My wife is tolerating my automation work at the moment, hopefully she’s not seeing the bank bills, need to simplify though as I have far too much going on at present, needs to be easy for others in the house. Need to add a camera also, any recommendations? I had a canary but I don’t want anything with a subscription, fed up of those.

If it helps anyone, here’s my config for the hue motion sensor…

cat devices/sensors.yaml

Questions…

Lux seems to go to 0 with lights off. Normal, guess it is dark! But 0? Also is at a very high number in the day.

Motion sensor seems bang on! Look, no false positives at all at night… same for others ?

Anyone got any great use cases, I figure I’d like to set the house to empty more if there is no movement for say 3 hours from 6am… That should do it I could then set things up on the basis the house is empty, any tips on how to do that?

Temp is nice, I have it near my nest, interesting to see if they tally.

Motion sensor saying True / False … Might be better on off or something, where can I set that?

Thanks again for the tips here, made it to easier…

The filter has a higher precedence than the division. Try
value_template: '{{ ( value_json.state.temperature | float / 100) | round(1) }}'
instead.

1 Like

Is there an easy way to hide my API key when I push my configs to my public github repo?

Cheers.

Not that I know of.

Use secrets.yaml file.

And put this in your sensors.yaml (example)

  - platform: rest
    resource: !secret hue_resource_2
    value_template: '{{ value_json.state.temperature | round(-1) | float / 100 }}'
    unit_of_measurement: °C
    scan_interval: 2
    name: 'Temperatuur bijkeuken'
1 Like

Anyone help me by pasting in their complete sensor settings, am - checking if mine are right or if I can optimise, e.g. lux reads a v high number or 0 at the moment.

platform: rest
resource: http://192.168.Xx.xx/api/APIKEY/sensors/6
value_template: '{{ value_json.state.lightlevel }}'
unit_of_measurement: Lux
name: 'Day Room Lux'

also

Is there a performance hit / advantage fro doing the scan_interval: 2 on all sensors, I have it just on the motion sensor at the moment, things are running ok.

Loving this sensor at the moment, am even thinking of buying another…pricey but cheaper than the multi sensors I read about…with z wave stick required etc. Most pleased with the fact I see 0 false positives, have previously knocked up MQTT sensors with PIR on a remote raspberry - good but fiddly and sometimes see false pos. This hue sensor takes the hassle out of it and get Temps and Lux for free.

Of course! That makes perfect sense. I was thinking about how I could hide just to API part of the URL

Thank you!

would it be some how possible to integrate this with Google Home and let’s say ask about the room temperature ?

Thanks for this tutorial! I was able to add all three sensors from the Hue motion sensor, as well as a battery monitor for it as well.

1 Like

Awesome!

Would you mind sharing how you monitor the battery level?

I’d be interested to see the battery monitor code also.

You have to find the battery sensor number (32 in my case) with the clip web interface of the Hue bridge, just like you found the light and temperature sensors.
The code is:

- platform: rest
  resource: http://192.168.xxx.xxx/api/YOURAPI/sensors/32
  value_template: '{{ value_json.config.battery }}'
  unit_of_measurement: '%'
  scan_interval: 1800
  name: 'Motion Sensor X Battery Level'

Ruud

3 Likes

hey @bingobob and @saesh

How RuudV explained it is how I have it as well. Works very well for tracking the battery tracking. You can use any of the sensors ID’s (LUX, Temp or Motion) to retrieve the battery data as each sensor has the data embedded in it.

thanks, seems to work great, my sensor is newish, showing 100% at the moment.

Am enjoying the reliability of this sensor. Seems great so far.

Great, thanks!

Thanks for the work here guys, I love these little sensors with the available temp, but I currently cannot get any automation working with them. I just did some testing and its not seeing the numeric_state. Though with the Nest sensor I have works fine. Do I need to use another platform?

alias: 'Alert on House temperature'
trigger:
  platform: numeric_state
  entity_id: sensor.house_thermostat_temperature
  above: 10.0
action:
  service: notify.mypushbullet
  data:
    message: "House Temperature Low"

Or the following

alias: Turn on heat in Master Bedroom
trigger:
  platform: numeric_state
  entity_id: sensor.master_bedroom_temperature
  below: 18.0
action:
  - service: climate.set_temperature
    data:
      entity_id: sensor.house_thermostat_target
      temperature: 22.0

cheers,
R

1 Like

Acting upon a temperature threshold can be done with a value_template. See my example below for the Netatmo weather station. I guess it works with the Hue sensor as well.
I use the limit value set by an input selector.

- alias: Notify_if_room_below_limit
  trigger:
    platform: template
    value_template: '{{ (states("sensor.netatmo_room_temperature") | float) < (states("input_select.target_lowtemperature") | float) }}'
  action:
    service: notify.pushover_example
    data:
      title: "Temperature Warning"
      message: "Room is {{ states.sensor.netatmo_room_temperature.state }} °C"
2 Likes

For completeness, here is the code for the input selector in my input_select.yaml file. I prefer input selectors over sliders because sliders don’t show the set value directly in the frontend.

target_lowtemperature:
  name: Room Low Temperature Alarm
  options:
    - 15
    - 16
    - 17
    - 18
    - 19
    - 20
  initial: 18
  icon: mdi:thermometer-lines
2 Likes