Aquara motion sensor temperature value is not reported to home-assistant
Gronis opened this issue · 9 comments
In deconz, I have a Xiaomi aqura motion sensor which reports motion, light intensity (lux) and temperature. In home assistant, I can read the light intensity under "sensor" and motion under "binary_sensor" component. However, the temperature is not reported to hass. This would be desirable.
I'm running home-assistant v0.79.3, and deconz 2.05.39 with firmware 26240500 on conbee
Hmm. If it reports temperature correctly it should appear. Can you enable debug per component documentation and post the json data for that device?
I just saw your post in Svenska hemautomatiseringsgruppen. I didn't realize it is the same as the once in door sensors. There is a different PR requesting support for the door sensors and due to the poor quality of the temp sensor I'm not inclined to add support for it.
As I understand, the readings are not very accurate. I'm not sure if that is because of a bad sensor or bad tuning of the sensor. Personally, my readings are very stable, but it seems to be slightly higher than ground truth, so it might be a tuning problem.
Either way, I understand that you are not inclined to add support for it, but since the temperature is reported to deconz by the sensor, I think it's accurate to report it to home-assistant as well.
I started looking into this and here is an example of what deconz sends on the REST API (badly formated):
"18":{ "config":{ "battery":100, "on":true, "reachable":true, "temperature":2400, "tholddark":12000, "tholdoffset":7000 }, "ep":1, "etag":"6f5621302c442acd784b9d85ee7a191e", "manufacturername":"LUMI", "modelid":"lumi.sensor_motion.aq2", "name":"PIR5", "state":{ "dark":true, "daylight":false, "lastupdated":"2018-10-24T18:22:40", "lightlevel":0, "lux":0 }, "type":"ZHALightLevel", "uniqueid":"00:15:8d:00:02:22:be:5a-01-0400" }, "19":{ "config":{ "battery":100, "duration":60, "on":true, "reachable":true, "temperature":2400 }, "ep":1, "etag":"6f5621302c442acd784b9d85ee7a191e", "manufacturername":"LUMI", "modelid":"lumi.sensor_motion.aq2", "name":"PIR5", "state":{ "lastupdated":"2018-10-24T18:23:41", "presence":false }, "type":"ZHAPresence", "uniqueid":"00:15:8d:00:02:22:be:5a-01-0406" },
The temperature is for some objects stored in the "ZHALightLevel" object as a value in the "config" section and for some under the same sction in the "ZHAPresence" object. And for the Aqara water sensors it is the same place but for the "ZHAWater" object.
One possible solution would be to do similar to how battery is handled in DeconzSensor class and store like this:
self._temperature = device['config'].get('temperature')
Also to note is that some devices have the temperature value but it's always 0.
I guess since the battery is reported and that isn't very accurate (always stuck at 100%) then why shouldn't the temperature be able to be reported?
Same place for different sensors then. Yes that would be the solution.
But apart from Xiaomi there are other devices that send battery in a proper way so just because Xiaomis battery status isn't the most accurate doesn't actually warrant supporting their poor temperature sensor as well ;).
I also want to avoid creating sensors that always report 0 as a value. We have this issue with certain Osram power plugs reporting 0 for power usage. And I really want to avoid a lot of extra checking for devices with 0-values that can be ignored in HASS. Maybe when hass supports ignoring specific entities...
Reporting static 0 values is bad but reporting static 100% values are equally bad. I wish the battery worked because I think the values are actually sent in the zigbee msgs, just in a non-standard way.
I first tried to get the temperature values by making a custom component of deconz in HA but it's not possible for a user of pydeconz to get the temperature values since the values in "device['config']" are not stored anywhere and are thrown away in init. Might be possible to do some python magic but I just need a way to get the temperature value from the object.
Another solution is to store the whole config but that kind of works against the separation of concerns...
A third solution is just that I give up and try to parse the values with a REST component myself.
If you do a custom component you could as well fork pydeconz
I am improving pydeconz to map all attributes of devices (including this temperature value) so it will be added to hass in release 88 or 89.