dresden-elektronik / deconz-rest-plugin

deCONZ REST-API plugin to control ZigBee devices
BSD 3-Clause "New" or "Revised" License
1.89k stars 498 forks source link

Aqara Door/Window Sensor Temperature #530

Closed mercballs closed 5 years ago

mercballs commented 6 years ago

Would it be possible to expose the temperature from the Aqara door/window sensors as separate sensors? I believe it would make it easier to use this data if all temperature sensors were exposed in a standardized way.

nerdosity commented 6 years ago

Why? They don't have temperature measurement. I used them with Xiaomi official app, and they just report battery and opening state.

mercballs commented 6 years ago

They do have a temperature sensor. The temperature is reported in deconz and in the rest API.

gjong commented 6 years ago

I have seen the temperature reading in deconz as well. But as far as I know the door sensor had no temperature sensor in it. Be sides the reading makes no sense, as I doubt it was 30+ celcius in the room the sensor when the room next to it was only 22 degrees.

nerdosity commented 6 years ago

Yeah, very useful. I see, just one of my three sensors actually reports a temperature.

image

That was:

So, even if some device reports temp, that stay as totally pointless.

mercballs commented 6 years ago

I believe they only report temperature when the door/window status changes. For sensors that are used most often, I find the readings pretty good. For sensors that have not been operatred in a while I would agree that the temperatures are off.

I have written a node-red flow to pull these temps from the rest-api and publish them to mqtt so I can view them in home assistant. If anyone is curious, here it is: [{"id":"7f0b743d.047d1c","type":"inject","z":"750675f2.f9148c","name":"","topic":"","payload":"","payloadType":"date","repeat":"60","crontab":"","once":false,"onceDelay":0.1,"x":370,"y":220,"wires":[["4cfe459a.ab9d6c"]]},{"id":"4cfe459a.ab9d6c","type":"http request","z":"750675f2.f9148c","name":"","method":"GET","ret":"obj","url":"http://192.168.10.201/api/AA8F97682F/","tls":"","x":530,"y":220,"wires":[["8ff6f380.752d5"]]},{"id":"9d66fe59.38e64","type":"mqtt out","z":"750675f2.f9148c","name":"","topic":"","qos":"0","retain":"true","broker":"3e01161.062e5ea","x":870,"y":220,"wires":[]},{"id":"8ff6f380.752d5","type":"function","z":"750675f2.f9148c","name":"CRAZY","func":"var obj = msg.payload.sensors;\nvar keys = Object.keys(obj);\nvar names = [];\nvar temps = [];\n\nfor(var i=0; i<keys.length;i++) { \n if ('config' in obj[keys[i]] && 'temperature' in obj[keys[i]].config) {\n \n names.push(obj[keys[i]].name);\n temps.push(obj[keys[i]].config.temperature);\n \n //node.warn(obj[keys[i]].config.temperature.toString());\n }\n}\nmsg = {};\nfor(var i=0; i<names.length;i++) { \n msg.payload = Math.round(temps[i] / 100 * 1.8 + 32);\n \n msg.topic = \"temps/\" + names[i];\n node.send(msg);\n}\n","outputs":1,"noerr":0,"x":700,"y":220,"wires":[["9d66fe59.38e64"]]},{"id":"3e01161.062e5ea","type":"mqtt-broker","z":"","broker":"192.168.10.14","port":"1883","clientid":"","usetls":false,"compatmode":false,"keepalive":"15","cleansession":true,"willTopic":"","willQos":"0","willPayload":"","birthTopic":"","birthQos":"0","birthPayload":""}]

image

Kane610 commented 6 years ago

@manup any thoughts on this?

manup commented 6 years ago

Since the temperature reported by non temperature sensors of Xiaomi is very coarse, there are currently no plans to put the little extra info in a rest api sensor resource.

The coarse temperature value might not be used as reliable temperature but I don't think it's useless, for example it might be used for automations which use night/daytime differences of the reported value.

stale[bot] commented 5 years ago

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

JSkier21 commented 5 years ago

I've been testing one of these recently as well. deconz reports the temp, but homeassistant does not. If it has temperature capabilities, it should expose this, otherwise if not, it shouldn't.

Confusing because the wiki claims the temperature capability is supported; although it is not fully supported.

Kane610 commented 5 years ago

@JSkier21 there is no support yet for the secondary temperature sensor certain Xiaomi devices report. I'm refactoring the deconz library and that will help in the possibility of supporting the secondary sensors later on, since due to the old design there could really only be one origin of the temperature sensor. It has been stated on multiple occassions that those temperatures are unreliable so I have also previously decided against supporting them.

ebaauw commented 5 years ago

those temperatures are unreliable so I have also previously decided against supporting them.

Indeed. I don't support them in homebridge-hue either.

JSkier21 commented 5 years ago

Thanks for the feedback @Kane610 and @ebaauw. The nature of it makes sense; my Lightify motion sensors work great, but different brand + setup.

Kane610 commented 5 years ago

@JSkier21 you're saying that you have Osram devices reporting temperatures in config? Are they reliable?

ebaauw commented 5 years ago

my Lightify motion sensors work great

PIR motion sensors are thermometers; they detect motion by changes in the IR spectrum.

Osram devices reporting temperatures in config

Afaik, config.temperature is used only for the onboard temperature reported by Xioami devices in their special attribute report. I suspect the OSRAM lightify motion sensor exposes a Temperature Measurement cluster (like the Hue motion sensor), which the REST API exposes as a separate ZHATemperature sensor.

Kane610 commented 5 years ago

If that is the case it should work for home assistant

JSkier21 commented 5 years ago

@ebaauw is correct, ZHATempature has the value on the Lightify motion sensor. Readings are very similar (within one degree) to a dht22 sensor I have nearby, which is accurate.

Thus, value is visible in API and also passed on to homeassistant.