Aqara temperature sensors and Node Red – Info Overload?

AsI was sitting checking ny Aqara Zigbee temperature sensors (blogged a while ago) using the Node-Red nodes for the job, I noted that if I covered the sensor with my hand for a few seconds, I’d get a reading – sadly, not just that but THREE readings within a second. No problem with one sensor but if you have several and there’s, say, agust of wind, that could end up as one hell of a lot if un-necessary info coming back at you.

So off I went to use the RBE node which only allows payloads through for a given topic, on change. Two issues there, RBE is no more, replaced by the “filter” node – and I’m neither using msg.topic nor msg.payload. Easily solved – read on.

So above you see my incoming nodes giving the complete state of each of my two Aqara sensors. In that object there is a LOT of info but you can directly access msg.device.friendly_name and msg.payload.temperature which is what I do with that cream-coloured function node. But FIRST I’m now using the filter node included in Node-Red since around Node-Red 2.0

Filter usage is default – note in the image on the left what I’ve put in there.. and sure enough it works – the function to the right then merely converts msg.payload temperature into payload plus a space and msg.device.friendly_name into msg.payload for the debug. Works a treat.

if only life were generally this simple. Instead of a barrage of info I now get only what I need. Next step is to add a simple .toFixed(1) to the temperature part to get rid of that over-the-top level of precision. Done.

msg.payload : string[17]
"23.4 aqara-temp-1"
12/01/2022, 22:11:17
msg.payload : string[17]
"23.5 aqara-temp-2"
12/01/2022, 22:11:24
msg.payload : string[17]
"24.1 aqara-temp-1"

Just to be awkward, my Aqara TVOC sensor has a different format – out of that comes msg.temperature, msg.humidity and msg.voc so this isn’t a universal technique but you get the general idea. I looked at the entire object coming from the node I had set up to read the TVOC to find that out.

Facebooktwitterpinterestlinkedin

Leave a Reply

Your email address will not be published. Required fields are marked *

Leave the field below empty!

The maximum upload file size: 512 MB. You can upload: image, audio, video, document, spreadsheet, interactive, text, archive, code, other. Links to YouTube, Facebook, Twitter and other services inserted in the comment text will be automatically embedded. Drop file here