Google Cast with Docker - No Google Cast devices found

Hi,

Since moving my Hassio configuration over to docker I’ve been having issue with my Google Homes disappearing. I’m using Docker Compose and have the container connected to the host network.

What I’ve found is that the container can see ALL networks on the host including all bridge networks for other containers. It appears that Home Assistant is not using the right IP range to send the broadcast packets for discovering cast devices.

Here’s how I’ve came to this conclusion.

Get a bash console into the Home Assistant container
docker exec -it home-assistant /bin/bash

Install tcpdump
apk add tcpdump

Run tcpdump filtering for cast data. From the home assistant UI try to enable the Google Cast integration.
tcpdump | grep cast

What I see is:
18:43:05.058008 IP 172.17.0.1.5353 > 224.0.0.251.5353: 0 PTR (QM)? _googlecast._tcp.local. (40)

My home network is on a 192.168.0.0/24 subnet and I believe the above output confirms the Home Assistant is using the default bridge network for it’s cast detection.

By running ip a | grep inet I can confirm that home assistant can see all host networks.

ip a | grep inet
inet 127.0.0.1/8 scope host lo
inet 192.168.0.12/24 brd 192.168.0.255 scope global eno1
inet 172.19.0.1/16 brd 172.19.255.255 scope global br-c2e8e6550627
inet 172.17.0.1/16 brd 172.17.255.255 scope global docker0
inet 172.18.0.1/16 brd 172.18.255.255 scope global br-14c08394512f

Has anyone else came across this or know how to block/hide other host networks from home-assistant? Or force it to use the correct 192.168.0.0 range as it’s default?

Thanks,
Kev

As a follow up to this. Launching the Home-Assistant container in privileged mode solved the issue. Not instantly. But within 24 hours I had a popup that cast devices had been found.

Can you share the commands you used to launch the homeassitant container in privileged mode? The supervisor and version containers are already running in priv mode. I assume I would just need to change the hassio-dns container (which is not running in priv mode) to get this to work.

Here are my Hassio containers that are not addons.

a310cf1aa202 homeassistant/amd64-hassio-dns:1 “coredns -conf /conf…” 5 hours ago Up 5 hours hassio_dns
0703fe7514da homeassistant/amd64-hassio-supervisor “/bin/entry.sh pytho…” 2 weeks ago Up 5 hours hassio_supervisor
cc8259450c51 homeassistant/qemux86-64-homeassistant:0.103.4 “/bin/entry.sh pytho…” 4 weeks ago

Sorry if this is a basic question, I am new to docker and google was not helpful in figuring out how to launch a container in priv mode. Also will this change stick on reboot?

It looks like you’re using hassio which does this for you already.

Weird because I am getting the same results that you are. I have a dedicated network for IoT devices vlan 30. My hassio, running as a vm, has interfaces on my primary network (vlan 10) and on vlan 30. Google cast cannot discover any devices, all of which exist on vlan 30. I can manually add them and they work. when I run tcpdump | grep cast I get the exact same result as you which lead me to believe that your fix may work especially since the container labeled dns was not running in privileged mode. Do you have any ideas?

I have the same issue, tried everything, but i can’t make it working

Hi, please explain step by step how you add them manually, thanks.

I think you guys are running your home-assistant in a different network. That is why it will be undetected.

My homeassistant network has not changed, I run it from 192.168.68.134, my casts are 192.168.68.140 and 192.168.68.147, been running them for over 2 years and they suddenly stopped showing, I miss my automations, is there a way of forcing them in the config? I tried :

cast:
  media_player:
    - host: 192.168.68.140
    - host: 192.168.68.147 

This doesn’t bring them back, I trieg removing the integration, rebooting them and reloading it, still no joy.

I also have an issue with Google Home devices (few minis and one hub) - I’m building a new install of HA.
HA-Core in docker. Network mode is host, but integration doesn’t find no one of devices.

So the problem is solved and was very stupid. I’m running HA core on docker container (network_mode: host) inside KVM Guest Ubuntu machine. So the problem is that by default KVM is not forwarding multicast traffic to guest machines.

Can I ask why you’re not using Hassid on KVM? I use docker on the host and have around 50 containers. After the recent (retracted) announcement I moved to HassOS on KVM. I prefer it as it keeps home assistant free from my meddling with docker and it stops home assistant messing with docker swarm.

I had the same problem. When you create the docker you need to set network mode to host. So if creating docker on command line add “–net=host” to the command line.

Check documentation at https://www.home-assistant.io/integrations/cast/

Ok so I didn’t see anyone call out any explicit solutions to this so I’ll post what fixed this issue for me.

Firstly I’m running a Centos 7 box w/ portainer with docker containers.

I found that nowhere explicitly does the Google Cast integration state that 5353/udp needs to be available at the host level.

I found when searching discovery that that port needs to be open for Google Cast to work https://www.home-assistant.io/integrations/discovery/

So for me…

[tj.****@hothserv1 home-assistant]$ sudo firewall-cmd --zone=public --add-port=5353/udp --permanent
[sudo] password for tj.hoth:
success
[tj.****@hothserv1 home-assistant]$ sudo firewall-cmd --reload
success

Then I went into portainer and restarted the container and boom Google Cast auto detected my devices.

Are you running CentOS on physical machine or Virtual?

Centos 7 is running on the hardware docker on top of it.

Check that mDNS is working… .this can be a problem with a switch / FW

I guess my response wasn’t all too clear. I was stating that my solution was opening that firewall port on the host level. I troubleshot this for about 2 days and solved it by opening the port. I posted my solution here in case anyone others weren’t aware that 5353 needed to be accessible at the host level since it’s not anywhere in the installation documentation. After I openined that port on my hosts firewall my devices were detected instantly.

So for those of you who are using Google Cast and reverse proxy, how are you doing it? Sounds like I need to have this container on host to use the googles, and on another network simultaneously for letsencrypt/etc (which is not possible when using host). Maybe I just don’t know enough about configuring my proxy conf to make this work

I have the same issue, in my case, I don’t use Docker but Kubernetes
I am not able to use “–net=host” in the command line or in config file

Is there a way to configure Google Cast in the config file?