pychromecast icon indicating copy to clipboard operation
pychromecast copied to clipboard

SiriusXM/Chromecast Casting Issue

Open rac146 opened this issue 1 year ago • 9 comments

There is an issue regarding Chromecast integration in Home Assistant and the SiriusXM app - if the cast integration is enabled, casting SiriusXM to a Chromecast device will fail with an error code 1001. Disabling cast integration in HASS fixes the problem.

Original discussion here - also confirmed another add-on that uses pychromecast (Music Assistant 2.0 Beta) results in the same behavior:

https://github.com/home-assistant/core/issues/93360

rac146 avatar Jul 25 '23 19:07 rac146

I'm able to repro the issue using the ./examples/simple_listener_example.py script in this repo.

Basic steps:

  1. ensure the cast home assistant integration is disabled and reboot home assistant
  2. use the siriusxm app on my android phone to cast to the same cast device I use in CAST_NAME below (it should work)
  3. clone this repo
  4. install pychromecast via pip locally
  5. run the script python ./examples/simple_listener_example.py --cast 'Kitchen Display' --show-debug --show-zeroconf-debug > /tmp/log.txt 2>&1
  6. use the siriusxm app on my android phone to cast to the same cast device I used in CAST_NAME above (you should see the error in the siriusxm app)

Below is the log file when I performed the failed cast attempt (apologies for the extra noise in here...I have quite a few chromecasts on my network)

log.txt

jsermer avatar Jul 25 '23 21:07 jsermer

Referencing this other one which is most likely the same https://github.com/home-assistant/core/issues/87387

PereViader avatar Jul 26 '23 10:07 PereViader

So just an update. SiriusXM completely redesigned their mobile app and now casting works for me!!

I am on and Android device with version 7.0.2 of the SiriusXM app.

Hope this helps someone.

krkeegan avatar Dec 18 '23 22:12 krkeegan

I haven't tried it yet, but I suppose it will work again. I have noticed that with the newly designed website and app (even though I don't like it much. I just want my favorites, don't care about the rest!) it appears that they stopped cutting off playback immediately if you had two devices playing from the same account. It used to be so bad that if I even turned on my stereo receiver it would cut off my stream on my computer almost immediately, even if I didn't open the SiriusXM app on the receiver and start using it. Seems far more laxed for now. Not sure if that will continue or if they'll harden that down the road. Glad this is fixed though!

scythe944 avatar Dec 18 '23 22:12 scythe944

I know I'm resurrecting an old issue here - but can confirm that the issue is still present with Audible as mentioned above: https://github.com/home-assistant/core/issues/87387

Can confirm that disabling both HA Google Cast integration and Music Assistant allows me to cast Audible just fine. If I re-enable, it breaks again.

linkian19 avatar Mar 15 '24 20:03 linkian19

I noticed that by adding a 2 second delay here, the issue is avoided for me (in the devcontainer HA environment):

I'm sure this is too invasive, but I wanted to note that I think something is happening such that if Audible gets a message it doesn't expect (even if it's just a status message), then it abandons the session. Sleeping for 2 seconds allows the expected messages to come from the Chromecast in the order expected by the application. I'm completely new to all of this, but am trying to help out.

https://github.com/home-assistant-libs/pychromecast/blob/b2e3c9dd4c554d50d1f526415d31c453c5dd391e/pychromecast/controllers/receiver.py#L112

    def receive_message(self, _message: CastMessage, data: dict) -> bool:
        """
        Called when a receiver message is received.

        data is message.payload_utf8 interpreted as a JSON dict.
        """

        sleep(2) # <!--- Delay to allow application to connect before processing

        if data[MESSAGE_TYPE] == TYPE_RECEIVER_STATUS:
            self._process_get_status(data)

            return True

        if data[MESSAGE_TYPE] == TYPE_LAUNCH_ERROR:
            self._process_launch_error(data)

            return True

        return False

geoffoxholm avatar Mar 24 '24 16:03 geoffoxholm

I've narrowed this down a but further, and pushed up a branch here.

https://github.com/geoffoxholm/pychromecast/blob/4ab1fad5423c524f5832b9731432496f3e47edcb/pychromecast/socket_client.py#L492-L495

geoffoxholm avatar Mar 29 '24 18:03 geoffoxholm

How can I test this out on my main install? I've tried copying the cast component from homeassistant/core into custom_components but I can't figure out how to get that to load.

This is the only edit i made, by the way:

    def new_cast_status(self, status: CastStatus) -> None:
        # ... redacted for brevity... 

        # When a new cast status is received, give Audible time to load
        if status.app_id == "25456794":
            self.logger.debug("Detected Audible connection. Sleeping for 1s")
            time.sleep(1)

geoffoxholm avatar Mar 29 '24 21:03 geoffoxholm

Just bumping this issue again. Issue is still present on HA Core 2024.8.0 with trying to cast Audible audio.

If I disable the Cast integration then Audible casting to Cast devices works as expected. Enabling the integration breaks it.

It would be greatly appreciated if this can get looked at. I'd really love to be able to have my cast devices enabled in Home Assistant.

I'm happy to gather any logs or test things out as needed.

Thank you!

linkian19 avatar Aug 10 '24 15:08 linkian19