Google Cast with Docker - No Google Cast devices found

@PPCM Did you manage to get Cast working via Kubernetes? I’m running into this issue now. If you found the solution that would be appreciated. If not, I’ll continue looking and let you know what I find.


Patrick

also having this issue, anyone aware of a fix?

Hi Craig,

The latest HA allows you to enter the IP address of the device from the Integrations section. This seems to work for me as I was able to add my Nest Hub and Nest Mini without an issue.

Might be worth trying it now. (I am on the dev version, but I believe I saw it added on 2021.4)

For anyone googling this thread or still have issues;
if you want to run Home Assistant in Docker and NOT use host mode networking for whatever reason, but still would like mDNS discovery to work, read on.
(According to the official documentation this is not supported, so beware, you are on your own, here be dragons, etc.)

The solution requires you to be able to install software on your docker host.
I got it working on Ubuntu 18.04

What you need to do is allow UDP packets on port 5353 in to your Docker host, and install avahi-dameon and configure it to route packets between your interfaces.

For Ubuntu:
Open firewall (replace with your ip, and tweak to your security liking)
sudo ufw allow from any to 192.168.1.<your_ip> port 5353
Install avahi if not already installed:
sudo apt install avahi-daemon

Now edit the configuration file located at /etc/avahi/avahi-daemon.conf
Make sure to uncomment or change the following lines:
Under the [server] heading find allow-interfaces and change it to contain your server interface and your docker interface.
For me this looks like
allow-interfaces=eno1,docker0

Under the [reflector] heading, find and uncomment/edit:
enable-reflector=yes

Save your changes and restart avahi-daemon
sudo systemctl restart avahi-daemon

That’s it. Your devices should now be auto discovered. I actually missed this first and thought it didn’t work, but you’ll get a little notice in Home Assistant that there are devices discovered.
Both my Chromecast and my printer (:exploding_head:) got discovered.

If it doesn’t work, start troubleshooting with tcpdump and make sure the packets reach both your host and the container.

On the host
tcpdump port 5353 -i any

On the docker container, get a shell on the container and
apk add tcpdump && tcpdump port 5353

1 Like

Thanks for this post. It just solved problem I’ve been working on for hours :smiley:
In my case HA would not discover HomeKit Devices.

Hi Peterh

Thanks for your guide!

As a complete Linux and docker-noob I am trying to get the Cast intergration working. As this is not covered by any popular YT video (like i followed, settining everything up) I got stuck in configuerring this part. And typing this means it is basically my last resort…

I think I can win this battle by just a little bit of steering in the right direction and thus I have a couple of questions:

To have it all clear, as of today I have running:

My modem/router (fritzbox): 192.168.178.1
Linux Ubuntu: I SSH into [username]@192.168.178.73
with Docker compose in /opt dir, with 7 containers that work properly (Portainer, HA, Cloudflair(tunnel), duplicati, Jellyfin, mosquitto and ZB2MQTT)

HA has network: Tunnel,for remote access via cloudflare and thus is not in network:host mode, like you described!

I followed your guide and noticed the following/have questions:

  1. The command sudo ufw allow from any to 192.168.1.<your_ip> port 5353. What do you mean with IP. Should this be in my case the IP of the server (192.168.178.73?) or something else. Where should i look?

  2. I noticed that in the base file avahi-daemon.conf under allow-interfaces was listed "eth0" as default option, instead of eno1 that you suggest. When I exec. Ip address show on the server I do see the 2 values that you name: eno1 and docker0. Soo I should copy your code, right? Or do I leave the eth0 value. or all 3?

  3. tcpdump port 5353 -i any gets me a lot of verbose lines untill i stop it with ctrl C. No clue what it means, but after 2 mins of running: 293 packets captured, 296 packets received by filter, 0 packets dropped by kernel

If i go to the container (via portainer) and open an console bin/bash into container as default user and I use apk add tcpdump && tcpdump port 5353, I get 0 packets captured, 0 packets received by filter, 0 packets dropped by kernel

So I think it has to do something with the HA container. But I am clueless what to try and do next. Can you help me troubleshoot, I have a feeling the sollution is fairly obvious, but again im just a noob.

@Svenyboy17 I just got this working so will endeavour to answer your questions.

My setup is rpi5 with homeassistant running in its own network on 10.22.0.2. The host I call dockerbox and it has ip address 192.168.0.70.

Here is what I did:

  1. I ignored the sudo ufw line because I am not running ufw firewall on my dockerbox. In your case I think you would have used the ip of your host - if I did have ufw running then I think I would have needed sudo ufw allow from any to 192.168.0.70 port 5353

  2. I found that avahi-daemon was alreaady installed when I did sudo apt install avahi-daemon. (I use raspbian minimal install but it was still there).

  3. I made the changes to /etc/avahi/avahi-daemon.conf as described. In my case ifconfig showed a whole load of interfaces including lo, eth0, docker0 etc and I looked for the one that held my home assistant install. It was called br-ec3b5e449851 and I found it by finding 10.22.0.1/16. So my line there looked like:

allow-interfaces=eth0,br-ec3b5e449851

  1. I me the other changes to /etc/avahi/avahi-daemon.conf and restarted avahi-daemon exactly as described.

And it immediately started working. I could play radio fine, TTS is not working, but I am not sure if that is anything to do with this.

I know it is a bit late but hopefully this might help someone.

I worked out the TTS issue was because the cast device could not see the homeasssitant docker container API path because it used the ip address. Happily I use a reverse proxy (caddy - which is excellent) so I was able to go in to the configuration.yaml and put in my internal_url: to the URL I use, restart ha and bingo, TTS started working immediately.

Thanks for replying @cyber5 and sorry for not seeing this sooner @Svenyboy17

Firewall should be opened for your ip as you suspected:

The interface to use in avahi-daemon.conf is most probably eno1, if that is the interface that has your server ip 192.168.178.73

Hope this works