Automation with date time problem

I have an automation that’s been triggerd by an input time
I want an extra automation 5 minutes before that input time. How do I code this ?

trigger:
  - platform: time
    at: input_datetime.velux_invoer_uur

I already found this

{{(((state_attr('input_datetime.velux_invoer_uur' , 'timestamp')) - 300) | timestamp_custom('%H:%M', false))}}

it gives me the right time in the developer tools template, but when I add it in an automation I get

Message malformed: Expected HH:MM, HH:MM:SS or Entity ID with domain ‘input_datetime’ or ‘sensor’ @ data[‘at’][0

Add it how?

As a time trigger?

The time trigger does not support templates. Only input_datetime and sensor entities.

Use a template trigger.

trigger:
  - platform: template
    value_template: "{{ today_at(states('input_datetime.velux_invoer_uur')) - timedelta(minutes=5) > now() }}"
1 Like