Repository navigation
Refuse a Connect entity of another account and retry transfers on 404 - #77
Merged
Merged
Conversation
A `*_spotcast` media player mirrors a Spotify Connect device as seen by one Spotcast account. The device is signed in to that account only, so a play or transfer from another account gets a 404 from Spotify. Spotcast accepted the entity regardless, waited 12 seconds for the device to show up and gave up with "not available on Spotify Connect", or, on the transfer path, surfaced spotipy's raw "Device not found" (#76). async_build_from_type now checks that the entity belongs to the calling account and raises AccountMismatchError with a message that names both accounts and points at the Google Cast entity, which is the only route that can switch a device between accounts. play_media and play_custom_context report it as a ServiceValidationError. The transfer branch of async_play_media gets the same 404 wait-and-retry as the start branch, since a Chromecast whose Spotify app was just relaunched can still be registering. The timeout message now names the account. The same log showed Home Assistant flagging an invalid entity id built from an account id containing a dot and a dash. _define_entity_id now slugifies the whole identity key. The key itself is unchanged, so unique ids, device identifiers and the legacy migration are untouched and registered entities keep their entity id. Refs #76 Co-Authored-By: Claude Fable 5.1 <[email protected]>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
A
*_spotcastmedia player mirrors a Spotify Connect device as seen by one Spotcast account. The device is signed in to that account only, so a play or transfer from another account gets a 404 from Spotify. Spotcast accepted the entity regardless, waited 12 seconds for the device to appear and gave up with "not available on Spotify Connect", or, on the transfer path, surfaced spotipy's raw "Device not found". That is what the reporter of #76 hit with two accounts and one Chromecast.This PR:
async_build_from_typechecks that theSpotifyDevicebelongs to the calling account and raises the newAccountMismatchError, whose message names both accounts and points at the Google Cast entity (the only route that can switch a device between accounts).play_mediaandplay_custom_contextreport it as aServiceValidationError, like a missing active device.async_play_medianow gets the same wait-and-retry as the start branch, since a Chromecast whose Spotify app was just relaunched can still be registering. The timeout message names the account.media_player.cloudytv_koen.wigman-nl_spotcast)._define_entity_idslugifies the whole identity key. The key itself is unchanged, so unique ids, device identifiers and the legacy migration are untouched and registered entities keep their entity id.play_media/transfer_playbackdocs that a*_spotcastentity only works with its own account.Refs #76 (kept open until the reporter confirms the Google Cast route works for them).
Type of Change
Checklist
Additional Information
test_async_build_from_type.py), theaccountproperty,ServiceValidationErrormapping in both services, transfer 404 retry / timeout / non-404 paths, and entity ids for account ids with.and-.*_spotcastentity to a same-named Google Cast device. The reporter now targets the cast entity directly; a clear error plus docs is the cleaner answer for everyone else.🤖 Generated with Claude Code