home-assistant-libs / pychromecast

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

No device to cast found #442

Open OwnM4ker opened 3 years ago

OwnM4ker commented 3 years ago

I followed instalation guide in readme file and when i wanted to run a script i got just empty list. What may block it?

Python 3.8.5 (default, Jul 28 2020, 12:59:40) 
[GCC 9.3.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import pychromecast
>>> chromecasts, browser = pychromecast.get_chromecasts()
>>> chromecasts
[]

I also tried:

venv > username > username-Notebook-Type > ~ > Path > To > Project > $ > catt scan
Scanning Chromecasts...
Error: No devices found.

I am able to cast via my phone and Google Chrome to youtube to my Samsung Smart TV. my machine - Ubuntu Python - 3.8.5 pychromecast - 7.7.1

ghost commented 3 years ago

Yep, I have the same problem with a whole bunch of TV's in our office that have Chromecast built-in that never get updated by the manufacturer. Something changed after 7.6.0 - downgrading to that version worked for me.

OwnM4ker commented 3 years ago

@dcdeo I tried to downgrand the version to 7.6.0 but it hasn't changed anything. The issues that i had persists. If anyone will find out the solution, please, let me now.

emontnemery commented 3 years ago

pychromecast depends on MDNS discovery to find cast devices, which in turn relies on multicast UDP as transport. Multicast UDP is not routed across sub-networks, and may also not be routed between WLAN and Ethernet interfaces by WiFi APs.

Can you describe your setup in some more detail:

Some hints here:

emontnemery commented 3 years ago

@dcdeo It's interesting that you saw a change after version 7.6.0, can you please open an issue for that?

ghost commented 3 years ago

@dcdeo It's interesting that you saw a change after version 7.6.0, can you please open an issue for that?

Yes, will do. I noticed we were both using catt, so I'll raise it with them too.

OwnM4ker commented 3 years ago

Can you describe your setup in some more detail:

* IP address and network type (WLAN, wired) of the computer running pychromecast

* Is pychromecast running natively, or inside docker or a VM

@emontnemery I have my notebook (dynamic IP) connected wirelessly to the same network as the TV is (also WLAN - static IP). I checked links attached to the comment, but I don't understand the second point. I just opened terminal, typed python3, and then imported pychromecast and tried to get chromecast as i already mentioned at the beginning.

dgilbert2 commented 3 years ago

I also have this problem where with the latest version of pychromecast, I cannot find my chromecast device. I use it with TVH_EPG which produces the attached errors tmphng2pqo6.html.pdf.

If I go back to a version of pychromecast from a year ago, sorry don't know its version number, everything works fine.

emontnemery commented 3 years ago

@OwnM4ker Is your phone Android or iOS?

@dgilbert2 it would be extremely helpful if you could find out which version is working. Are you sure it was related to changing pychromecast versions, and not due to python zeroconf?

dgilbert2 commented 3 years ago

@emontnemery , thank you for your reply.

zeroconf is version 0.28.8

Looking in the pychromecast working directory, how can I read the version of it? Attached is a screenshot of the files it contains. Capture

emontnemery commented 3 years ago

Do you mean zeroconf is 0.28.8 in both cases, and you're sure that's the version imported by pychromecast?

Unfortunately, it's not possible to see the pychromecast version from the files. But you're most welcome to zip up the contents, excluding pycache and attach here.

dgilbert2 commented 3 years ago

Yes, zeroconf is 0.28.8 in both cases.

Thanks, I've attached my working pychromecast directory FYI pychromecast.zip

dgilbert2 commented 3 years ago

I've spent some time today to try the various pychromecast versions from the github releases archive and I've now found that the last version that works on my TVH_EPG setup is 6.0.1, ie 7.x.x does not work for me.

Not sure what this means but I hope it helps.

emontnemery commented 3 years ago

Can you paste the code you use to discover?

If you run the example, python3 discovery_example.py, does that work?

dgilbert2 commented 3 years ago

Yes, discovery_example.py works.

I'm not the author of tvh_epg.py so do not know its details, sorry. I've attached the latest version though as a txt file.

tvh_epg.txt

emontnemery commented 3 years ago

Try making this change:

-    chromecasts = pychromecast.get_chromecasts()
+    chromecasts, browser = pychromecast.get_chromecasts()
dgilbert2 commented 3 years ago

Thanks @emontnemery. With this change tvh_epg works using the latest 7.x.x of pychromecast. I'll advise the author of the change needed.

I guess the complication now is needing to know what version of pychromecast is installed as this would stop the older installed versions from working.

emontnemery commented 3 years ago

The author of tvh_epg can check the return value:

    chromecasts = pychromecast.get_chromecasts()
+   if isinstance(chromecasts , tuple)
+       chromecasts, browser = chromecasts
+       browser.close()

I'll mark our conversation as off topic as it's not related to @OwnM4ker's problem.