Advice for monitoring a backup status

TL;DR: I would like to update sensors when backups are successful (or not). If the status of the backup does not change for too long a time, I would like to get a notification.

I use a wrapper around restic to manage my backups. I wrote the wrapper myself so I have complete control over its actions. Today it sends me an ntfy notification in case of errors.

Another dangerous case I would like to handle is the lack of backups (for any reason - let’s say my program crashed). This must obviously be done outside of my program, and an idea I have is to set a sensor in Home Assistant which would send a warning if its state does not change for, say, 26 hours (to account for a full day and some).

The update of the sensor can be via MQTT or an API call. This part is (hopefully) easy.

Now to the “idleness” of the sensor: is there a trigger that would say “if idle for x time”?

This would be an ideal trigger for my automation but I do not see it neither in the available states when creating a trigger, nor in the documentation AFAICT.

So question 1: is there such a thing?

My planned workaround is

  • either a cyclic automation that would check the sensor (its value would then be an EPOCH timestamp) and its difference with the current time is greater than something then it would trigger the alert
  • or a standalone container that would do the checks via the API and send the warnings

Question 2: maybe there are better ways to do that?

I am trying to reuse as much as possible the power of HA as a state machine so the approach with an “idle state” would be ideal, but I am open to anything.

Note: after considering this question for some time, I found Backup Monitoring with Home Assistant - Opus Perpetuum whch covers exactly this, but it uses an Idle state that I do not see in HA

Ahhhh, after reading carefully the blog above i now understand how it works. the state is set to Idle (it can be anything), and the trigger uses for after a “change” (“the status is changed and stays the same for …”).

For instance

would mean “trigger if the battery status is ‘Charging’ for 50 hours or more”

If this works it would be the perfect solution!