I am trying to get a low-battery warning for my various Insteon Leak sensors, which talk to HA through MQTT. In addition to wet/dry, they each connect daily for a ‘heartbeat’. This shows up in HA as a timestamp entity. I pulled one battery out and sure enough, the timestamp of that sensor’s heartbeat still shows the last day it was successful. So, I need an automation that notifies me when any of those heartbeat sensors’ entities states gets to be more than 2 days ago. But it’s not formatted nicely, so I am stuck.
Right now, the State of the Entity i’m playing with says this “2022-04-22T22:48:32+00:00”.
Can anyone help me make an automation that constantly monitors those entities and fires whenever that timestamp strays further than 2 days from current time?
I love the idea of using Alert instead of a single iOS notification action. Thank you for mentioning it.
So far I have 3 Template Trigger suggestions so I set up a single new automation with all 3 as different Triggers, each with a TriggerID. I’m going to pull out a sensor’s battery and wait 2 days to see which triggers fire.
Once I have confirmation that the triggers work, i’ll set up the Alert Integration as the Action for this Automation by creating a new Helper Input Boolean that gets changed to “on” to trigger the Alert. (Hope I have that right)
Thank you for the suggestions. After reviewing the help pages, I put together the following chunk of code which I intend to add to the bottom of my configuration.yaml file. Does this look right?
Question: How do I add more than one leak sensor to this alert? I have about a dozen sensor.ls_whatever_heartbeat devices scattered around the house. How do I set this up to trigger for any/all of them?
Sorry, that is beyond me. I dont understand how to ensure that all my leak sensors are included.
I get lost at the value_template in that thread you linked. I dont even see anything in my HA entities that shows that these heartbeats are device_class: battery - if that’s even the right question to be asking…
I am asking for help. Maybe point me in the right direction to show me what I need to learn…? It’s the value_template bit, no?
I didn’t ask you to re-engineer anything. I asked you to help me understand how it works. If you cant be bothered, why are you so active on this forum?
That was a really unhelpful, toxic response when I am just trying to learn. It’s not like there’s good documentation for this.
I wouldn’t even mind listing them each one at a time. Would that make it easier than trying to learn how the value_template bit automatically grabs each ls sensor I am concerned about?
Solution found.
I got 3 suggested “template”-based automation triggers. I made an automation with all 3 and found only 1 works. So here’s that: {{ now() - states(‘sensor.ls_attic_heartbeat’) | as_datetime > timedelta(days=2) }}
In addition, I created a text helper. So I have 1 automation that lists a dozen triggers, each Templates with the code above (swapping in the names of each sensor). That automation both sets my text helper to trigger my new Alert - and it sends me a notification directly since that direct automation can actually identify which sensor died.
As a result, whenever any of my sensors miss a daily check-in, I get a notification identifying the dead battery and I get a repeat of that notification (Alert) every hour until I do something about it.