Configure Cast integration for specific Chromecast devices only

Hi,
I wonder if anybody can help me. I’ve been using the Google Cast integration for a while with no issues. It has auto-discovered all my devices including Google Nest speakers/hubs, an Android TV and a Chromecast-enabled music streaming player. I’m not sure when it started but I’ve noticed that the Cast integration has recently started to report the music streamer device as unavailable and it automatically adds a duplicate device. This happens at least once each day and the device list gets longer and longer.

I don’t actually need to use the music streamer with the Google Cast integration so what I’d like to do is re-configure the integration to only include specific Chromecast devices (rather than auto-discovering them all). I know the IP addresses of the devices I want to use but it appears you need to know their UUID values to populate the ‘Allowed UUIDs’ field. I’ve managed to find UUID values for some devices by enabling debug logging for the integration and searching the log files but UUID values aren’t shown for every device. I have tried the procedure mentioned in the documentation using python commands to derive the UUID values but my technical skills aren’t sufficient to make sense of it.

My queston: Is there a way to stop the integration using auto-discovery (so that it will only include those devices listed under ‘Known hosts’)? Alternatively, is it possible to specify a list of ‘Allowed devices’ with IP addresses (instead of UUIDs)?

Im not sure if I’m about to tell you everything you’ve already done but does your config look somewhat like this?

discovery:
ignore:
- google_cast

cast:
known_hosts:
- 192.168.1.101 # Google Nest Hub
- 192.168.1.102 # Chromecast
- 192.168.1.103 # Android TV

logger:
default: warning
logs:
homeassistant.components.cast: debug

cast:
allow_uuids:
- 12345678-1234-5678-1234-567812345678
- 87654321-4321-6789-4321-678943216789

//and have you tried a script like this somehow?

import pychromecast

devices, browser = pychromecast.discovery.discover_chromecasts()
for device in devices:
print(f"Device: {device.friendly_name}, UUID: {device.uuid}")
browser.stop_discovery()

I have not tried any of this myself these are just examples. Let me know what happens or if this was useless.

Thanks for the response, Jerry. Apologies if this is a dumb question but where would I find the configuration file for the Cast integration? There aren’t any lines in my configuration.yaml that resemble the ones you listed so I’m guessing the Cast inegration has its own file somewhere?
Ian

I believe these lines should go into the home assistant configuration.yaml,
The home assistant configuration can be accessed via Home Assistant Add-on: File editor (setting>add ons> add on store) and it’ll be homeassistant/configuration.yaml

the home assistant configuration is what I use but sometimes you can drop stuff into the (device and service > integration(cast) > configure) but usually that doesn’t work for me.

Best of luck :slight_smile:

Sorted! I noticed the statements below that you suggested in your previous reply and was curious to see whether they might yield any additional debug information about my Chromecast devices.

logger:
  default: warning
logs:
  homeassistant.components.cast: debug

I added the four lines to the end of my configuration.yaml file and restarted HA. I then checked the log file and saw messages similar to the one below for each of my Chromecast devices. Each included the device’s UUID which is what I needed.

2024-12-06 19:42:05.918 DEBUG (Thread-4) [homeassistant.components.cast.discovery] Discovered new or updated chromecast ChromecastInfo(cast_info=CastInfo(services={HostServiceInfo(host=‘192.168.178.203’, port=8009), MDNSServiceInfo(name=‘???-???-49b8c1d0301a39ce77c7ecf8cd3d532d._googlecast._tcp.local.’)}, uuid=UUID(‘49b8c1d0-301a-39ce-77c7-ecf8cd3d532d’), model_name=‘???’, friendly_name=‘???’, host=‘192.168.178.203’, port=8009, cast_type=‘audio’, manufacturer=‘???’), is_dynamic_group=None)

I added the UUID values for the devices I wanted to include in the Google Cast integration (I listed them all in the ‘Allowed devices’ field of the integrations UI), restarted HA, and they were then the only ones listed as devices. Problem solved.

Thank you so much for help, Jerry. It’s appreciated.
Ian

1 Like