Add DeviceInfo.connections for cross-integration HA card merge#215
Draft
trudenboy wants to merge 1 commit into
Draft
Add DeviceInfo.connections for cross-integration HA card merge#215trudenboy wants to merge 1 commit into
trudenboy wants to merge 1 commit into
Conversation
This was referenced Apr 30, 2026
Mirrors HA's open-ended device_registry connections shape (a set of (connection_type, value) tuples) on MA's player DeviceInfo so the HA integration can forward the set verbatim and HA's device_registry can dedupe cards across integrations that know the same hardware. Existing identifiers dict[IdentifierType, str] keeps serving MA-internal cross-protocol matching (universal_player MAC > UUID > fallback ranking). The new field has different audience (HA forwarding) and stays open-ended on purpose so future transports (zigbee, matter, thread, custom) work without taxonomy changes. Companion PRs in aiosendspin (protocol field), music-assistant/server (Sendspin provider passthrough), and home-assistant/core (MA integration forwarding).
0f3fa91 to
3708d99
Compare
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.
DeviceInfo: add open-endedconnectionsset for cross-integration HA device-card mergeSummary
Adds a new optional
connections: set[tuple[str, str]]field tomusic_assistant_models.player.DeviceInfo, mirroring Home Assistant'shomeassistant.helpers.device_registry.DeviceInfo.connectionsshape, plusa small
add_connection()helper that normalizes MAC-shaped values toHA's canonical lowercase-with-colons form.
This is the data-model side of a coordinated change across four repos
(see Coordination below). The downstream
music-assistant/serverPRpopulates the field from
aiosendspinclient_hello.device_info.connections,and the
home-assistant/corePR forwards the set verbatim into HA'sDeviceInfo.connectionsso HA's device-registry can dedupe device cardsacross integrations that know the same hardware.
Motivation
Today every player provider that knows hardware identity (WiiM,
hass_players, AirPlay-via-Sendspin, BT-via-Sendspin, future
Zigbee/Thread/Matter bridges) sets
IdentifierType.MAC_ADDRESS/IdentifierType.IP_ADDRESSon its player'sDeviceInfo.identifiers—but none of that propagates into HA's
device_info.connections.The MA HA integration constructs
DeviceInfowith onlyidentifiers,manufacturer,model,name,configuration_url(seehomeassistant/components/music_assistant/entity.py).Result: every MA
media_player.<name>lands in HA's device-registrywith
connections=[]. When another HA integration (e.g. the officialbluetoothintegration, or a vendor-specific custom_component) createsits own card for the same physical device, HA can't merge them
because there's no common connection tuple. Operators see two device
cards per speaker.
This is not Sendspin-specific — it affects every MA player provider
that has hardware identity but no path to surface it to HA. Fixing the
data model (this PR) + MA HA integration (separate PR) unblocks
identity-passthrough for the whole org.
Design
identifiers: dict[IdentifierType, str]— the existing field — keepsserving MA-internal cross-protocol matching (universal_player ranks
MAC_ADDRESS>UUID> fallback). Closed enum is intentional there —the matcher reasons about each type's reliability ranking.
connections: set[tuple[str, str]]— the new field — is open-endedon purpose. HA's device_registry accepts any string as
connection_type; standard values are"mac","bluetooth","zigbee","upnp"but new transports (Matter device-id, Thread MLE,custom protocols) should work without taxonomy changes here.
The two fields have different lifecycles and different audiences (MA
internals vs. HA forwarding) so they live side by side rather than
overloading one.
API
Tests
tests/test_player_device_info.pycovers:separator / already-canonical) under both
macandbluetoothtypes,zigbee,matter, custom),mactype stored verbatim (no false coercion),to_dict/from_dictround-trip preserves the set,identifiers(no leakage between fields).11 new tests, 100% pass. Coverage of
player.pyimproved(see
.local-ci-output.txt).Backwards compatibility
default_factory=set— existingDeviceInfo()constructions work unchanged.to_dict/from_dictround-trip preserves the set; old serializedpayloads without
connectionsdeserialize toset()(default).identifiers,add_identifier,mac_address, or anyexisting API surface.
conventionally HA-aligned but the model itself stays HA-agnostic.
Coordination
This PR is one of four in a coordinated change. Land order:
music-assistant/models).Sendspin/aiosendspin#226— protocol-level
DeviceInfo.connectionsfield.music-assistant/server#3813— Sendspin provider passthrough + opportunistic
IdentifierType.MAC_ADDRESSmirror formac/bluetoothtuples.home-assistant/core#169541— MA integration forwards
player.device_info.connectionsinto HADeviceInfo.connections.Umbrella discussion with full design context, status, and cross-links:
https://github.com/orgs/music-assistant/discussions/5415
PR-D and PR-A both depend on this PR landing & a
music_assistant_modelsrelease.
Test plan locally
Output captured in
.local-ci-output.txtnext to this description.