mirror of
https://github.com/home-assistant/core.git
synced 2025-07-23 13:17:32 +00:00
Avoid useless data conversion in sonos config flow (#136294)
We would convert the zeroconf data to a dict and pass it to async_step_discovery which does nothing with it
This commit is contained in:
parent
ce792f6fe9
commit
7afd1f8cf8
@ -1,7 +1,6 @@
|
|||||||
"""Config flow for SONOS."""
|
"""Config flow for SONOS."""
|
||||||
|
|
||||||
from collections.abc import Awaitable
|
from collections.abc import Awaitable
|
||||||
import dataclasses
|
|
||||||
|
|
||||||
from homeassistant.components import ssdp
|
from homeassistant.components import ssdp
|
||||||
from homeassistant.config_entries import ConfigFlowResult
|
from homeassistant.config_entries import ConfigFlowResult
|
||||||
@ -32,15 +31,15 @@ class SonosDiscoveryFlowHandler(DiscoveryFlowHandler[Awaitable[bool]], domain=DO
|
|||||||
hostname = discovery_info.hostname
|
hostname = discovery_info.hostname
|
||||||
if hostname is None or not hostname.lower().startswith("sonos"):
|
if hostname is None or not hostname.lower().startswith("sonos"):
|
||||||
return self.async_abort(reason="not_sonos_device")
|
return self.async_abort(reason="not_sonos_device")
|
||||||
await self.async_set_unique_id(self._domain, raise_on_progress=False)
|
|
||||||
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)
|
|
||||||
if discovery_manager := self.hass.data.get(DATA_SONOS_DISCOVERY_MANAGER):
|
if discovery_manager := self.hass.data.get(DATA_SONOS_DISCOVERY_MANAGER):
|
||||||
|
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)
|
||||||
discovery_manager.async_discovered_player(
|
discovery_manager.async_discovered_player(
|
||||||
"Zeroconf", properties, host, uid, boot_seqnum, model, mdns_name
|
"Zeroconf", properties, host, uid, boot_seqnum, model, mdns_name
|
||||||
)
|
)
|
||||||
return await self.async_step_discovery(dataclasses.asdict(discovery_info))
|
await self.async_set_unique_id(self._domain, raise_on_progress=False)
|
||||||
|
return await self.async_step_discovery({})
|
||||||
|
Loading…
x
Reference in New Issue
Block a user