Automations with timer or delay

The following is a basic example of a single automation to turn on a light on/off at specific times.

- alias: example
  trigger:
    - id: 'on'
      platform: time
      at: '18:00:00'
    - id: 'off'
      platform: time
      at: '22:00:00'
  condition: []
  action:
    - service: 'light.turn_{{ trigger.id }}'
      target:
        entity_id: light.whatever

It is unaffected by a restart, or Reload Automations, unless it occurs precisely at the scheduled time. However, there’s a simple technique to mitigate that situation as well (involving a condition).

For more information, refer to the following post:

There’s also a technique to dynamically set the scheduled time so that it can behave like a timer (i.e. start time is not fixed and stop time is calculated based on the floating start time).

1 Like