Automation repeat Until


I am trying to write an automation to reboot become unavailable hub.
Idea is to turn off/turn on switch for power of this hub, until one of switches connected to this hub gets on OR off state.

- alias: Sonoff_hub_reboot
  initial_state: true
   - platform: state
     entity_id: switch.sonoff_a48002531e_1
     to: 'unavailable'
         minutes: 2

    - alias: Hub reboot sequence
          - service: switch.turn_off
            entity_id: switch.gateway_sonoff_power
          - delay:  00:00:10
          - service: switch.turn_on
            entity_id: switch.gateway_sonoff_power
          - delay:  00:03:00
             condition: or
              - condition: state
                entity_id: switch.sonoff_a48002531e_1
                state: 'on'
              - condition: state
                entity_id: switch.sonoff_a48002531e_1
                state: 'off' 

Automation is okay, configuration check doesn’t give any errors, but problem is that this automation works only once and doesn’t repeat.
Please point me, where am i wrong?

I’m a little confused…
If the switch that you are trying to restart is ‘unavailable’ how do you expect it to receive the ‘turn on’ and ‘turn off’ commands? The same goes for the hub. For example, if you have a zigbee hub that becomes ‘unavailable’ you cannot expect to reboot it with a zigbee smartplug… when the hub goes down there’s no way to reach the plug.

Sorry, my bad. I explained it wrong.
I have SonOff zigbee hub powered through Xiaomi smart plug (integrated to homeassistant through xiaomi hub), so if hub goes unavailable - xiaomi plug turns off for 10 seconds and then turns on again. Then automation script checks if switch connected to sonoff hub (another one, not xiaomi) goes on or off state instead of unavailable. Idea is to repeat this turn on/off hub script until switch gets proper state, but automation performs only once.