WTH can't automations be triggered x minutes before/after a specific time-entity?

Example:

  • An automation will start a 1h timer (timer helper) when my Playstation is turned on.
  • When the timer is finished the Playstation will be turned off.
  • WTH: If you want to get a warning 5 minutes before the timer ends (like a flashing light or a Text-To-Speach announcement) you can’t use a time trigger.

So, something like this won’t work,

trigger: time
at: timer.ps5_playtime
offset: "00:05:00"

because

  1. there is no offset: option (WTH?) and
  2. the time when the timer helper will finish is an attribute and and not the state of said helper, but attributes can not be selected for the at: option (WTH?).

Therefore workarounds like template sensors or using a template trigger like this are necessary:

trigger: template
value_template: >-
  {{ (((state_attr('timer.ps5_playtime', 'finishes_at') | as_timestamp) -
  360 ) | timestamp_custom('%H:%M', true)) == ((now() | as_timestamp) |
  timestamp_custom('%H:%M', true)) }}

The documentation has an example that says you can though I have not tested it: Automation Trigger - Home Assistant

e.g.

triggers:
  - trigger: time
    at: 
      - entity_id: sensor.alarm_time
        offset: "00:05:00"

FML - you are right. I looked it up: This was implemented two months ago in 2024.10.

A template sensor is still needed to use a timers attribute but it is a huge improvement.

edit: And afaik the date time has to be rounded to a full minute; otherwise the automation might not be triggered.

full second