mirror of
https://github.com/home-assistant/core.git
synced 2025-07-26 22:57:17 +00:00
Use dataclass properties in hyperion discovery (#60714)
Co-authored-by: epenet <epenet@users.noreply.github.com>
This commit is contained in:
parent
c7c2b810a7
commit
63ed0af644
@ -11,7 +11,6 @@ from hyperion import client, const
|
|||||||
import voluptuous as vol
|
import voluptuous as vol
|
||||||
|
|
||||||
from homeassistant.components import ssdp
|
from homeassistant.components import ssdp
|
||||||
from homeassistant.components.ssdp import ATTR_SSDP_LOCATION, ATTR_UPNP_SERIAL
|
|
||||||
from homeassistant.config_entries import (
|
from homeassistant.config_entries import (
|
||||||
SOURCE_REAUTH,
|
SOURCE_REAUTH,
|
||||||
ConfigEntry,
|
ConfigEntry,
|
||||||
@ -189,9 +188,11 @@ class HyperionConfigFlow(ConfigFlow, domain=DOMAIN):
|
|||||||
|
|
||||||
# SSDP requires user confirmation.
|
# SSDP requires user confirmation.
|
||||||
self._require_confirm = True
|
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:
|
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:
|
except ValueError:
|
||||||
self._port_ui = const.DEFAULT_PORT_UI
|
self._port_ui = const.DEFAULT_PORT_UI
|
||||||
|
|
||||||
@ -204,7 +205,7 @@ class HyperionConfigFlow(ConfigFlow, domain=DOMAIN):
|
|||||||
except ValueError:
|
except ValueError:
|
||||||
self._data[CONF_PORT] = const.DEFAULT_PORT_JSON
|
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")
|
return self.async_abort(reason="no_id")
|
||||||
|
|
||||||
# For discovery mechanisms, we set the unique_id as early as possible to
|
# For discovery mechanisms, we set the unique_id as early as possible to
|
||||||
|
Loading…
x
Reference in New Issue
Block a user