Chormecast problem. Help needed

I have problem adding Chromecast. I run HA in Docker on LibreELEC and Discover doesn’t find any devices. Same configuration yaml files on Windows 10 running in same network finds both. Both machines run Home Assistant 0.56.2 and exact same configurations

media_player:
  - platform: cast
    host: 192.168.1.9
  - platform: kodi
    host: 192.168.1.10 

Anyone knows what might be the issue?

2017-10-23 22:45:05 ERROR (MainThread) [homeassistant.components.media_player] Error while setting up platform cast
Traceback (most recent call last):
  File "/usr/local/lib/python3.6/site-packages/pychromecast/discovery.py", line 107, in discover_chromecasts
    listener, browser = start_discovery(callback)
  File "/usr/local/lib/python3.6/site-packages/pychromecast/discovery.py", line 88, in start_discovery
    ServiceBrowser(Zeroconf(), "_googlecast._tcp.local.", listener)
  File "/usr/local/lib/python3.6/site-packages/zeroconf.py", line 1660, in __init__
    self._listen_socket = new_socket()
  File "/usr/local/lib/python3.6/site-packages/zeroconf.py", line 1632, in new_socket
    s.bind(('', _MDNS_PORT))
OSError: [Errno 98] Address already in use

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/src/app/homeassistant/helpers/entity_component.py", line 170, in _async_setup_platform
    SLOW_SETUP_MAX_WAIT, loop=self.hass.loop)
  File "/usr/local/lib/python3.6/asyncio/tasks.py", line 358, in wait_for
    return fut.result()
  File "/usr/local/lib/python3.6/asyncio/futures.py", line 245, in result
    raise self._exception
  File "/usr/local/lib/python3.6/concurrent/futures/thread.py", line 56, in run
    result = self.fn(*self.args, **self.kwargs)
  File "/usr/src/app/homeassistant/components/media_player/cast.py", line 80, in setup_platform
    all_chromecasts = pychromecast.get_chromecasts()
  File "/usr/local/lib/python3.6/site-packages/pychromecast/__init__.py", line 75, in get_chromecasts
    hosts = discover_chromecasts()
  File "/usr/local/lib/python3.6/site-packages/pychromecast/discovery.py", line 114, in discover_chromecasts
    stop_discovery(browser)
UnboundLocalError: local variable 'browser' referenced before assignment
2017-10-23 22:45:15 WARNING (MainThread) [homeassistant.setup] Setup of remote is taking over 10 seconds.

I don’t know if it’s related, but I can no longer discover cast devices on the latest cast firmware. See here: Trouble with Chromecast Audio different firmware versions

1 Like

I’m having the same problem.

When I tried to debug it. I went to /usr/lib/python3.6/site-packages/zeroconf.py and updated line _MDNS_PORT = 5353 to 5352

But then, for some reason, I get this log

Need to say, I’m running HA on Docker on machine running Libreelec (ARM)

`

2018-02-01 20:34:57 WARNING (MainThread) [homeassistant.components.media_player] Setup of platform cast is taking over 10 seconds.
2018-02-01 20:34:57 INFO (SyncWorker_6) [pychromecast] Querying device status
2018-02-01 20:34:58 ERROR (SyncWorker_6) [pychromecast.socket_client] Failed to connect, retrying in 5.0s
2018-02-01 20:35:47 ERROR (MainThread) [homeassistant.components.media_player] Setup of platform cast is taking longer than 60 seconds. Startup will proceed without waiting any longer
`

– Addition:
Running netstat -nap on the libreelec machine. I got (among others):

udp 0 0 0.0.0.0:5353 0.0.0.0:* 723/avahi-daemon: r
udp 0 0 :::5353 :::* 723/avahi-daemon: r

Meaning that indeed the avahi-deamon (zeroconf) on the “outer” machine (libreelec) does use port 5353.
I think that modifying the 5353 port in docker is inevidble

Same configuration, same error…
You must disable zeroconfig in libreelec and resstart it
zeroconfig is in settings->services->Avahi

Chromecast is dead to me since around HA58… running HA in Docker on Synology…