/
/
/
# What does this implement/fix? A Universal Player — the player Music Assistant creates for a device that has no native provider — took its player id from whichever device identifiers happened to be available at the moment it was created. Re-creating one could therefore give the same speaker a different id, for example switching from a MAC-based to a UUID-based one. Anything bound to that id then sees the player disappear and a brand new one show up: in Home Assistant the old entity is orphaned and automations referencing it stop working. A related problem made the replacement carry a stale automatically generated name, which showed up as a duplicated friendly name. The id is now handed out once and never derived from the device again. ## Changes - A Universal Player gets a random id the first time its device is wrapped, and that id is never recomputed - A device's Universal Player is found through the link its protocol players store, and is restored from its configuration when it is not loaded yet — previously this case quietly created a second player - Nothing looks a Universal Player up by rebuilding its id from the device any more - A Universal Player keeps its settings when its protocol players disappear: it goes unavailable instead of being deleted, so the device returns as the same player. Only removing it yourself deletes it for good - When two Universal Players for the same device merge, the one that has been around longest now wins, so the established player id is the one that survives - A player no longer stores its automatically generated name as if you had renamed it, so a renamed device is no longer shadowed by its old name. Existing players are migrated Existing Universal Players keep the id they already have — nothing is renumbered. **Related issue:** https://github.com/music-assistant/support/issues/5888 <sub>Note for reviewers: the trigger in the report (changing the output protocol) could not be reproduced as a cause on either `dev` or 2.9.9 — that setting never tears a player down. The destructive path that did exist in 2.9.9 was on the startup restore and is already fixed on `dev` by #4643. What remains genuinely unstable is the derived id itself, which this PR removes. One case stays open by design: if a protocol player is permanently removed and its config deleted, a returning device has no stored link left and gets a new id.</sub> ## Types of changes <!-- Tick exactly one box. CI (.github/workflows/pr-labels.yaml) derives the label from the ticked box and applies it automatically; the release-notes generator uses that same label to slot this change into the next release notes. --> - [X] Bugfix (non-breaking change which fixes an issue) — `bugfix` - [ ] New feature (non-breaking change which adds functionality) — `new-feature` - [ ] Enhancement to an existing feature — `enhancement` - [ ] New music/player/metadata/plugin provider — `new-provider` - [ ] Breaking change (fix or feature that would cause existing functionality to not work as expected) — `breaking-change` - [ ] Refactor (no behaviour change) — `refactor` - [ ] Documentation only — `documentation` - [ ] Maintenance / chore — `maintenance` - [ ] CI / workflow change — `ci` - [ ] Dependencies bump — `dependencies` ## Checklist - [X] The code change is tested and works locally. - [X] `pre-commit run --all-files` passes. - [X] `pytest` passes, and tests have been added/updated under `tests/` where applicable. - [ ] For changes to shared models, the companion PR in `music-assistant/models` is linked. - [ ] For changes affecting the UI, the companion PR in `music-assistant/frontend` is linked. - [X] I have read and complied with the project's [AI Policy](https://github.com/music-assistant/.github/blob/main/AI_POLICY.md) for any AI-assisted contributions. - [ ] I have [raised a PR against the documentation repository](https://github.com/music-assistant/music-assistant.io/blob/main/CONTRIBUTING.md) targeting the main or beta branch as appropriate. --------- Co-authored-by: Claude <[email protected]> Co-authored-by: Marcel van der Veldt <[email protected]>