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

Cast device not launching properly, but works if timeout is ignored #365

Closed
5 of 8 tasks
Gramatus opened this issue Nov 27, 2022 · 20 comments
Closed
5 of 8 tasks

Cast device not launching properly, but works if timeout is ignored #365

Gramatus opened this issue Nov 27, 2022 · 20 comments
Assignees
Labels
bug Something isn't working

Comments

@Gramatus
Copy link
Contributor

Gramatus commented Nov 27, 2022

Bug Ticket

Describe the bug

I am not sure if this is relevant for anyone else, but in case it creeps up other places I decided to create a report as I have a solution if anyone else experiences the same problem.
Basically it seems my cast devices has some sort of issue with starting properly. This does not only include spotcast, but also when trying to cast Spotify from the web player. Most of my devices are Chromecast audio, but I also have a few normal Chromecasts.
What happens is the app is started (I hear the "startup sound"), but not totally started (on the normal chromecasts, the screen goes black).

Now, what I discovered is that this causes Spotcast to fail because the is_launched property of the SpotifyController class stays false. However, if I ignore that and simply try to start playing anyways everything works fine.

If this becomes a problem, and not just something happening on my setup, it seems it can be fixed by ignoring that is_launched is False.
If no one else experiences the same, feel free to ignore this as I have fixed the issue for myself.

I made these changes to Spotcast, and now everything seems to work for me:

  1. Spotify_controller.py, line 104 to 106 changed to:
            # raise LaunchError(
            #     "Timeout when waiting for status response from Spotify app"
            # )
            self.logger.warning("Timeout when waiting for status response from Spotify app")
  1. Spotcast_controller.py, linje 94-96 changed to:
            # raise HomeAssistantError(
            #     "Failed to launch spotify controller due to timeout"
            # )
            _LOGGER.warning("Spotify controller did not launch properly before timeout, this might not be a problem")
  • Using latest version of spotcast
  • Using latest stable version of Home Assistant
  • I have setup the Spotify integration in Home Assistant
  • I have Spotify Premium
  • I am using multiple accounts
  • I have renewed my sp_dc and sp_key values and restarted Home Assistant (see README)
  • I'm attaching relevant logs with level debug for component spotcast (see README)
  • I'm using entity_id in the service call and have tried device_name but the issue remains

Environment

  • Installation type: HA_OS
  • HA version: 2022.11.4
  • spotcast version: 3.6.29 (but I have manually included the fix from 3.6.30)

Configuration

Add your configuration

Service Call

If relevant, provide a yaml of the service call or explain the action taken to replicate the issue.

Additional context

Add any other context about the problem here.

@Gramatus Gramatus added the bug Something isn't working label Nov 27, 2022
@DanDixon
Copy link

This fixed the problem for me that I reported:
https://community.home-assistant.io/t/spotcast-custom-component-to-start-playback-on-an-idle-chromecast-device/114232/911?u=ozstone

Thank you so much, @Gramatus

And a massive thanks to @fondberg for making this in the first place. Doing away with trying to start music on speaker groups using Google Assistant was an awful experience that worked maybe half? the time. Thank you again!

Cheers to @fcusson for helping too!

@Johnito
Copy link

Johnito commented Nov 27, 2022

@Gramatus thank you so much for taking the time to post your fix. I also had this issue and had to send every command to play something 2 times to actually get past the startup sound.

@jsv93
Copy link

jsv93 commented Nov 28, 2022

@Gramatus Thank you so much for posting this fix! I had been chasing this for hours on end. After adjusting as per your recomendation it is working again. Any idea what has caused this to happen?

@tasteebeverage
Copy link

@Gramatus , thank you for this! I was banging my head against the wall trying to figure out what went wrong and the fix you described worked for me.

@Gramatus
Copy link
Contributor Author

Any idea what has caused this to happen?

As far as I understand it, there seems to be an error in the Spotify Chromecast "app" (the thing running on the Chromecast). I base that on the fact that the same behaviour happens if I try to cast using Chrome.

As such this is a rather bad workaround and probably needs some smarter code if it is to be included in Spotcast, but as the other commenters have confirmed it seems to work for now.

