Creating automation via GUI using Value template and timestamp

As always I am struggling finding a concreate example to help me create the automation I need.

I would rather use the GUI, appreciate you might have an example that would work using code but I much prefer it this way.

I’m using PiHole, I am aware that last changed/updated/timestamp values might be updated to 0/now on reboot, I can live with that.

I would like a notification when the stats are not updated within the last 6min. It updates roughly every 5 so this will indication PiHole has lost connection.

sensor.rpi_pihole_rpi_monitor_pihole example attribute is timestamp: 2024-08-15T17:10:10+01:00

I suspect I need to use a value template that takes time(now) and subtracts the timestamp and then checks if it’s > 419 seconds

I tried a few examples I found on the web/here and one could be right but I couldn’t even get it to save most of the time since I have no idea what I should be setting for entity, Above mode, Above, Below mode, Below, and For Values.

I guess using timestamps mathematically is hard enough without factoring in a Value Template without knowing what/how they work on the page.

Maybe I could also use:
{{ states.sensor.rpi_pihole_rpi_monitor_pihole.last_updated }}

Edit, think i’m close with…

{{ as_timestamp(now()) > (as_timestamp(states(‘sensor.rpi_pihole_rpi_monitor_pihole.last_changed’), 0) + 419000) }}

OR

{{ as_timestamp(now()) > (as_timestamp(states(‘sensor.rpi_pihole_rpi_monitor_pihole.last_changed’), 0) + 419) }}

Another edit, built all this out in the Developer Tools template section and it gives me all the right values and outcome. I just don’t have a clue how to make this a trigger in the gui.

{{ as_timestamp(now()) > (as_timestamp(state_attr(‘sensor.rpi_pihole_rpi_monitor_pihole’, ‘last_update’), 0) + 419000) }}

then this. (note that i did a different template than yours… i find this one easier to read and maintain):

1 Like

Ahhhhhhhh thanks! I’ll try that out in the morning.