Cast Plex Media to Google Chromecast not working

Hi everyone,
I’m really getting desperate by now. I have found several posts here in the forum and elsewhere on the internet, but I still can’t get the problem solved.

I have my Plex server running as an add-on in Homeassistant. Furthermore, the Plex integration is set up. If I now open my media players and try to cast an entry of a music title via “browser Media”, nothing happens. there is a bit of information in the log files, but nothing that gets me anywhere.

2024-08-29 17:10:06.977 ERROR (MainThread) [homeassistant.components.websocket_api.http.connection] [139811543948528] Unexpected exception
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/components/cast/media_player.py", line 100, in wrapper
    return_value = func(self, *args, **kwargs)
                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/components/cast/media_player.py", line 558, in media_play
    media_controller.play()
  File "/usr/local/lib/python3.12/site-packages/pychromecast/controllers/media.py", line 630, in play
    response_handler.wait_response()
  File "/usr/local/lib/python3.12/site-packages/pychromecast/response_handler.py", line 54, in wait_response
    raise RequestTimeout(self._request, self._timeout)
pychromecast.error.RequestTimeout: Execution of play timed out after 10.0 s.

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/components/websocket_api/commands.py", line 241, in handle_call_service
    response = await hass.services.async_call(
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/core.py", line 2763, in async_call
    response_data = await coro
                    ^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/core.py", line 2806, in _execute_service
    return await target(service_call)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/helpers/service.py", line 999, in entity_service_call
    single_response = await _handle_entity_call(
                      ^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/helpers/service.py", line 1071, in _handle_entity_call
    result = await task
             ^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/components/media_player/__init__.py", line 814, in async_media_play
    await self.hass.async_add_executor_job(self.media_play)
  File "/usr/local/lib/python3.12/concurrent/futures/thread.py", line 58, in run
    result = self.fn(*self.args, **self.kwargs)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/components/cast/media_player.py", line 102, in wrapper
    raise HomeAssistantError(
homeassistant.exceptions.HomeAssistantError: CastMediaPlayerEntity.media_play Failed: Execution of play timed out after 10.0 s.

Do you have any ideas?

I have 2 Home Assistant instances, one is on an rPi and another runs as docker.

The docker version has stopped working for me - I just see the Plex screen “Loading… playback will begin in a moment.” Then after about 60 seconds I see “Sorry! Something went wrong”.

Looking in the Plex logs, I see nothing but debug logs, no indication (that I can spot) of any issue… and the same in the Home Assistant logs.

As this seems to break in ‘some’ installs, I assume that the issue is somethign configurational. I intend to get the HA plex integration code from Github and work through it (at some point), to see where it fails, and which plex documentation it aligns with. Triggering playlists from Home Assistant was great… I want it back!

I’ve been facing a similar issue lately. I was able to resolve by doing a combination of 2 things:

  • Add 192.168.2.0/24,172.0.0.0/8 to the Plex Network Settings ‘List of IP addresses and networks that are allowed without auth’. In my case I am allowing IPs on the local network as well as the docker network.
  • Add the Plex server to HA using the local IP address of the server (in my case, same IP as HA itself as they’re on the same box). If I tried 127.0.0.1 or localhost, casting would result in a ‘Sorry!’ error.