Templating input_datetime as a trigger

Trying to execute a trigger 24 hours before an input_datetime value. This will evaluate as true at the right time, but the automation does not trigger.

  trigger:
    - platform: template
      value_template: "{{ (state_attr('input_datetime.test', 'timestamp') - 86400) == now().timestamp() | int  }}"

I’d like to not have to do this with additional sensors or input_datetime variables.

trigger:
  - platform: template
    value_template:  "{{now() >= states('input_datetime.test') | as_datetime | as_local - timedelta(hours=24) }}"

Or

trigger:
  - platform: template
    value_template: >
      {{ now() | as_timestamp >= states('input_datetime.test') | as_timestamp - 86400 }}
1 Like