home-assistant-libs / pychromecast

Library for Python 3 to communicate with the Google Chromecast.
MIT License
2.54k stars 380 forks source link

Recent versions fail to find my chromecast #611

Open caco3 opened 2 years ago

caco3 commented 2 years ago

I had a script working fine by connecting directly by IP:

import pychromecast
pychromecast.Chromecast("192.168.1.108")
# => Chromecast('192.168.1.108', port=8009, device=DeviceStatus(friendly_name='myChromecast', model_name='Eureka Dongle', manufacturer='Google Inc.', uuid=UUID('78c41f7a-7370-bdd1-99cf-515532fc4a81'), cast_type='cast'))

This work fine with pychromecast 7.7.1.

Now I tried to update to update to the latest version (11.0.0). I learned that I need to connect differently, but it doesn't find the chromecast anymore:

import pychromecast
chromecasts, browser = pychromecast.get_listed_chromecasts(known_hosts="192.168.1.108")
print(chromecasts) # <= Chromecast no longer found!

So am I doing something wrong or is it broken?

I tested the discovery_example.py example and it works fine:

Found cast device with UUID 78c41f7a-7370-bdd1-99cf-515532fc4a81
Currently known cast devices:
  78c41f7a-7370-bdd1-99cf-515532fc4a81 CastInfo(services={ServiceInfo(type='mdns', data='Chromecast-78c41f7a7370bdd199cf515532fc4a81._googlecast._tcp.local.')}, uuid=UUID('78c41f7a-7370-bdd1-99cf-515532fc4a81'), model_name='Chromecast', friendly_name='Wohnzimmer', host='192.168.1.108', port=8009, cast_type=None, manufacturer=None)

How ever I do NOT want to rely on mDNS!

Notes:

clach04 commented 2 years ago

@caco3 I'm in the same boat, the API definitely changed as a CastInfo is required. Unfortunately due to issue #290 client side code can't determine which API to use other than by using requirements file.

See the examples directory, I believe I saw a search demo that has ip/hostname filtering - but I suspect that may not work with your network setup as it appears to be a filter rather than a pointer to go check this address.

You might be able to create a dummy CastInfo object?

soreau commented 2 years ago

This just started happening to me today on 1st gen chromecasts. I have two and neither are found by pychromecast. The pychromecast system hasn't changed, seems something changed on the chromecast.

EDIT: Just as suddenly as it stopped, it started working again.

soreau commented 2 years ago

Today again, it has stopped working. I've rebooted the system, tried pychromecast on other machines, nothing has been working. The network is working fine as far as I know. I would really like to know what is causing this intermittent behavior.