Add 'offset' parameter to Home Assistant trigger

The following trigger fires when Home Assistant starts up or shuts down:

automation:
  trigger:
    - platform: homeassistant
      # Event can also be 'shutdown'
      event: start

Documentation:

The problem is that my ZHA devices are not yet available when HA has just booted up.
This takes a minute or 2.

Therefore add the following (optional) parameter:

automation:
  trigger:
    - platform: homeassistant
      event: start
      offset: "00:03:00"

This makes sure that this event fires 3 minutes after HA has started up.
I think this could be usefull.

(note: In case of a ‘shutdown’ event, an offset should not be allowed.)

  trigger:
    - platform: homeassistant
      event: start
  action:
    - delay: '00:03:00'
    ... etc ...
1 Like

True, but I usually have multiple triggers. For example:

  trigger:
    - platform: homeassistant
      event: start # in case the states aren't properly restored
    - platform: event
      event_type: automation_reloaded # in case automations reload
    - platform: time
      at:
        - "07:30:00" # Turn on light in the morning
        - "00:00:05" # Turn off light a couple seconds after midnight
    - platform: sun # Turn off light half hour after sunrise
      event: sunrise
      offset: "00:30:00"
    - platform: sun # Turn on light half hour before sunset
      event: sunset
      offset: "-00:30:00"

A general delay for all triggers is not what I want.

And yes, I know that I can use a trigger id to later get the actual trigger back that fired, but that makes it more complicated.

If your automation is using five triggers it must already contain a choose to determine which one of the triggers occurred. It’s not more complicated than adding another conditions to it.

  action:
    - choose:
        - conditions: '{{ trigger.platform == 'homeassistant' }}'
          sequence:
            - delay: '00:03:00'
              ... etc ...
        - conditions: '{{ trigger.platform == 'event' }}'
          sequence:
            ... etc ...
        - conditions: '{{ trigger.platform == 'time' }}'
          sequence:
            ... etc ...
        etc

Well in my case it’s actually is not quite that easy. The home assistant start trigger is not part of my choose conditions.

Like this
- choose:
        - conditions:
            condition: or
            conditions:
              - condition: time # Condition to turn on in the morning
                after: "07:25:00"
                before: "08:35:00"
              - condition: sun # Condition to turn on in the evening
                after: sunset
                after_offset: "-00:45:00"
          sequence:
            - service: light.turn_on
              entity_id: light.inside
            - service: light.turn_on
              entity_id: light.outside # christmas light string in hedge
      default:
        - service: light.turn_off
          entity_id: light.inside
        - service: light.turn_off
          entity_id: light.outside # christmas light string in hedge

But that’s irrelevant. I know I can get it working with the available tools. I just thought the ‘offset’ parameter would make a usefull addition. Usefull in a lot of circumstances.

And I didn’t suggest a general delay for all triggers.

So why did you provide an example of an automation that won’t even use the offset feature you are requesting?