Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Random issue with chromecast audio dongle #195

Closed
strunker opened this issue Nov 15, 2017 · 23 comments
Closed

Random issue with chromecast audio dongle #195

strunker opened this issue Nov 15, 2017 · 23 comments

Comments

@strunker
Copy link
Contributor

This just started happening, one thing I noticed is that all my other chromecasts devices are using port 8008, I tried to swap the port to 8008 by using the port= param but this didnt seem to make a difference. I can connect to the dongle fine from my phone just isnt working via script anymore for only the audio dongle. Just a random connection error.

Traceback (most recent call last):
File "C:\Python27\Echo\test.py", line 158, in
CC2 = pychromecast.Chromecast("10.1.1.12",port=8009)
File "C:\Python27\lib\site-packages\pychromecast_init_.py", line 169, in init
"Could not connect to {}:{}".format(self.host, self.port))
pychromecast.error.ChromecastConnectionError: Could not connect to 10.1.1.12:8009

@lsmithso
Copy link

Hi: This just started happening with my chromecast audio too. It
happens every time I connect and is not at all random. Its been
working for weeks just fine but stopped working last night.

I enabled debug logging:

INFO:pychromecast:Querying device status
DEBUG:urllib3.connectionpool:Starting new HTTP connection (1): 192.168.0.86
DEBUG:urllib3.connectionpool:http://192.168.0.86:8008 "GET /ssdp/device-desc.xml HTTP/1.1" 404 0

and

