Cast and re-cast a lovelace view to a Google Hub

There seems to be a problem with this blueprint after the upgrade to 2022.4.0 and 2022.4.1
Not working reliably at all…

3 Likes

I’m also seeing some issues after update. I suddenly find my nesthub not showing the lovelace view. When I check the status of the nesthub using Developer Tools, it says ‘playing’ even though the nesthub is actually idle. So the blueprint/automation won’t fire. This looks to be an issue with the HA → Chromecast integration to me.

I think it is a bit of both. Please see my suggestion for an update to the blueprint in the thread for my report against the cast integration since I have it working now:

1 Like

I appreciate how everyone keeps contributing to this thread with new ideas, solutions and bug fixes, so I decided to chip in by adding my blueprint here.

The most noticeable changes from the original and from the versions that were posted recently are:

  • Start and End time input (No need to keep casting at night, I think…)
  • “lovelace” is renamed to “dashboard” in most places
  • The view and dasboard inputs switched places, because that makes more sense to me
  • I added state changes to “off” (immediate), “paused” (20 seconds delay) and “idle” (20 seconds delay) as triggers.
  • I removed the 2nd “cast.show_lovelace_view” service call (thanks to @jeremyc for the suggestion)

It works as expected, so I’m really happy with it this way.
(The only thing is that it sometimes drops to the background, so I have to tap the screen and then the Lovelace tile to get it back in the foreground.)

Here’s the blueprint:

blueprint:
  name: "Cast & Recast dashboard view (Timed)"
  description: "Cast a dashboard view to a Google Hub when it's off or idle or paused for 20 seconds. This tries to bypass the 10 min timeout for the picture frame by re-casting every 9 min."
                                                           
  domain: automation
  input:
    player:
      name: Google Hub
      description: Google Hub or Chromecast device to cast to
      selector:
        entity:
          integration: cast
    starttime:
      name: Starttime
      description: Time at which the casting should start
      default: "07:00:00"
      selector:
        time:
    endtime:
      name: Endtime
      description: Time at which to stop casting
      default: "23:00:00"
      selector:
       time:
    dashboard:
      name: Home Assistant dashboard path
      description: Path to the dashboard. Defaults to 'lovelace' if empty.
      default: lovelace
    view:
      name: Dashboard view path
      description: Path of the view to cast. A path has to be defined in your dashboard YAML for each view, as outlined in the views documentation.
      default: cast

trigger:
- platform: state
  entity_id: !input 'player'
  to: 'off'
  for: 00:00:20
- platform: state
  entity_id: !input 'player'
  to: paused
  for: 00:00:20
- platform: time_pattern
  minutes: /9
- platform: time_pattern
  minutes: '0'

action:
- choose:
  - conditions:
    - condition: time
      after: !input 'starttime'
      before: !input 'endtime'
    - condition: or
      conditions:
      - condition: state
        entity_id: !input 'player'
        state: 'off'
      - condition: state
        entity_id: !input 'player'
        state: idle
        for: 00:00:20
      - condition: state
        entity_id: !input 'player'
        state: paused
        for: 00:00:20
    sequence:
    - service: media_player.volume_mute
      data:
        is_volume_muted: true
        entity_id: !input 'player'
    - service: media_player.turn_off
      data:
        entity_id: !input 'player'
    - delay:
        seconds: 2
    - service: media_player.turn_on
      data:
        entity_id: !input 'player'
    - delay:
        seconds: 2
    - service: cast.show_lovelace_view
      data:
        view_path: !input 'view'
        dashboard_path: !input 'dashboard'
        entity_id: !input 'player'
    - delay:
        seconds: 10
    - service: media_player.volume_mute
      data:
        is_volume_muted: false
        entity_id: !input 'player'
1 Like

I noticed that rebooting (unplug/replug) the nests helps … sometimes they just seem to get stuck.

Hey Rob. How do I import this blueprint?

