Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 11 additions & 9 deletions homeassistant/components/octoprint/config_flow.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
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,
Expand Down Expand Up @@ -143,29 +143,31 @@ async def async_step_zeroconf(
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,
}
Expand Down