mirror of
https://github.com/home-assistant/core.git
synced 2025-07-21 12:17:07 +00:00
Use dataclass properties in sonos discovery (#60633)
Co-authored-by: epenet <epenet@users.noreply.github.com>
This commit is contained in:
parent
be89c07cac
commit
f444dd6d86
@ -1,5 +1,5 @@
|
||||
"""Config flow for SONOS."""
|
||||
from typing import cast
|
||||
import dataclasses
|
||||
|
||||
import soco
|
||||
|
||||
@ -30,13 +30,13 @@ class SonosDiscoveryFlowHandler(DiscoveryFlowHandler):
|
||||
self, discovery_info: zeroconf.ZeroconfServiceInfo
|
||||
) -> FlowResult:
|
||||
"""Handle a flow initialized by zeroconf."""
|
||||
hostname = discovery_info[zeroconf.ATTR_HOSTNAME]
|
||||
hostname = discovery_info.hostname
|
||||
if hostname is None or not hostname.lower().startswith("sonos"):
|
||||
return self.async_abort(reason="not_sonos_device")
|
||||
await self.async_set_unique_id(self._domain, raise_on_progress=False)
|
||||
host = discovery_info[zeroconf.ATTR_HOST]
|
||||
mdns_name = discovery_info[zeroconf.ATTR_NAME]
|
||||
properties = discovery_info[zeroconf.ATTR_PROPERTIES]
|
||||
host = discovery_info.host
|
||||
mdns_name = discovery_info.name
|
||||
properties = discovery_info.properties
|
||||
boot_seqnum = properties.get("bootseq")
|
||||
model = properties.get("model")
|
||||
uid = hostname_to_uid(hostname)
|
||||
@ -44,7 +44,7 @@ class SonosDiscoveryFlowHandler(DiscoveryFlowHandler):
|
||||
discovery_manager.async_discovered_player(
|
||||
"Zeroconf", properties, host, uid, boot_seqnum, model, mdns_name
|
||||
)
|
||||
return await self.async_step_discovery(cast(dict, discovery_info))
|
||||
return await self.async_step_discovery(dataclasses.asdict(discovery_info))
|
||||
|
||||
|
||||
config_entries.HANDLERS.register(DOMAIN)(SonosDiscoveryFlowHandler)
|
||||
|
Loading…
x
Reference in New Issue
Block a user