Start automation based on time in state of sensor


I have setup buienalarm which will give me state that next rain is forecasted at 14:15.
With the following state of the sensor 2022-08-19 14:15:00
How to use that time minus 15 minutes to start an automation?


A template trigger:

{{ states('sensor.buienalarm') | as_datetime - timedelta(minutes=15) == now().timestamp() | timestamp_custom("%Y-%m-%d %H:%M:%S", true) }}

wow, very fast and very helpful. I will see in like 20 minutes if it will work as intended :slight_smile:

Note that I just made an edit. I forgot half of the template

It probably didn’t work?

Try this:

{{ (states('sensor.buienalarm') | as_datetime - timedelta(minutes=15)) | string  == (now() | string)[0:19] }}

Cool, this is it!! It worked like a charm, thanks!