Unifi integration - PoE switches inconsistent behaviour: How to solve this automation?

With the release of 2022.11.0 I’ve started creating automations around the Unifi Integration. What I wanted to achieve is disabling 3 PoE switches with an attached u6-mesh access point, as well as a u6-mesh ap in the garden when we’re in bed or away from home.

The automation runs and works,… most of the time. :wink:

When the automation fires it sends to commands to my udmp to turn of power for certain ports. First night I tested this I noticed not all ports where disabled. I thought I had to build a delay because maybe the udmp does not handle all commands at the same time very well. Thus I build the following automation, this is for when we wake up:

- alias: wifi_on_time_state_morning
  trigger:
  - platform: state
    entity_id: input_select.house_time_state
    to: 'Morning'
    

  condition:
  - condition: state
    entity_id: input_select.house_presence_state
    state: 'Home'


  action:
  - service: switch.turn_on
    entity_id: switch.tech_azi_1_living_room_poe
  - delay:
      seconds: 30

  - service: switch.turn_on
    entity_id: switch.tech_azi_2_playcorner_poe
  - delay:
      seconds: 30

  - service: switch.turn_on
    entity_id: switch.tech_azi_3_attic_2_poe
  - delay:
      seconds: 30

  - service: switch.turn_on
    entity_id: switch.tech_garden_poe

  - wait_template: "{{ is_state('switch.tech_azi_1_living_room_poe', 'on') }}"
  - wait_template: "{{ is_state('switch.tech_azi_2_playcorner_poe', 'on') }}"
  - wait_template: "{{ is_state('switch.tech_azi_3_attic_2_poe', 'on') }}"
  - wait_template: "{{ is_state('switch.tech_garden_poe', 'on') }}"

  - service: notify.pushover_power
    data:
      title: "Network"
      message: "Switches and WiFi are '{{ states.switch.tech_garden_poe.state }}'."
      data:
        sound: none

#-# Changelog #-#
# 04-11-2022: Created automation.

I have similar automations built for when we go to sleep and away/home.

The delay did not help this morning. Only the first, switch.tech_azi_1_living_room_poe, was turned on. (Thank god, otherwise the kids would’ve woken us…)

Any idea how I can for example make a check every minute after running the automation to check of said switches have actually turned on, and if not try again.