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

hey guys,

I tried this with my cast but the problem is, that the cast is in screensaver mode after a while. anyone an idea? bought this device only for that usecase and if it is not well supported I would rather think to return the device.

- alias: "Cast to Google Hub"
  trigger:
    - platform: time_pattern
      minutes: /9
  action:
    - service: media_player.volume_mute
      data:
        is_volume_muted: true
        entity_id: media_player.flur
    - service: cast.show_lovelace_view
      data:
        view_path: nest
        dashboard_path: lovelace
        entity_id: media_player.flur
    - delay:
        seconds: 10
    - service: media_player.volume_mute
      data:
        is_volume_muted: false
        entity_id: media_player.flur
  mode: restart

Best,
Dirk

1 Like

Cast is working now. Just read back some comments above: Cast and re-cast a lovelace view to a Google Hub - #73 by Bram_Kragten

1 Like

Stays the same like I mentioned above and this issue also states the problem people are describing here. Google Cast stopped working within the last couple of weeks · Issue #53882 · home-assistant/core · GitHub

1 Like

Hi guys, I am trying to cast the my lovelace calendar to my Google Hub, I’ve finally managed to get it up on the Hub, but its empty while everything is showing in HA before I cast it. Anyone got any idea what the issue could be or how I could fix that?

I got it working. I just simply cast with a script and dont use the automation that re-triggers casting every 9 or 10 minutes and that works good.

sequence:
  - service: media_player.volume_mute
    data:
      is_volume_muted: true
      entity_id: media_player.flur
  - service: cast.show_lovelace_view
    data:
      view_path: nest
      dashboard_path: lovelace
      entity_id: media_player.flur
  - delay:
      seconds: 10
  - service: media_player.volume_mute
    data:
      is_volume_muted: false
      entity_id: media_player.flur
mode: single

Hi Dirk,

So you’re not using CATT? I tried using CATT with 10 minute automations, but I could not get it to work reliably enough.

no. I just use the Home Assistant embedded casting mode and without the 9 or 10 minute automation trigger it works very good.

Hi all,
trying to set up my new Nest Hub with this automation, however it seems like my view is not recognized.
I checked into view’s raw data (see picture) and entered “default_view” as path in the automation, however when running it I am getting an “Unable to find a view with path default_view” from the home view on the device.
Any hint?

Nicola

Just a reminder to anyone who finds this blueprint and thinks it’s functional, it is not.
Use the built in lovelace casting by calling service: cast.show_lovelace_view
It’s still super finnicky and I’ve had luck putting this into a script that calls the wrong dashboard path, then waits, then calls the correct one to avoid the random failures of the casting system saying “Unable to find a view with path”
(Just remember that you must put a path into your lovelace dashboard with the raw editor)

Can some1 help me out the I get the error on my nest hub max :
not connected
error unable to connect to the home assistant WebSocket API

the Lovelace tab is called ‘deurbel’
the nest hub is called ‘keuken’

Try changing the dashboard_path to lovelace-deurbel and the view_path to default_view.
They probably changed something or it wasn’t explained good enough, but that fixed it for me.

Hey there,
for all that maybe have the same Problem, that the Casting after 20 seconds stops and restarts, and it keeps on doing that.

I’m really new to HA (basically started today XD), I’m not completely sure if its the right way to fix it but it works for me so maybe give it a try ;).

So basically the problem was that the TRIGGER that restream the Dashboard when you have used it for like Streaming music or something else and then stopped it or just paused it (which happens when you tell Google to stop streaming music, it dosen’t actually stop it and just pauses it idk why).
Because the MediaPlayer that is used to show the Dashboard onto the Google Cast device, gives back the status paused all the time when streaming it onto a Google Cast device.

So the thing i did was replacing the TRIGGER statement from “to: paused” to “from: playing”, I tested it by just waiting and seeing if the problem still occurs, which didn’t happen, then i tried to play some music over VoiceCommand which worked fine and played for some time without being interrupted.
And after stopping/pausing the music it recasted the dashboard onto the Hub.

Im not quiet sure if it could cause problems with other use cases, but when I quickly think of it it should work with everything that just has the status playing when its beign casted onto the Hub.

And just as a tip, u can easily tune the timings in the Automation if you don’t want to always start the recast so quickly, by just editing the time when the TRIGGER starts.

