Use ZeroconfServiceInfo in system_bridge (#60102)
parent
a72a5486c2
commit
fa9465d003
|
@ -151,8 +151,9 @@ class ConfigFlow(config_entries.ConfigFlow, domain=DOMAIN):
|
|||
self, discovery_info: zeroconf.ZeroconfServiceInfo
|
||||
) -> FlowResult:
|
||||
"""Handle zeroconf discovery."""
|
||||
host = discovery_info["properties"].get("ip")
|
||||
uuid = discovery_info["properties"].get("uuid")
|
||||
properties = discovery_info[zeroconf.ATTR_PROPERTIES]
|
||||
host = properties.get("ip")
|
||||
uuid = properties.get("uuid")
|
||||
|
||||
if host is None or uuid is None:
|
||||
return self.async_abort(reason="unknown")
|
||||
|
@ -164,7 +165,7 @@ class ConfigFlow(config_entries.ConfigFlow, domain=DOMAIN):
|
|||
self._name = host
|
||||
self._input = {
|
||||
CONF_HOST: host,
|
||||
CONF_PORT: discovery_info["properties"].get("port"),
|
||||
CONF_PORT: properties.get("port"),
|
||||
}
|
||||
|
||||
return await self.async_step_authenticate()
|
||||
|
|
|
@ -5,6 +5,7 @@ from aiohttp.client_exceptions import ClientConnectionError
|
|||
from systembridge.exceptions import BridgeAuthenticationException
|
||||
|
||||
from homeassistant import config_entries, data_entry_flow
|
||||
from homeassistant.components import zeroconf
|
||||
from homeassistant.components.system_bridge.const import DOMAIN
|
||||
from homeassistant.const import CONF_API_KEY, CONF_HOST, CONF_PORT
|
||||
|
||||
|
@ -27,13 +28,13 @@ FIXTURE_ZEROCONF_INPUT = {
|
|||
CONF_PORT: "9170",
|
||||
}
|
||||
|
||||
FIXTURE_ZEROCONF = {
|
||||
CONF_HOST: "1.1.1.1",
|
||||
CONF_PORT: 9170,
|
||||
"hostname": "test-bridge.local.",
|
||||
"type": "_system-bridge._udp.local.",
|
||||
"name": "System Bridge - test-bridge._system-bridge._udp.local.",
|
||||
"properties": {
|
||||
FIXTURE_ZEROCONF = zeroconf.ZeroconfServiceInfo(
|
||||
host="1.1.1.1",
|
||||
port=9170,
|
||||
hostname="test-bridge.local.",
|
||||
type="_system-bridge._udp.local.",
|
||||
name="System Bridge - test-bridge._system-bridge._udp.local.",
|
||||
properties={
|
||||
"address": "http://test-bridge:9170",
|
||||
"fqdn": "test-bridge",
|
||||
"host": "test-bridge",
|
||||
|
@ -42,18 +43,18 @@ FIXTURE_ZEROCONF = {
|
|||
"port": "9170",
|
||||
"uuid": FIXTURE_UUID,
|
||||
},
|
||||
}
|
||||
)
|
||||
|
||||
FIXTURE_ZEROCONF_BAD = {
|
||||
CONF_HOST: "1.1.1.1",
|
||||
CONF_PORT: 9170,
|
||||
"hostname": "test-bridge.local.",
|
||||
"type": "_system-bridge._udp.local.",
|
||||
"name": "System Bridge - test-bridge._system-bridge._udp.local.",
|
||||
"properties": {
|
||||
FIXTURE_ZEROCONF_BAD = zeroconf.ZeroconfServiceInfo(
|
||||
host="1.1.1.1",
|
||||
port=9170,
|
||||
hostname="test-bridge.local.",
|
||||
type="_system-bridge._udp.local.",
|
||||
name="System Bridge - test-bridge._system-bridge._udp.local.",
|
||||
properties={
|
||||
"something": "bad",
|
||||
},
|
||||
}
|
||||
)
|
||||
|
||||
|
||||
FIXTURE_INFORMATION = {
|
||||
|
|
Loading…
Reference in New Issue