Template automation condition now - timestamp > 2 minutes

how do i create a template conditions that subtracts two timestamps and it’s true if rhe results is greater than two minutes?
i tried like this but it gives me an error
{{ now() - (‘sensor.z2m_last_updated’) > timedelta(minutes=2) }}
sensor.z2m_last_updated state is reported like this

To perform the subtraction, you must convert the sensor’s state value from a datetime string to a datetime object.

{{ now() - states('sensor.z2m_last_updated') | as_datetime | as_local > timedelta(minutes=2) }}

thank you very much

1 Like