Email alert when sensor battery is low

I have a flow that processes my Acurite temperature/humidity sensors sent from rtl_433 via MQTT. One of the fields the sensor provides is a battery_ok value which is 1 when normal and returns 0 when it drops below a predefined threshold.

I have some code that I thought would work but today when this sensor transitioned from 1 to 0 I ended up getting dozens of emails. I am assuming that's because it wasn't a clean transition from 1 to 0. I'd appreciate any recommendations that could be provided.

This is the battery notification section less the email generation itself.

[{"id":"95956d64.1c802","type":"switch","z":"b76701c5.7313f","name":"","property":"payload.battery_ok","propertyType":"msg","rules":[{"t":"lt","v":"1","vt":"num"}],"checkall":"true","repair":false,"outputs":1,"x":1110,"y":260,"wires":[["47cfdca2.e40a04","9eee43be.5f0678"]]},{"id":"47061126.bf4668","type":"comment","z":"b76701c5.7313f","name":"battery notification","info":"","x":850,"y":220,"wires":[]},{"id":"f6e008da.ac0fc","type":"change","z":"b76701c5.7313f","name":"","rules":[{"t":"delete","p":"payload.time","pt":"msg"},{"t":"delete","p":"payload.tempF","pt":"msg"},{"t":"delete","p":"payload.temperature_C","pt":"msg"},{"t":"delete","p":"payload.humidity","pt":"msg"},{"t":"delete","p":"payload.moisture","pt":"msg"},{"t":"delete","p":"payload.moisture_offset","pt":"msg"},{"t":"set","p":"topic","pt":"msg","to":"","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":840,"y":260,"wires":[["88ceb81.c18a1c8"]]},{"id":"88ceb81.c18a1c8","type":"rbe","z":"b76701c5.7313f","name":"","func":"rbei","gap":"","start":"","inout":"out","property":"payload.battery_ok","x":990,"y":260,"wires":[["95956d64.1c802"]]}]

You can use a delay node to limit the number of emails, for example 1 per day:

ps you asked a similar question 6 months ago, I think this answer is better than my suggestion then!

1 Like

I should have mentioned the previous question and even linked it. I decided not to bump an old thread and rather ask again in a slightly different way (since I now have working code). I used those suggestions here but now that I have an example of a battery dying (first time the code has triggered) I realized that it does not work as I had hoped. Ideally I would have it so the trigger would see the battery_ok drop below zero and then send 1 message per day. But I think having the property go back up to 1 might reset things. I'll try the delay and see if that helps. So far today I have over 40 notifications that one battery is dying.

I added the delay and can see the battery_ok oscillating but no new emails. I'm going to reduce the frequency to 10 minutes to test that it's working as intended but it looks like this should be a viable fix. Thanks!

The sensor is being a bit finicky now but it does appear that the 10 minute delay is working. I have a lot of various sensors so will implement this in each location. Thanks for the suggestions (this time and last)!

I have something very similar in place to monitor a Victron ESS installation. I use a couple of variables in context to monitor if the status has changed and a delay node to filter out fast transitions between 0/1. The combination of the two makes it stable.

1 Like

You may want to put in a longer delay before notification, or another notification that the the battery is definitely dead.

I don't know about your sensors but I have an Oregon-THGR810 (temperature/ humidity sensor) that has been claiming a low battery for the last 2 months, and is still going. (same battery_ok attribute of 1 or 0)

I don't know the actual dead point but if I could figure it out, I could estimate how long it would take to actually die and then notify once a week until I got to the real critical time and then once per day. And if I really knew what I was doing, have something in the flow that looks for the last time the sensor sent data and if it was more than a threshold value, send a notice saying the sensor's battery died. But then, I tried that and it didn't work. I've got something that appears to be working now so I'll watch it for a while and see if I need to tweak any further.

This topic was automatically closed 60 days after the last reply. New replies are no longer allowed.