Fix OctoPrint SSDP URL parsing and discovered values (#58698)

This commit is contained in:
Franck Nijhof 2021-10-29 16:34:27 +02:00 committed by GitHub
parent 520a36aa51
commit 4b64b92dba
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -1,9 +1,9 @@
"""Config flow for OctoPrint integration."""
import logging
from urllib.parse import urlsplit
from pyoctoprintapi import ApiError, OctoprintClient, OctoprintException
import voluptuous as vol
from yarl import URL
from homeassistant import config_entries, data_entry_flow, exceptions
from homeassistant.const import (
@ -162,14 +162,16 @@ class ConfigFlow(config_entries.ConfigFlow, domain=DOMAIN):
await self.async_set_unique_id(uuid)
self._abort_if_unique_id_configured()
url = urlsplit(discovery_info["presentationURL"])
url = URL(discovery_info["presentationURL"])
self.context["title_placeholders"] = {
CONF_HOST: url.hostname,
CONF_HOST: url.host,
}
self.discovery_schema = _schema_with_defaults(
host=url.hostname,
host=url.host,
path=url.path,
port=url.port,
ssl=url.scheme == "https",
)
return await self.async_step_user()