As I said im new, that’s why i didn’t wanted to put this new Code into a Blueprint if that would be even possible here?!
So I would suggest if you just do it as I did, create a new empty Automation, then switch to the YAML Editor, by clicking on the 3 dots on the top right and then paste and replace the code into there, then just replace these brackets → “[…]” with your information (Google Cast device name with spaces replaced with underlines → “_” ; and the dashboard_path with your sidebar card name that you want to stream → http://homeassistant.local:8123/["what ever is in here"]/dashboard; and the view_path with which card from the top at your Dashboard you wanna stream).

alias: Lovelace Dashboard Cast
description: 'Casts a Dashboard of your choice to a Google Cast device, it also recasts it, if it is stopped or another kind of streaming has been paused for 10 seconds (time is adjustible have a look at the code in the YAML Editor) '
trigger:
  - platform: state
    entity_id: media_player.[yourHub]
    for:
      hours: 0
      minutes: 0
      seconds: 10 
      milliseconds: 0 #change the time here for when the recast should trigger when a streaming is turned off#
    to: 'off'
  - platform: state
    entity_id: media_player.[yourHub]
    for:
      hours: 0
      minutes: 0
      seconds: 10 
      milliseconds: 0 #change the time here for when the recast should trigger when a streaming is beign paused# 
    from: playing
  - platform: time_pattern
    minutes: /9
  - platform: time_pattern
    minutes: '0'
action:
  - choose:
      - conditions:
          - condition: or
            conditions:
              - condition: state
                entity_id: media_player.[yourHUB]
                state: 'off'
              - condition: state
                entity_id: media_player.[yourHUB]
                state: paused
                for:
                  hours: 0
                  minutes: 0
                  seconds: 10
                  milliseconds: 0 #change the time here for when the recast should trigger when a streaming is  beign paused#
        sequence:
          - service: media_player.volume_mute
            data:
              is_volume_muted: true
              entity_id: media_player.[yourHUB]
          - service: media_player.turn_off
            data:
              entity_id: media_player.r[yourHUB]
          - delay:
              seconds: 2
          - service: media_player.turn_on
            data:
              entity_id: media_player.[yourHUB]
          - service: cast.show_lovelace_view
            data:
              view_path: [card name/url from the Dashboard ur streaming]
              dashboard_path: [...] #(http://homeassistant.local:8123/["what ever is in here"]/dashboard)#
              entity_id: media_player.[yourHUB]
          - service: cast.show_lovelace_view
            data:
              view_path: [card name/url from the Dashboard ur streaming]
              dashboard_path: [...] #(http://homeassistant.local:8123/["whatever is in here"]/dashboard)#
              entity_id: media_player.[yourHUB]
          - delay:
              seconds: 10 #time when the Cast device is beign unmuted again#
          - service: media_player.volume_mute
            data:
              is_volume_muted: false
              entity_id: media_player.[yourHUB]
mode: single
3 Likes

@Bram_Kragten Now that 2021.12 is out, what would you recommend for making this work?

I added from: playing, to: paused as you recommended, which worked, but when I removed the from: playing after upgrading to 2021.12, it’s still not working after reloading automation. It’s just showing the HA <3 Nabu Casa screen and “not connected.”

Any suggestions?

1 Like

So i imported the blueprint, and it suddenly worked… Decided to move the Google Hub to it’s designated location, and powered it up again… Now I’m back to the dashboard showing the “NOT CONNECTED” screen.

If I use the cast.home-assistant.io and manually cast, it works every time I say cast.

What baffles me is the random works every now and then with the blueprint… THere must be something I am doing wrong?:slight_smile:

I’m using a custom automation somewhat based on this blueprint that re-casts once every hour, but it sounds like my experience has been similar. Often times when I first cast it’ll show an error saying something about the lovelace path being wrong, but if I leave it alone then it’ll start working after a bit, though the HA casted screen won’t stay up consistently. It seems like it usually works during the first part of the day up until the late afternoon or early evening before it stops casting and just goes back to Google screensavers. At first I thought maybe it was when my wife used the Google hub to set timers or something like that which was causing it to stop, but I’ve tried to debug a bit and it just seems more random as far as I can tell.

after scrolling through large parts of this thread. Setting an internal and external address helped me cast my lovelace UI to a chromecast device.

Has anyone found a modification to this blueprint that works to maintain the stream? Or have you just built your own?

Super interested in knowing what exactly is working rite others. I ended up building my own script to call the service, but I still find it broken Periodically.

I have tried every possible way with view_path and dashboard_path, but still just get the message can’t find view_path xxxx
This is my main page:
http://192.168.0.150:8123/lovelace/oversikt (copied from my browser)
I also have tried with my nabu casa adress and still the same… not sure what to put where :confused:

Cast from nabu casa works fine…

1 Like

Hi!
Using the principle method above, is there any option to trigger showing the lovelace on a Nest Hub (Google Home Hub) on demand vs every x minutes?

Example: I enjoy the picture screensaver mode of my Nest Hub. If I want to interrupt it, it would be great if I could just say something like “OK Google, show me Home Assistant”. This should then trigger starting the cast of the lovelace view.

Thanks a lot Nouxii. I’ve been using your script (with minor tuning) for 2 weeks now without issues.

I struggled initially with the dashboard path setting. Reading your instructions finally did the trick i.e. in my case (with the default lovelace dashboard), it’s simply “lovelace” :slight_smile:

Has anyone got hold of the dark/light theme handling? It seems that every now and then the background color changes, but not every time when you change the theme (for the cast user) in Home assistant and recast. I have also noticed in order to have any effect, you first need to turn of the Google Nest Hub (media_player.turn_off service) prior recasting with the changed theme (User profile → Theme: dark/light) setting .

I’d really like to have a way to switch between dark/light theme without random background color mismatch.

Any ideas?

Br,
Mikko

1 Like