Hey,
is there a way to create an on/off switch/script inside HASS for the Hue motion sensor? I want to be able to enable/disable specific motion sensors on demand through Alexa (I have nabucasa subscription running). Is this possible?
Hi,
in case this is still relevant:
You can turn on/off a hue motion sensor through the Hue REST API by issuing a PUT
request to /api/<userid>/sensors/<id>/config
.
The body should be {"on":true}
to turn the sensor on, or {"on":false}
to turn it off.
So with that we can use the RESTful Switch component and build us a nice handy switch to turn the sensor on and off:
platform: rest
resource: http://<IP>/api/<USERID>/sensors/<SENSORID>/
name: 'Hue Motion Sensor'
method: put
body_on: '{"config": {"on":true}}'
body_off: '{"config": {"on":false}}'
is_on_template: '{{ value_json.config.on == true }}'
headers:
Content-Type: application/json
where <IP>
is the IP address of the hue bridge, <USERID>
is a valid user id to access the bridge (see the phue.conf file) and <SENSORID>
is the id of the specific motion sensor.
You can get the sensor id by issuing a GET
request to /api/<USERID>/sensors
and looking through the output.
Hope that helps,
Sebastian
Hi where do you find the Sensor ID I have the post output but struggling to see it
Use something like this to query your bridge:
curl http://<IP>/api/<USERID>/sensors | python -m json.tool | less
You should get a block of nicely formatted JSON output, like so:
"33": {
"capabilities": {
"certified": true,
"primary": true
},
"config": {
"alert": "none",
"battery": 95,
"ledindication": false,
"on": true,
"pending": [],
"reachable": true,
"sensitivity": 0,
"sensitivitymax": 2,
"usertest": false
},
"manufacturername": "Philips",
"modelid": "SML001",
"name": "Flur Sensor",
"productname": "Hue motion sensor",
"state": {
"lastupdated": "2020-01-20T15:49:53",
"presence": false
},
In my case, “33
” is the sensor ID.
Sebastian
Thank you,
that really helped I was expecting low consecutive numbers but they range from 24 to 51
I’ve also implemented the Hue Motion Sensor switches. However I faced a problem with enabling the motion sensors from HA. So for anybody facing the same here are my findings. If you disable the motion sensor from the Hue application (and possibly any other than from HA) and enable it from HA it looks enabled (also in the Hue application) but it isn’t really. If you open options from the Hue application like light settings it will state it can only show the settings if the sensor is enabled. Even though it looks enabled. Only solution I found is only disable it from HA and not from the Hue application. Enabling it from HA if disabled also from HA works correctly.
I apologize for a noob question, but where exactly do you enter this query? Thank you.
On a Linux command line with curl and python installed, preferably.
Alternatively, there’s also a debug tool provided by the hue bridge, that you can access at http://<hue_bridge_ip>/debug/clip.html
.
Enter the correct user id (and add /sensors
at the end of the pre-filled query) and click the GET
button - this should return the sensors list.
Sebastian
Nevermind, please. I used node red’s “inject”,“http request” and “debug” nodes. Thanks anyway. This post was very helpful.
Oh, thank you for your very quick response! I posted my reply about node red at the same time you posted yours.