@antonio1475
Copy link

antonio1475 commented Nov 28, 2022

Thank you @Gramatus. Your changes work for me too.

The experience is not the original from months ago (Spotify logo > 10 seconds black screen > starts playing) but it works at least! 😄

Although I also see, as you mentioned, that casting from Spotify Chrome does the same (or even worse, it doesn't get to play for me! I'd be pissed if I was a normal user using Spotify web to cast, and not HA & Spotcast 😅 )

It also solves (directly or indirectly?) #334 , which I was working around it by repeating the Spotcast service twice.

@TheFes
Copy link

TheFes commented Nov 28, 2022

There seem to me more issues regarding Spotify on Google Cast devices. I've noticed several times that the device reports as idle in Home Assistant while it is actively playing on Spotify

Anyway, thanks a lot for the fix described in your post, it works for me as well, although it is a bit slow.

@JesusArmy
Copy link

Thanks @Gramatus. I do confirm that I had same issue and and commenting the lines that you have suggested did also solved the problem. I do also note same as others than music takes much more time to play.

@antonio1475
Copy link

I was wrong about this solving the need to repeat the service twice after a long time of no playing (issue 334) - not sure how long is the threshold.

Does it work for you guys directly after a long time of no playing (hours)? Mine stays in black screen until I trigger the Spotcast service again:

service: spotcast.start
data:
  shuffle: true
  force_playback: true
  device_name: Salón
continue_on_error: true

@robkjr
Copy link

robkjr commented Nov 29, 2022

So I'm finding that this fix works but not for the first time initiated. Example. I have a mini media card setup with 4 Spotify station buttons. The first time I click on a button, it initiates the speakers but fails to play the playlist. Click the button again, and the playlist works fine. From that point, any button/playlist works until the playlist is stopped and the speakers go back to idle/off.

@Johnito
Copy link

Johnito commented Nov 30, 2022

@antonio1475 @robkjr yes, i do observe the very same things on my setup so this seems to be general. You can provoke this behaviour easily to test just by stopping the Google Nest entities (for exemple) and trying to launch the spotcast service again.

@robkjr
Copy link

robkjr commented Nov 30, 2022

@Johnito Exactly. The Google Nest/Cast items must be in the off state to see the behavior.

@robkjr
Copy link

robkjr commented Dec 6, 2022

Does anyone know if we will get an official fix to this issue? Right now, the first-time fail issue has killed the functionality of all my keypads when it comes to staring music.

@Johnito
Copy link

Johnito commented Dec 11, 2022

@robkjr i manually copied the changes implemented from this pull request, and it works just fine now. 100% success whatever may be the initial cast device state.

@max246
Copy link

max246 commented Jan 5, 2023

Looks like the issue is back
https://community.home-assistant.io/t/spotcast-custom-component-to-start-playback-on-an-idle-chromecast-device/114232/918

but also for me:
2023-01-05 14:38:44.547 ERROR (MainThread) [homeassistant.components.automation.new_automation2] [Alarm] Bedroom alarm: Error executing script. Error for call_service at pos 2: Failed to get device id from Spotify

@antonio1475
Copy link

@robkjr i manually copied the changes implemented from this pull request, and it works just fine now. 100% success whatever may be the initial cast device state.

Yup, this seems to be working for me! Although it does generate errors

@fcusson
Copy link
Collaborator

fcusson commented Mar 7, 2023

closing due to new release and no further report

@fcusson fcusson closed this as completed Mar 7, 2023
@wautersj
Copy link

I'm experiencing this behaviour again. A lot like the comments above.

It might have to do with Spotify changing their auth/handshake flow?

@cjborchert
Copy link

@wautersj same thing here, although looks like there's a new ticket: #398

@wautersj
Copy link

wautersj commented Aug 29, 2023

@cjborchert Thanks! Looks like the right thing!

UPDATE:
It seems it has been fixed already at the side of Spotify. My flows all work again!

(I didn't change anything. I tried this morning; no result. Tried again a few minutes ago; and it worked)

Screenshot 2023-08-29 at 11 21 33

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests