Add UPNP device connection for Sonos (#56702)

This commit is contained in:
Michael Chisholm 2021-09-28 01:36:47 +10:00 committed by GitHub
parent 70cc6295b5
commit 805e73f78c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 10 additions and 2 deletions

View File

@ -95,7 +95,10 @@ class SonosEntity(Entity):
"name": self.speaker.zone_name,
"model": self.speaker.model_name.replace("Sonos ", ""),
"sw_version": self.speaker.version,
"connections": {(dr.CONNECTION_NETWORK_MAC, self.speaker.mac_address)},
"connections": {
(dr.CONNECTION_NETWORK_MAC, self.speaker.mac_address),
(dr.CONNECTION_UPNP, f"uuid:{self.speaker.uid}"),
},
"manufacturer": "Sonos",
"suggested_area": self.speaker.zone_name,
}

View File

@ -177,6 +177,7 @@ class SonosSpeaker:
# Device information
self.mac_address = speaker_info["mac_address"]
self.model_name = speaker_info["model_name"]
self.uid = speaker_info["uid"]
self.version = speaker_info["display_version"]
self.zone_name = speaker_info["zone_name"]

View File

@ -160,6 +160,7 @@ def speaker_info_fixture():
"""Create speaker_info fixture."""
return {
"zone_name": "Zone A",
"uid": "RINCON_test",
"model_name": "Model Name",
"software_version": "49.2-64250",
"mac_address": "00-11-22-33-44-55",

View File

@ -77,7 +77,10 @@ async def test_device_registry(hass, config_entry, config, soco):
)
assert reg_device.model == "Model Name"
assert reg_device.sw_version == "13.1"
assert reg_device.connections == {(dr.CONNECTION_NETWORK_MAC, "00:11:22:33:44:55")}
assert reg_device.connections == {
(dr.CONNECTION_NETWORK_MAC, "00:11:22:33:44:55"),
(dr.CONNECTION_UPNP, "uuid:RINCON_test"),
}
assert reg_device.manufacturer == "Sonos"
assert reg_device.suggested_area == "Zone A"
assert reg_device.name == "Zone A"