Run automation after HA starts up

Hi.

I am fairly new to Home Assistant and my knowledge on YAML is very limited. I do just about everything in the UI. I can however follow simple yaml code fairly easily

Here is my scenario. In South Africa we struggle with load shedding and I have set automations to switch off certain lights and appliances during load shedding. I have installed a Tuya loading sheeding detector which is a modified garage opener. HA then detects that the mains power has been cut. If my battery backup system last the period of load shedding then I have no problem. However if my batteries run out and i lose power completely for a time and then comes back on the my automation just sits and do not trigger.

I run HA on an Intel NUC and its set to power up automatically when power comes back.

How do i get automation to look for return of power and trigger automatically or alternatively to continally check for power availabilty.

Would appreciate some help.

One way is to trigger the automation on restart:

  - alias: "Homeassistant restart"
    id: ha_restart
    description: "runs only on restart"
    initial_state: true # ensure automation is turned on when restarting HA
    trigger:
      - platform: homeassistant
        event: start
    condition: []
    action:
      ...

Below is the automation. I am not that good at YAML. Can you please check if correct.
Many thanks

alias: Garage Fride on After Total Power out
description: “”
trigger:

  • platform: state
    entity_id:
    • switch.garage_fridge_plugs_switch_1
      from: unavailable
      to: “off”
      for:
      hours: 0
      minutes: 0
      seconds: 30
      condition:
  • condition: state
    entity_id: cover.load_shedding_dectector_door
    state: “off”
    for:
    hours: 0
    minutes: 0
    seconds: 10
    action:
  • type: turn_on
    device_id: 17399db52cf717cde47a46b28322178c
    entity_id: switch.garage_fridge_plugs_switch_1
    domain: switch
    mode: single