mirror of
https://github.com/home-assistant/core.git
synced 2025-07-22 20:57:21 +00:00
Use dataclass properties in yamaha_musiccast discovery (#60749)
Co-authored-by: epenet <epenet@users.noreply.github.com>
This commit is contained in:
parent
68011ee952
commit
824b313705
@ -82,16 +82,18 @@ class MusicCastFlowHandler(ConfigFlow, domain=DOMAIN):
|
|||||||
errors=errors or {},
|
errors=errors or {},
|
||||||
)
|
)
|
||||||
|
|
||||||
async def async_step_ssdp(self, discovery_info) -> data_entry_flow.FlowResult:
|
async def async_step_ssdp(
|
||||||
|
self, discovery_info: ssdp.SsdpServiceInfo
|
||||||
|
) -> data_entry_flow.FlowResult:
|
||||||
"""Handle ssdp discoveries."""
|
"""Handle ssdp discoveries."""
|
||||||
if not await MusicCastDevice.check_yamaha_ssdp(
|
if not await MusicCastDevice.check_yamaha_ssdp(
|
||||||
discovery_info[ssdp.ATTR_SSDP_LOCATION], async_get_clientsession(self.hass)
|
discovery_info.ssdp_location, async_get_clientsession(self.hass)
|
||||||
):
|
):
|
||||||
return self.async_abort(reason="yxc_control_url_missing")
|
return self.async_abort(reason="yxc_control_url_missing")
|
||||||
|
|
||||||
self.serial_number = discovery_info[ssdp.ATTR_UPNP_SERIAL]
|
self.serial_number = discovery_info.upnp[ssdp.ATTR_UPNP_SERIAL]
|
||||||
self.host = urlparse(discovery_info[ssdp.ATTR_SSDP_LOCATION]).hostname
|
self.host = urlparse(discovery_info.ssdp_location or "").hostname or ""
|
||||||
self.upnp_description = discovery_info[ssdp.ATTR_SSDP_LOCATION]
|
self.upnp_description = discovery_info.ssdp_location
|
||||||
await self.async_set_unique_id(self.serial_number)
|
await self.async_set_unique_id(self.serial_number)
|
||||||
self._abort_if_unique_id_configured(
|
self._abort_if_unique_id_configured(
|
||||||
{
|
{
|
||||||
@ -102,7 +104,9 @@ class MusicCastFlowHandler(ConfigFlow, domain=DOMAIN):
|
|||||||
self.context.update(
|
self.context.update(
|
||||||
{
|
{
|
||||||
"title_placeholders": {
|
"title_placeholders": {
|
||||||
"name": discovery_info.get(ssdp.ATTR_UPNP_FRIENDLY_NAME, self.host)
|
"name": discovery_info.upnp.get(
|
||||||
|
ssdp.ATTR_UPNP_FRIENDLY_NAME, self.host
|
||||||
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user