Google Cast not working

Hi,

I have a home-assistant installation running under docker (not hassio) and would like to cast a lovelace view to my Google Nest screen. I followed the instructions from the Google Cast topic at: https://www.home-assistant.io/integrations/cast/, but until now every attempt failed, after calling my script that should start the cast.

The discovery of the cast device did seemed to succeed (the youtube cast sample did succeed):

2021-02-22 07:15:47 DEBUG (zeroconf-ServiceBrowser__googlecast._tcp.local._16336) [homeassistant.components.cast.discovery] Discovered chromecast ChromecastInfo(services={'Google-Nest-Hub-b1995e807b8236cc3ab8cdf42e22feee._googlecast._tcp.local.'}, host='192.168.64.185', port=8009, uuid='b1995e80-7b82-36cc-3ab8-cdf42e22feee', _manufacturer='Google Inc.', model_name='Google Nest Hub', friendly_name='Nest', is_dynamic_group=None)
2021-02-22 07:15:48 DEBUG (MainThread) [homeassistant.components.cast.media_player] _async_create_cast_device: ChromecastInfo(services={'Google-Nest-Hub-b1995e807b8236cc3ab8cdf42e22feee._googlecast._tcp.local.'}, host='192.168.64.185', port=8009, uuid='b1995e80-7b82-36cc-3ab8-cdf42e22feee', _manufacturer='Google Inc.', model_name='Google Nest Hub', friendly_name='Nest', is_dynamic_group=None)

Here is the error that i receive in my log:

2021-02-22 07:16:21 INFO (MainThread) [homeassistant.components.script.cast_on_nest] Cast Screen on Nest: Running script sequence
2021-02-22 07:16:21 INFO (MainThread) [homeassistant.components.script.cast_on_nest] Cast Screen on Nest: Executing step call service
2021-02-22 07:16:21 ERROR (MainThread) [homeassistant.components.script.cast_on_nest] Cast Screen on Nest: Error executing script. Error for call_service at pos 1:
2021-02-22 07:16:21 ERROR (MainThread) [homeassistant] Error doing job: Task exception was never retrieved
Traceback (most recent call last):
File "/usr/src/homeassistant/homeassistant/helpers/script.py", line 1033, in async_run
await asyncio.shield(run.async_run())
File "/usr/src/homeassistant/homeassistant/helpers/script.py", line 246, in async_run
await self._async_step(log_exceptions=False)
File "/usr/src/homeassistant/homeassistant/helpers/script.py", line 254, in _async_step
await getattr(
File "/usr/src/homeassistant/homeassistant/helpers/script.py", line 464, in _async_call_service_step
await service_task
File "/usr/src/homeassistant/homeassistant/core.py", line 1455, in async_call
task.result()
File "/usr/src/homeassistant/homeassistant/core.py", line 1490, in _execute_service
await handler.job.target(service_call)
File "/usr/src/homeassistant/homeassistant/helpers/service.py", line 665, in admin_handler
await result
File "/usr/src/homeassistant/homeassistant/components/cast/home_assistant_cast.py", line 44, in handle_show_view
hass_url = get_url(hass, require_ssl=True, prefer_external=True)
File "/usr/src/homeassistant/homeassistant/helpers/network.py", line 123, in get_url
raise NoURLAvailableError
homeassistant.helpers.network.NoURLAvailableError

My script looks like:

script:
  cast_on_nest:
    alias: Cast Screen on Nest
    sequence:
        data:
          dashboard_path: lovelace
          entity_id: media_player.nest
          view_path: casting
        service: cast.show_lovelace_view

  cast_youtube_to_my_chromecast:
    alias: "Cast YouTube to My Chromecast"
    sequence:
      - target:
          entity_id: media_player.nest
        data:
          media_content_type: cast
          media_content_id: '
            {
              "app_name": "youtube",
              "media_id": "dQw4w9WgXcQ"
            }'
        service: media_player.play_media

So the cast_on_nest fails and the cast_youtube_to_my_chromecast succeeds.

I have a Nabu Casa cloud account and followed instructions mentioned here: https://www.home-assistant.io/more-info/no-url-available/

Other things I tried are:

  • Reinstalling the Google Cast integration
  • Other cast devices (Chromecast)
  • use mdns-scan on the docker host
  • verified the net-host option in my docker-compose file
  • tried some other lovelace views
  • Start the script while i was connected to the Nabu Casa cloud of my installation

Anyone has some tips to get this working?
Thanks

I also had the same problem. I found this post: WebSocket API error when trying to call service cast.show_lovelace_view on chromecast device - Giters which led me to the this information from the official documentation (Google Cast - Home Assistant):

Home Assistant Cast requires your Home Assistant installation to be accessible via https:// . If you’re using Home Assistant Cloud, you don’t need to do anything. Otherwise you must make sure that you have configured the external_url in your configuration.

I just found this thread because, this morning, my Google Nest Hub Display became unavailable in HA. I have one of my lovelace cards cast to the display and when I came down this morning, it wasn’t showing. So, I did some quick troubleshooting and the hub was on the network, it was available to me from my phone, and seemed to be working fine. So, I removed the cast integration and restarted HA and, when it came up, it found the display immediately. But, after adding it, it once again was showing as unavailable.

I tried resetting the wifi information in the hub and tried restarting HA. I found this thread, though, which mentioned restarting the router, so I went ahead and tried that and almost immediately after the router came up, the hub started showing my lovelace card. I don’t know why something in the router would have caused this, but it was what fixed the display issue.

The same thing just happen to me,
Did you find the solution?
On top, I’ve 4 Displays and at least 1 still working without an issue.

1 Like