Good shout!
I use the motion sensors in HA. I use the rest-component in HA to set it up.
I donāt know if this has been mentioned but the Hue API also exposes the presence as a sensor, appearing in mine as:
{
"state": {
"presence": true,
"lastupdated": "2017-07-22T11:52:42"
},
"config": {
"on": true,
"reachable": true
},
"name": "Robins iPhone",
"type": "Geofence",
"modelid": "HA_GEOFENCE",
"manufacturername": "Philips",
"swversion": "A_1",
"uniqueid": "L_02_IYwHM",
"recycle": false
}
Thanks for sharing.
I personally donāt want Philips to know where I am so I donāt have an account linked and thus no presence detection.
Anyone have an issue with these virtual sensors disappearing upon a power cycle/loss with the HUE hub? Power went out a few days ago and I lost all of my virtual sensors. It was only two so it wasnāt a big deal to recreat, but stillā¦
Is there a way to back up the configuration? Should it store these changes?
Thanks,
Yes that happens. Also when you change the sensitivity for instance through the Hue app I noticed I lost some rules and entries.
So what I did is keep a copy of what I entered in a document and once it happens I copy paste is quickly again.
Iām using the motion sensors without using the āvirtual sensorsā and work great!
binary_sensor:
- platform: rest
resource: http://<bridge ip address>/api/<username>/sensors/15
name: living_room_motion_sensor
value_template: '{{value_json.state.presence}}'
scan_interval: 1
Iām having some problems setting this up.
I guess this is my motion sensor:
ā5ā:{āstateā:{āstatusā:0,ālastupdatedā:ā2017-08-10T05:30:39ā},āconfigā:{āonā:true,āreachableā:true},ānameā:āMotionSensor 3.Companionā,ātypeā:āCLIPGenericStatusā,āmodelidā:āPHA_STATEā,āmanufacturernameā:āPhilipsā,āswversionā:ā1.0ā,āuniqueidā:āMotionSensor 3.Companionā,ārecycleā:true},
And this is my config:
- platform: rest
resource: http://192.168.1.23/api/myapikey/sensors/5
name: āBewegungsmelderā
value_template: ā{{value_json.state.presence}}ā
scan_interval: 1
My sensor will show up in homeassistant but it doesnt report any state. It is just empty
Doesnāt look correct return from the API. See https://www.hackster.io/robin-cole/boil-my-kettle-when-i-get-out-of-bed-in-the-morning-10e7de
You are right, thank you for the link.
This is how the sensor should look like:
"3": {
"state": {
"presence": false,
"lastupdated": "2017-04-15T19:32:23"
},
"config": {
"on": true,
"battery": 100,
"reachable": true,
"alert": "none",
"ledindication": false,
"usertest": false,
"sensitivity": 2,
"sensitivitymax": 2,
"pending": []
},
"name": "Unten Sensor",
"type": "ZLLPresence",
"modelid": "SML001",
Great tutorial. Have followed and worked out greatā¦ twice. Seems if you change IP address the key needs to be reset. Am I right in saying that as I moved from one hardwired access point to another (with different IP) I just setup again after no motion sensor detection? Had no issues in doing so but just wanted to double check
Glad I did as I setup the lux and temp sensors now. Pal I owe you a few internet pints
One thing iāve noted with my dealings though is that instead of motion sensor detection āTrueā is that it shows as ā1ā or ā0āā¦ which is no biggie but just wondering why it aint matching with ātrueā or āfalseā
Always grateful for an internet pint
To avoid the changing IP I recommend setting a DHCP reservation on your router.
Iāve also noticed that if you remove and then re-add a sensor in the Hue app, it is assigned a different index.
Re 1, 0, I havenāt encountered that, be interested to hear if you get to the bottom of it. Cheers
Is it possible to set the scan_interval to less than a sec (e.g. 500 ms) ?
I set scan_interval = 0.5 and appears to make no difference. I also removed scan_interval and that made no difference. Therefore I conclude that scan_interval is not required (it is not in https://github.com/home-assistant/home-assistant/blob/dev/homeassistant/components/sensor/rest.py)
I took the steps above without any problems. However when I restarted HA I get this error
2017-08-13 15:37:52 ERROR (Thread-5) [homeassistant.components.sensor.rest] Error fetching data: <PreparedRequest [GET]>
2017-08-13 15:37:52 ERROR (Thread-5) [homeassistant.components.sensor.rest] Unable to fetch REST data
-
platform: rest
resource: http://huebridgeipaddress/api/myapikeyhere/sensors/7
value_template: ā{{ value_json.state.lightlevel }}ā
unit_of_measurement: Lux
name: āMaster Bedroom Lights Sensorā -
platform: rest
resource: resource: http://huebridgeipaddress/api/myapikeyhere/sensors/7
value_template: ā{{ value_json.state.temperature | float / 100 }}ā
unit_of_measurement: Ā°C
name: āMaster Bedroom Temperature Sensorā
Does anyone know why Iām getting that error?
Ip of the bridge hasnāt changed and Hue component is otherwise functioning without errors?
Yes the IP is still the same and the Hue component is functioning correctly.
Iād check what is being returned by the rest call. Have noticed that adding new devices can change the ordering of sensors etc
EDIT: Now using Deconzā¦ even better !
I moved my Hue Motion sensors from rest to MQTT using hue-mqtt-bridge and the delay is much better !
binary_sensor:
- platform: mqtt
device_class: motion
state_topic: hue/my_sensor/presence
name: āSensor Motionā
payload_on: ātrueā
payload_off: āfalseā
I followed the tutorial to add the light sensor (not the others) in REST. My configuration file looks like this:
-
platform: rest
resource: http://āIP Adressā/api/āUserā/sensors/6
value_template: ā{{ (10 ** (float(value_json.state.lightlevel) / 10000) -1) | round (1)}}āunit_of_measurement: Lux
name: āLiving Room Luxā
It works fine and home assistant receives data. However when I try to use the lux in an automation, the automation does not trigger. My automations file looks like this:
- action:
- data:
entity_id: light.iris
service: light.turn_on
alias: Turn on Iris
condition: - condition: state
entity_id: light.iris
state: āoffā
id:
trigger: - below: ā200ā
entity_id: sensor.living_room_lux
platform: numeric_state
- data:
If I change the automation to start at for instance 20:00 it works fine, so it is only the trigger that is failling.
Any ideas?