So after almost giving up, I’ve got it all working again.
It turns out that it was a problem with my OS while running pyChromecast. I am running Home Assistant in Docker on a Raspberry Pi 4.
When I tried running the following command on my Raspberry Pi 4:
python3 -c "import pychromecast; print(pychromecast.get_listed_chromecasts(friendly_names=['Living Room TV']))"
I got the following error:
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/.../pychromecast/pychromecast/discovery.py", line 506, in discover_chromecasts
zconf = zeroconf_instance or zeroconf.Zeroconf()
File "/.../.local/lib/python3.8/site-packages/zeroconf/__init__.py", line 2493, in __init__
self._listen_socket, self._respond_sockets = create_sockets(
File "/.../.local/lib/python3.8/site-packages/zeroconf/__init__.py", line 2328, in create_sockets
respond_socket = add_multicast_member(cast(socket.socket, listen_socket), i, apple_p2p=apple_p2p)
File "/.../.local/lib/python3.8/site-packages/zeroconf/__init__.py", line 2273, in add_multicast_member
listen_socket.setsockopt(socket.IPPROTO_IP, socket.IP_ADD_MEMBERSHIP, _value)
OSError: [Errno 105] No buffer space available
After a lot of Googling, I found a solution that worked.
First, take a backup of /etc/sysctl.conf
.
Next, replace the contents of the file with:
# Bigger buffers (to make 40Gb more practical). These are maximums, but the default is unaffected.
net.core.wmem_max=268435456
net.core.rmem_max=268435456
net.core.netdev_max_backlog=10000
# Avoids problems with multicast traffic arriving on non-default interfaces
net.ipv4.conf.default.rp_filter=0
net.ipv4.conf.all.rp_filter=0
# Force IGMP v2 (required by CBF switch)
net.ipv4.conf.all.force_igmp_version=2
net.ipv4.conf.default.force_igmp_version=2
# Increase the ARP cache table
net.ipv4.neigh.default.gc_thresh3=4096
net.ipv4.neigh.default.gc_thresh2=2048
net.ipv4.neigh.default.gc_thresh1=1024
# Increase number of multicast groups permitted
net.ipv4.igmp_max_memberships=1024
Note: I don’t know what else could fail because of this but everything is working fine for me so far.
Finally, reload the configuration file using sudo sysctl -p
or reboot the system.
Source: Mpho Mphego
Source: Correlator-Beamforming Tests (GitHub)
All Google Cast devices should now show up in Home Assistant and are controllable!