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
- there is no
offset:
option (WTH?) and - 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)) }}