FWIW, I just created a gist you can use to import the latest version here (use the URL):

This whole blueprint forum system is a total mess.

1 Like

Thanks! Got it working now! Love it.

What is the difference between the different states off, idle and paused? I would like to automatically re-cast but in the same time not interrupt any other usage of the hub as reading a recipe. Is it possible to somehow prevent this and detect when the hub is “occupied”?

I have the same issue. Did you solved?

Well I’ll be?? Just stopped the re-cast automation (based on an older blueprint) and the screen saver doesn’t come on anymore? Has been working fine without reload for over 42 minutes now…
Might be related to me trying to cast a video from HA’s media browser to the Hub (followed by disabling the re-cast automation because the video got interrupted, obviously). Maybe this is the road to success?
Or maybe there’s been a Google firmware update.
Still running HA 2022.4.0.

Still going strong on 2022.5.3. Status of the hub is ‘playing’, this might be new. The video I tried to play might have been unplayable, maybe it got stuck? Still filled with glee about the thing just working like it was supposed to.

Hello, I would like to ask you, maybe someone has managed to do what I want them to do. I wish I could cast more then one dashboard alternative to every 2 minutes. So for example start now with dasboard 1, keep this 2min. and go to dashboard 2 …dasboard 3 and at the end go back to dashboard 1 and start again. I try to find seomething like this on the internet but without success. I’m not good on the programming language for ha but i try to learn. Matbe somebody who know more like me can help me.Thanks

I have an open ticket about this, looks like the Google Home Cast intergration is off and not reading the states correctly when cast from HA.

Google Cast Integration doesn't detect paused state when cast from HA · Issue #70836 · home-assistant/core · GitHub please star/comment if you see the same thing.

They all used to work pretty well with this script, but as of the last week or so, I’ve noticed that the v1 Hubs have mostly stopped working and don’t even respond to a recast command. I have to disconnect the power for a manual reset and even then they sometimes don’t work (or not for very long). The v2 hubs have all been working without issue.

Is anyone else having a problem with the v1 hubs?

edit: Updating to the version of the script at the top of this thread seems to have mostly addressed the problem

edit 2: They all came up initially, but after some time the v1 hubs drop the cast (when using the lastest script at the top of this thread) - still having this problem

edit 3: The current script at the top of this page doesn’t work as well as the script I linked in the GitHub issue. I’ve switched back to that. Either way, I’ve decided to just get v2 Hubs to address this problem since they seem to work fine.

edit 4: (July 16 2022): I’m having fewer problems after moving to all v2 Google Nest Hubs, but still have to occasionally call a “fix/reset cast” script that sets the display/media-player to ‘off’ and then calls the cast script again.

I can confirm I’m seeing this problem too:
Google Cast Integration doesn’t detect paused state when cast from HA ·

Quite regularly this fails the first time of the day.
When restarting the whole process it usually works.

I also have issues with reliability using the cast.show_lovelace_view service. The resulting state will be playing with the app_name set to “Home Assistant Lovelace” as is the case when it’s successful. But the dashboard won’t be displaying. On my Google TV the home screen will be displayed or the Chromecast ambient screen will be displayed.

Since all the states and attributes seem to be indicating the dashboard should be displaying there isn’t anything I can do to compensate for it not actually working. Anyone else run into this?

I have been playing with this and and was getting a black screen after a period of time/not being able to recast

have noticed if i cast the same view/dashboard twice in a row the second time around it just casts a back screen but if i cast a different view its loads fine

Anyone else have the at issue?

I’ve been slowly moving my config from yaml to the UI. I found that once I moved external_url to “Settings > System > Network”, casting via a service call no longer worked. At this point it would produce “unable to connect to the Home Assistant Websocket API”. This is despite the fact that using https://cast.home-assistant.io/ to cast continued to work. To be able to call cast.show_lovelace_view successfully, I had to move external_url back into “configuration.yaml”. Have others found the same?