mirror of
https://github.com/home-assistant/core.git
synced 2025-07-16 09:47:13 +00:00
Use dataclass properties in octoprint discovery (#60579)
Co-authored-by: epenet <epenet@users.noreply.github.com>
This commit is contained in:
parent
b4f3e08b84
commit
e0b315041b
@ -6,7 +6,7 @@ import voluptuous as vol
|
||||
from yarl import URL
|
||||
|
||||
from homeassistant import config_entries, data_entry_flow, exceptions
|
||||
from homeassistant.components import zeroconf
|
||||
from homeassistant.components import ssdp, zeroconf
|
||||
from homeassistant.const import (
|
||||
CONF_API_KEY,
|
||||
CONF_HOST,
|
||||
@ -143,29 +143,31 @@ class ConfigFlow(config_entries.ConfigFlow, domain=DOMAIN):
|
||||
self, discovery_info: zeroconf.ZeroconfServiceInfo
|
||||
) -> data_entry_flow.FlowResult:
|
||||
"""Handle discovery flow."""
|
||||
uuid = discovery_info[zeroconf.ATTR_PROPERTIES]["uuid"]
|
||||
uuid = discovery_info.properties["uuid"]
|
||||
await self.async_set_unique_id(uuid)
|
||||
self._abort_if_unique_id_configured()
|
||||
|
||||
self.context["title_placeholders"] = {
|
||||
CONF_HOST: discovery_info[zeroconf.ATTR_HOST],
|
||||
CONF_HOST: discovery_info.host,
|
||||
}
|
||||
|
||||
self.discovery_schema = _schema_with_defaults(
|
||||
host=discovery_info[zeroconf.ATTR_HOST],
|
||||
port=discovery_info[zeroconf.ATTR_PORT],
|
||||
path=discovery_info[zeroconf.ATTR_PROPERTIES][CONF_PATH],
|
||||
host=discovery_info.host,
|
||||
port=discovery_info.port,
|
||||
path=discovery_info.properties[CONF_PATH],
|
||||
)
|
||||
|
||||
return await self.async_step_user()
|
||||
|
||||
async def async_step_ssdp(self, discovery_info):
|
||||
async def async_step_ssdp(
|
||||
self, discovery_info: ssdp.SsdpServiceInfo
|
||||
) -> data_entry_flow.FlowResult:
|
||||
"""Handle ssdp discovery flow."""
|
||||
uuid = discovery_info["UDN"][5:]
|
||||
uuid = discovery_info.upnp["UDN"][5:]
|
||||
await self.async_set_unique_id(uuid)
|
||||
self._abort_if_unique_id_configured()
|
||||
|
||||
url = URL(discovery_info["presentationURL"])
|
||||
url = URL(discovery_info.upnp["presentationURL"])
|
||||
self.context["title_placeholders"] = {
|
||||
CONF_HOST: url.host,
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user