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

Try without the ’
So: below: 200
Also I have this for the lux, don’t know why you have all that floating and rounding.

- platform: rest
  resource: http://blablabla/sensors/11
  value_template: '{{ value_json.state.lightlevel }}'
  unit_of_measurement: Lux
  name: 'Living room'

Oh and when you post code, put on the line before you start the post ```
and also on the line below your code.
Then it’s easier to read.

Thanks for your reply:

The ‘200’ is done via the automation ui, but if I remove the ’ and just write 200 directly in the automations file and reload it then it unfortunately also doesn’t fire.

Original:

- action:
  - data:
      entity_id: light.iris
    service: light.turn_on
  alias: Turn on Iris
  condition:
  - condition: state
    entity_id: light.iris
    state: 'off'
  id: '<id replaced>'
  trigger:
  - below: '200'
    entity_id: sensor.living_room_lux
    platform: numeric_state

New

- action:
  - data:
      entity_id: light.iris
    service: light.turn_on
  alias: Turn on Iris
  condition:
  - condition: state
    entity_id: light.iris
    state: 'off'
  id: '<id replaced>'
  trigger:
  - below: 200
    entity_id: sensor.living_room_lux
    platform: numeric_state

Thanks for the tip regarding ```

I don’t know if the alignment is like that in your yaml file but it doesn’t look good.
Or does the automation ui fix the indent?
Can you align id: right under state?
And did you change the rest sensor thing like mine?

By the way it will only trigger when it goes from above 200 to below 200. Are you sure that’s happening when you want to test the automation?
Just put a light in front of it to it’s above 200 and then make it dark so it goes below.
You can see in the status list what the sensor’s actual status is.

The alignment is done completely by the ui.

You are spot on in regards to the lux has to be over 200 and then under 200 before home assistant switches the light on. Today it worked fine as daylight has been above 200 lux :slight_smile:

Is there any way that the automation will fire even if the lux is never above 200 - just for my understanding.

Maybe when Hass starts (after a restart) but otherwise no, only when it drops below 200, coming from above 200.
What is the reason you are asking?

Okay, it was primarily because I considered making an automation which would trigger the lights as 8:00 in the morning if the lux was below 200, but I have to test out if that works then, because during that time at winter the lux would always be below 200 when I would like it to trigger.

Also it is a difference to what I am used to in Domoticz where it always responds if the lux is under 200, but if the triggers work anyway it doesn’t really matter :slight_smile:

For the light level value, the template should be {{ float(10**((sensor.lightlevel-1)/10000)) | round(2) }} because according to Hue API: “Light level in 10000 log10 (lux) +1 measured by sensor”. (https://www.developers.meethue.com/documentation/supported-sensors)

1 Like

Interesting but still I didn’t set it up like that and it’s working fine :slight_smile:.

I broke out my hue_sensors functionality into a separate .py file, could be useful for debugging.
Hopefully I get the component published soon.

Can anyone assist getting the temperature working, I keep getting the following error in the log and its the only sensor not currently working.

When I do a GET with the following command “http://IP.ADDRESS.HERE/api/API-KEY-HERE/sensors/13” in the API debug tool I get the following output

{
“state”: {
“temperature”: 2365,
“lastupdated”: “2017-10-08T15:55:16”
},
“swupdate”: {
“state”: “noupdates”,
“lastinstall”: null
},
“config”: {
“on”: true,
“battery”: 100,
“reachable”: true,
“alert”: “none”,
“ledindication”: false,
“usertest”: false,
“pending”:
},
“name”: “Hue temperature sensor 1”,
“type”: “ZLLTemperature”,
“modelid”: “SML001”,
“manufacturername”: “Philips”,
“swversion”: “6.1.0.18912”,
“uniqueid”: “blah-blah-blah-02-0402”
}

Below is my sensor config

- platform: rest
  resource: !secret temp_sensor_api
  value_template: '{{ value_json.state.temperature | round(-1) | float / 100 }}'
  unit_of_measurement: °C
  scan_interval: 10
  name: 'Room Temperature'

Error in Hassio log

Error parsing value: ‘list object’ has no attribute ‘state’ (value: [{“error”:{“type”:4,“address”:“/13”,“description”:“method, GET, not available for resource, /13”}}], template: {{ value_json.state.temperature | round(-1) | float / 100 }})

Try without the rounding:
value_template: ‘{{ value_json.state.temperature | float / 100 }}’

Can I safely try this next to what I currently have?
I don’t want to be in an irreversible situation (apart from restoring a backup image).

Thanks for the quick response.

I just realised having read my own post and then checking my config, that I had a typo in my secrets.yaml file!!!

What a doughnut!! :frowning:

1 Like

Sure, no problem. During the testing/transition phase, I just commented out the old setup and put bellow the new configuration.

Can you provide more information as to how I need to set this up?
Will it work with the lights, motion sensor and dimmers?
Will it also keep passing through lux, temp and battery levels?

Suggest you might be interested in the custom component (soon to be added to HA hopefully) on

1 Like

Interesting new component: Timer!

Just follow this :slightly_smiling_face:

So which would be better and less resource hungry?

This: Hue motion sensors + remotes: custom component
Or this: Tutorial adding HUE Motion sensor (Lux,Temp and Motion)

BTW I tried the latter but fail at command: npm install (it says it doesn’t exist).

I don’t know which one is better, but the solution with hue-mqtt-bridge is working great and works with Hue Tap and Hue Motion. If it fails at npm install, maybe you don’t have node installed on your pi. This should help:

curl -sL https://deb.nodesource.com/setup_9.x | bash -
apt-get install -y nodejs