Loop automation 3 or 4 times

Hi there
i have made a automation using a lunch of if then statements is there anyway to make it simpler? this is my automation

alias: Switch House to Off-Grid Mode
description: ""
triggers:
  - at: "23:00:00"
    trigger: time
conditions:
  - type: is_battery_level
    condition: device
    device_id: 655bdc4b07c17f59a027e4ca8b3517a1
    entity_id: d1f502f28e1d9d1091c0c8152fa82908
    domain: sensor
    above: 99
  - condition: state
    entity_id: sensor.acdc_inverter_output_mode
    state: USB
actions:
  - if:
      - condition: state
        entity_id: sensor.acdc_program_status
        state: Online
    then:
      - type: turn_on
        device_id: 655bdc4b07c17f59a027e4ca8b3517a1
        entity_id: 2504ece9816ada1970051714367d1eaf
        domain: switch
      - wait_for_trigger:
          - entity_id:
              - sensor.acdc_inverter_mode
            from: USB
            to: SBU
            trigger: state
        timeout:
          hours: 0
          minutes: 1
          seconds: 0
          milliseconds: 0
      - if:
          - condition: device
            type: is_on
            device_id: 655bdc4b07c17f59a027e4ca8b3517a1
            entity_id: 2504ece9816ada1970051714367d1eaf
            domain: switch
        then:
          - action: notify.mobile_app_samsung_s22
            metadata: {}
            data:
              message: >-
                Switched to Off-Grid Mode at {{ now().strftime('%I:%M:%S %p')
                }}.
          - action: input_datetime.set_datetime
            metadata: {}
            data:
              datetime: "{{ now() }}"
            target:
              entity_id: input_datetime.house_off_grid
        else:
          - type: turn_on
            device_id: 655bdc4b07c17f59a027e4ca8b3517a1
            entity_id: 2504ece9816ada1970051714367d1eaf
            domain: switch
          - wait_for_trigger: []
            timeout:
              hours: 0
              minutes: 1
              seconds: 0
              milliseconds: 0
          - if:
              - condition: device
                type: is_on
                device_id: 655bdc4b07c17f59a027e4ca8b3517a1
                entity_id: 2504ece9816ada1970051714367d1eaf
                domain: switch
            then:
              - action: notify.mobile_app_samsung_s22
                metadata: {}
                data:
                  message: >-
                    Switched to Off-Grid Mode at {{ now().strftime('%I:%M:%S
                    %p') }}.
              - action: input_datetime.set_datetime
                metadata: {}
                data:
                  datetime: "{{ now() }}"
                target:
                  entity_id: input_datetime.house_off_grid
            else:
              - action: notify.mobile_app_samsung_s22
                metadata: {}
                data:
                  message: >-
                    Failed to switch to Off-Grid mode at {{
                    now().strftime('%I:%M:%S %p') }}.
    else:
      - action: notify.mobile_app_samsung_s22
        metadata: {}
        data:
          message: ACDC Program is Offline at {{ now().strftime('%I:%M:%S %p') }}.
mode: single

Repeat a Group of Actions