I have read countless forum posts, tried a bunch of methods but cannot figure out why my tests are not working.
Problem: I want to send a notification if the front porch sensor sees something but only if its been more than 60 seconds since the last notification.
Using the template tester I put these in and the results always look correct to me:
{% set a = states.binary_sensor.frontporch_motion.last_changed.timestamp() %}
{% set b = now().timestamp() %}
{% set c = (now().timestamp() - states.binary_sensor.frontporch_motion.last_changed.timestamp()) %}
{% set x = (now().timestamp() - states.binary_sensor.frontporch_motion.last_changed.timestamp()) > 60 %}
And so I put my condition into the automation as follows:
The simplest cheat in the automation would be to use this to get a “cooldown”.
Your template checks when the sensor last updated which will always be “right now” when running I assume. Instead check to see when the automation last triggered.