Use dataclass properties in hyperion discovery (#60714)
Co-authored-by: epenet <epenet@users.noreply.github.com>pull/60595/head
parent
c7c2b810a7
commit
63ed0af644
|
@ -11,7 +11,6 @@ from hyperion import client, const
|
|||
import voluptuous as vol
|
||||
|
||||
from homeassistant.components import ssdp
|
||||
from homeassistant.components.ssdp import ATTR_SSDP_LOCATION, ATTR_UPNP_SERIAL
|
||||
from homeassistant.config_entries import (
|
||||
SOURCE_REAUTH,
|
||||
ConfigEntry,
|
||||
|
@ -189,9 +188,11 @@ class HyperionConfigFlow(ConfigFlow, domain=DOMAIN):
|
|||
|
||||
# SSDP requires user confirmation.
|
||||
self._require_confirm = True
|
||||
self._data[CONF_HOST] = urlparse(discovery_info[ATTR_SSDP_LOCATION]).hostname
|
||||
self._data[CONF_HOST] = urlparse(discovery_info.ssdp_location).hostname
|
||||
try:
|
||||
self._port_ui = urlparse(discovery_info[ATTR_SSDP_LOCATION]).port
|
||||
self._port_ui = (
|
||||
urlparse(discovery_info.ssdp_location).port or const.DEFAULT_PORT_UI
|
||||
)
|
||||
except ValueError:
|
||||
self._port_ui = const.DEFAULT_PORT_UI
|
||||
|
||||
|
@ -204,7 +205,7 @@ class HyperionConfigFlow(ConfigFlow, domain=DOMAIN):
|
|||
except ValueError:
|
||||
self._data[CONF_PORT] = const.DEFAULT_PORT_JSON
|
||||
|
||||
if not (hyperion_id := discovery_info.get(ATTR_UPNP_SERIAL)):
|
||||
if not (hyperion_id := discovery_info.get(ssdp.ATTR_UPNP_SERIAL)):
|
||||
return self.async_abort(reason="no_id")
|
||||
|
||||
# For discovery mechanisms, we set the unique_id as early as possible to
|
||||
|
|
Loading…
Reference in New Issue