curl -v http://192.168.0.86:8008/ssdp/device-desc.xml

  • About to connect() to 192.168.0.86 port 8008 (#0)
  • Trying 192.168.0.86... connected

GET /ssdp/device-desc.xml HTTP/1.1
User-Agent: curl/7.22.0 (x86_64-pc-linux-gnu) libcurl/7.22.0 OpenSSL/1.0.1 zlib/1.2.3.4 libidn/1.23 librtmp/2.3
Host: 192.168.0.86:8008
Accept: /

< HTTP/1.1 404 Not Found
< Content-Length:0
< Content-Type:text/html
<

  • Connection #0 to host 192.168.0.86 left intact
  • Closing connection #0

Has there been a ffirmware upgrade that broke pychromecast?

@strunker
Copy link
Contributor Author

strunker commented Nov 17, 2017

So. What is most bizarre about this issue is... When you use the getchromecast method to discover the devices the dongle works fine. I ended up writing the below function, using globals (since I have other functions that need to be able to utilize the objects). I run into 0 issue with this method, and everything works out. Obviously you would need to change the device names to match your own.

I also call the function inside of a thread, so that the rest of my script can continue execution without being blocked.

Its troubling a bit to me though because I dont understand why this works, and creating the object manually with ip as a parameter does not. Nor why it only doesnt work on the dongle, yet works with manual creation for all other devices.

def BuildChromeCastObjects():
    global CC1
    global CC2
    global CC3
    global CC4
    global CC5
    global Tele
    global Kitchen
    global Bedroom
    global Group
    global LivingRoom
    try:
        chromecasts = pychromecast.get_chromecasts()
        for dev in chromecasts:
            print dev
            if dev.device.friendly_name == "Strunker":
                #television
                CC1 = dev
                Tele = CC1.media_controller
                CC1.set_volume(volume)
            elif dev.device.friendly_name == "Strunker Kitchen":
                #kitchen dongle
                CC2 = dev
                Kitchen = CC2.media_controller
                CC2.set_volume(volume)
            elif dev.device.friendly_name == "Strunker SoundBar":
                #bedroom soundbar
                CC3 = dev
                Bedroom = CC3.media_controller
                CC3.set_volume(volume)
            elif dev.device.friendly_name == "Group Audio":
                #audio group
                CC4 = dev
                Group = CC4.media_controller
                CC4.set_volume(volume)
            elif dev.device.friendly_name == "Strunker SoundBar LR":
                #living room soundbar
                CC5 = dev
                LivingRoom = CC5.media_controller
                CC5.set_volume(volume)  
            else:
                print "New Device We Have Not Enountered"
    except Exception as E:
        print "BIG CHROMECAST ERROR", E

StartChromecastThread = threading.Thread(target=BuildChromeCastObjects)
StartChromecastThread.start() 

@lsmithso
Copy link

lsmithso commented Nov 17, 2017 via email

@strunker
Copy link
Contributor Author

strunker commented Nov 17, 2017 via email

@lsmithso
Copy link

lsmithso commented Nov 17, 2017 via email

@Kernald
Copy link

Kernald commented Nov 19, 2017

This is probably related to home-assistant/core#9965 . Long story short: the /ssdp/device-desc.xml endpoint seems to be gone starting with 1.28.x release. The /setup/eureka_info?options=detail one still returns valid values, apparently everything needed. In the issue I linked, someone told he was currently working on a fix.

@strunker
Copy link
Contributor Author

strunker commented Nov 19, 2017 via email

@lsmithso
Copy link

lsmithso commented Nov 19, 2017 via email

@OttoWinter
Copy link
Collaborator

OttoWinter commented Nov 19, 2017

Yes, that's expected. When using discovery, pychromecast already gets the required data (model name, api version, ...) via zeroconf and does not fail when the /ssdp/device-desc.xml returns an error.

When manually creating via ip, the unpatched version of the library has to get the data via /ssdp/device-desc.xml, so the manual setup fails when that endpoints returns a 404.

@strunker
Copy link
Contributor Author

strunker commented Nov 19, 2017 via email

@OttoWinter
Copy link
Collaborator

@strunker I guess this issue can now closed, right?

@strunker
Copy link
Contributor Author

strunker commented Nov 21, 2017 via email

@fnxweb
Copy link

fnxweb commented Dec 1, 2017

Sorry to jump in here, I couldn't find a forum or mailing list; I'm seeing this 404 error when trying to connect to my new Google Home Mini [Fedora 26, Python3, pychromecast 0.8.2/Jul-17] via IP address.

Thing is, I am also getting an empty list from get_chromecasts() [I do see a load of MDNS replies, but I don't know anything about that protocol so don't know if the contents are OK — they don't look broken].

@OttoWinter
Copy link
Collaborator

@fnxweb As you've already mentioned, you're using pychromecast version 0.8.2 (within home assistant, I suppose) but this issue has already been resolved in version 1.0.2 - so this issue will be fixed with the next Home Assistant release (see home-assistant/core#10728)

@fnxweb
Copy link

fnxweb commented Dec 1, 2017

Ah, thanks. No, it's the native F26 package. I'll rebuild it with a newer release. Cheers.

@fnxweb
Copy link

fnxweb commented Dec 2, 2017

OK ta, I can now create a Chromecast by IP, but I do still get an empty list back from get_chromecasts() (1.0.2, now in Fedora 27, Python 3). PS: did you forget to tag 1.0.2?

@OttoWinter
Copy link
Collaborator

@fnxweb If adding by IP works, this is probably not related to this issue. I don't know your exact setup but maybe have a look at #36.

@fnxweb
Copy link

fnxweb commented Dec 3, 2017

@OttoWinter Ta; I only mentioned it FYI, I'm happy enough with access by IP (prefer, even). Unfortunately my Google Home Mini doesn't want to play ball anyway (trying to programmatically cast media, it just beeps at me and otherwise ignores me, and that's not just from pychromecast). I'll look into it again some other day.

@strunker
Copy link
Contributor Author

strunker commented Dec 3, 2017

@fnxweb I ran into similar issue on this latest version.

in 1.0.2 I am once again able to create via IP, which is good. However, like you, play_media was sporadic. It worked initially, but then started to fail sending audio to the dongle \ my sound bars. I tried local files, as well as youtube audio links and neither would play anything.

For the time being I reverted back to the .8 version and am using the function I linked earlier in the thread to create the objects. I have no issue with play_media when using older version \ above function. The cost is I cant create via IP on .8 version.

@fnxweb
Copy link

fnxweb commented Dec 3, 2017

@strunker Which .8? I started with 0.8.2 which didn't work either way for me.

@strunker
Copy link
Contributor Author

strunker commented Dec 3, 2017 via email

@OttoWinter
Copy link
Collaborator

@strunker Does 1.0.3 work for you now? Can this be closed?

@strunker
Copy link
Contributor Author

@OttoWinter

1.0.3 didn'twork for me but I changed my code for auto discovery and stayed on the version prior. I'd say close this. It seems to be working for everyone but me, so all good here.

Thanks for your work and attention on this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants