Google cast restart error

Hi guys i need your help please. I will briefly explain my problem.
So I have an automation that if the google nest hub is paused for more than 2 minutes it starts and designs the home assistant dashboard. This automation is a modified version of the one published by TomaszDom here on the site. The change consists in the fact that the dashboard page changes every 30 seconds from 1 to 5 for now. everything works fine with one exception. Overnight or sometimes for unknown reasons during the day after a few hours the nest hub restarts. after the restart, the automation wants to start instantly without waiting, but unfortunately only a black screen appears. after several tests I discovered that after the restart it would take about 5 min for everything to be ok and the dashboard to be designed again. My question is how should I make it so that if google nest hub restarts the automation stops and to start again from the beginning after approx. 5 minutes I attach below the current script in yaml:

alias: test12
description: test12
trigger:
  - platform: state
    entity_id:
      - media_player.living_room
    to: "off"
    for:
      hours: 0
      minutes: 2
      seconds: 0
  - platform: state
    entity_id:
      - media_player.living_room
    to: paused
    for:
      hours: 0
      minutes: 2
      seconds: 0
action:
  - choose:
      - conditions:
          - condition: time
            after: "00:00:00"
            before: "23:59:59"
            enabled: true
          - condition: or
            conditions:
              - condition: state
                entity_id: media_player.living_room
                state: "off"
                for:
                  hours: 0
                  minutes: 2
                  seconds: 0
              - condition: state
                entity_id: media_player.living_room
                state: idle
                for:
                  hours: 0
                  minutes: 2
                  seconds: 0
              - condition: state
                entity_id: media_player.living_room
                state: paused
                for:
                  hours: 0
                  minutes: 2
                  seconds: 0
        sequence:
          - delay:
              hours: 0
              minutes: 5
              seconds: 0
              milliseconds: 0
          - service: media_player.volume_mute
            data:
              is_volume_muted: true
              entity_id: media_player.living_room
          - service: media_player.turn_off
            data:
              entity_id: media_player.living_room
          - delay:
              seconds: 2
          - service: media_player.turn_on
            data:
              entity_id: media_player.living_room
          - delay:
              hours: 0
              minutes: 0
              seconds: 2
              milliseconds: 0
          - service: cast.show_lovelace_view
            data:
              entity_id: media_player.living_room
              dashboard_path: lovelace-test21
              view_path: "0"
          - delay:
              hours: 0
              minutes: 0
              seconds: 30
              milliseconds: 0
          - repeat:
              while:
                - condition: template
                  value_template: "{{ true }}"
              sequence:
                - service: cast.show_lovelace_view
                  data:
                    dashboard_path: lovelace-living
                    entity_id: media_player.living_room
                    view_path: "1"
                - delay:
                    hours: 0
                    minutes: 0
                    seconds: 20
                    milliseconds: 0
                - service: cast.show_lovelace_view
                  data:
                    dashboard_path: lovelace-living
                    entity_id: media_player.living_room
                    view_path: "2"
                - delay:
                    hours: 0
                    minutes: 0
                    seconds: 20
                    milliseconds: 0
                - service: cast.show_lovelace_view
                  data:
                    dashboard_path: lovelace-living
                    entity_id: media_player.living_room
                    view_path: "3"
                - delay:
                    hours: 0
                    minutes: 0
                    seconds: 20
                    milliseconds: 0
                - service: cast.show_lovelace_view
                  data:
                    entity_id: media_player.living_room
                    dashboard_path: lovelace-living
                    view_path: "4"
                - delay:
                    hours: 0
                    minutes: 0
                    seconds: 20
                    milliseconds: 0
                - service: cast.show_lovelace_view
                  data:
                    entity_id: media_player.living_room
                    dashboard_path: lovelace-living
                    view_path: "5"
                - delay:
                    hours: 0
                    minutes: 0
                    seconds: 20
                    milliseconds: 0
mode: single

Hi @electros ,
I stumbled upon your thread after searching for my issue with the Google nest Hub v2.
My Nest Hub2 will every now and then restart, which caused of loosing my HA-dashboard. This happens at least once a day, but often multiple times a day.
I want to point out that I did switch off the Automatic firmware-updates on the Home Assistant app.
BTW i am also using the @TomaszDom automation blueprint.

I did not see any reaction on your thread, but I hope you found an solution for your issue?

Hi deltalbert, yes I found a solution for the moment. Perhaps isn’t the best one but is working for mine and that’s fine.
I will try to explain you how best I can but you must consider English îs not my native language.
So I make another automation for reset second automation when the nest hub is restarted.
1 automation is triggered every second and when detect nest hub became unavailable or unknown disable second automation, wait 2 min ( enough time for nest hub to reboot) and enable back the second automation. Second automation is the automation for projection dashboard and start again to projection dashboard after 30 seconds or how you set.
I hope you understand my explanation, if not you can ask me again.

@electros Hi Sorin, No problem about your English. English is not my native language too :slight_smile:
But would it be possible for you to post me your automations?
I would be very grateful. Kind regards, Bert

Here is the yaml code for 1st automation

alias: Time2
description: ""
trigger:
  - platform: time_pattern
    seconds: /2
condition: []
action:
  - if:
      - condition: state
        entity_id: media_player.living_room
        state: unavailable
    then:
      - service: automation.turn_off
        data: {}
        target:
          entity_id: automation.test12
      - delay:
          hours: 0
          minutes: 3
          seconds: 0
          milliseconds: 0
      - service: automation.turn_on
        data: {}
        target:
          entity_id: automation.test12
      - delay:
          hours: 0
          minutes: 0
          seconds: 2
          milliseconds: 0
      - service: automation.trigger
        data: {}
        target:
          entity_id: automation.test12
    else: []
mode: single

and the automation. test12 is the automation which start projection dashboard to the nest hub.

@electros Hi Sorin, Thank you for your automation examples. I am going to use them for my Nest Hub2.
Will let you know how it is going.
Kind regards, Bert