Use dataclass properties in denonavr discovery (#60691)
Co-authored-by: epenet <epenet@users.noreply.github.com>pull/60595/head
parent
6544b440d2
commit
16942fc8e9
|
@ -211,7 +211,7 @@ class DenonAvrFlowHandler(config_entries.ConfigFlow, domain=DOMAIN):
|
|||
},
|
||||
)
|
||||
|
||||
async def async_step_ssdp(self, discovery_info: dict[str, Any]) -> FlowResult:
|
||||
async def async_step_ssdp(self, discovery_info: ssdp.SsdpServiceInfo) -> FlowResult:
|
||||
"""Handle a discovered Denon AVR.
|
||||
|
||||
This flow is triggered by the SSDP component. It will check if the
|
||||
|
@ -219,21 +219,23 @@ class DenonAvrFlowHandler(config_entries.ConfigFlow, domain=DOMAIN):
|
|||
"""
|
||||
# Filter out non-Denon AVRs#1
|
||||
if (
|
||||
discovery_info.get(ssdp.ATTR_UPNP_MANUFACTURER)
|
||||
discovery_info.upnp.get(ssdp.ATTR_UPNP_MANUFACTURER)
|
||||
not in SUPPORTED_MANUFACTURERS
|
||||
):
|
||||
return self.async_abort(reason="not_denonavr_manufacturer")
|
||||
|
||||
# Check if required information is present to set the unique_id
|
||||
if (
|
||||
ssdp.ATTR_UPNP_MODEL_NAME not in discovery_info
|
||||
or ssdp.ATTR_UPNP_SERIAL not in discovery_info
|
||||
ssdp.ATTR_UPNP_MODEL_NAME not in discovery_info.upnp
|
||||
or ssdp.ATTR_UPNP_SERIAL not in discovery_info.upnp
|
||||
):
|
||||
return self.async_abort(reason="not_denonavr_missing")
|
||||
|
||||
self.model_name = discovery_info[ssdp.ATTR_UPNP_MODEL_NAME].replace("*", "")
|
||||
self.serial_number = discovery_info[ssdp.ATTR_UPNP_SERIAL]
|
||||
self.host = urlparse(discovery_info[ssdp.ATTR_SSDP_LOCATION]).hostname
|
||||
self.model_name = discovery_info.upnp[ssdp.ATTR_UPNP_MODEL_NAME].replace(
|
||||
"*", ""
|
||||
)
|
||||
self.serial_number = discovery_info.upnp[ssdp.ATTR_UPNP_SERIAL]
|
||||
self.host = urlparse(discovery_info.ssdp_location).hostname
|
||||
|
||||
if self.model_name in IGNORED_MODELS:
|
||||
return self.async_abort(reason="not_denonavr_manufacturer")
|
||||
|
@ -245,7 +247,9 @@ class DenonAvrFlowHandler(config_entries.ConfigFlow, domain=DOMAIN):
|
|||
self.context.update(
|
||||
{
|
||||
"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…
Reference in New Issue