WTH Can we have an offset on date/time helper trigger in automations

I did a little digging and found something that works. I am using 2022.12.8 and tested (successfully) the following automation that will allow you do an offset. You can configure it however you like, but note that the “120” is seconds.

alias: Test Automation
description: "2 minutes before the value template triggers, based on the datetime helper, an audible notification will be sent to a specific echo device"
trigger:
  - platform: template
    value_template: >-
      {{ states('sensor.time') == (
      states.input_datetime.alarm_clock.attributes.timestamp | int - 120 ) |
      timestamp_custom('%H:%M', False) }}
condition: []
action:
  - service: notify.alexa_media_my_echo
    data:
      message: This is a test
      data:
        type: tts
mode: single

Hope that this is close to what you were looking for, and helps you out

2 Likes