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