mirror of
https://github.com/home-assistant/core.git
synced 2025-04-24 01:08:12 +00:00
Use zeroconf attributes in elgato (#58958)
Co-authored-by: epenet <epenet@users.noreply.github.com>
This commit is contained in:
parent
0040606c65
commit
ce9385d442
@ -46,8 +46,8 @@ class ElgatoFlowHandler(ConfigFlow, domain=DOMAIN):
|
||||
self, discovery_info: zeroconf.ZeroconfServiceInfo
|
||||
) -> FlowResult:
|
||||
"""Handle zeroconf discovery."""
|
||||
self.host = discovery_info[CONF_HOST]
|
||||
self.port = discovery_info[CONF_PORT] or 9123
|
||||
self.host = discovery_info[zeroconf.ATTR_HOST]
|
||||
self.port = discovery_info[zeroconf.ATTR_PORT] or 9123
|
||||
|
||||
try:
|
||||
await self._get_elgato_serial_number()
|
||||
|
@ -2,6 +2,7 @@
|
||||
import aiohttp
|
||||
|
||||
from homeassistant import data_entry_flow
|
||||
from homeassistant.components import zeroconf
|
||||
from homeassistant.components.elgato.const import CONF_SERIAL_NUMBER, DOMAIN
|
||||
from homeassistant.config_entries import SOURCE_USER, SOURCE_ZEROCONF
|
||||
from homeassistant.const import CONF_HOST, CONF_PORT, CONF_SOURCE, CONTENT_TYPE_JSON
|
||||
@ -27,12 +28,12 @@ async def test_full_user_flow_implementation(
|
||||
await hass.config_entries.flow.async_init(
|
||||
DOMAIN,
|
||||
context={CONF_SOURCE: SOURCE_ZEROCONF},
|
||||
data={
|
||||
"host": "127.0.0.1",
|
||||
"hostname": "example.local.",
|
||||
"port": 9123,
|
||||
"properties": {},
|
||||
},
|
||||
data=zeroconf.ZeroconfServiceInfo(
|
||||
host="127.0.0.1",
|
||||
hostname="example.local.",
|
||||
port=9123,
|
||||
properties={},
|
||||
),
|
||||
)
|
||||
|
||||
result = await hass.config_entries.flow.async_init(
|
||||
@ -70,12 +71,12 @@ async def test_full_zeroconf_flow_implementation(
|
||||
result = await hass.config_entries.flow.async_init(
|
||||
DOMAIN,
|
||||
context={CONF_SOURCE: SOURCE_ZEROCONF},
|
||||
data={
|
||||
"host": "127.0.0.1",
|
||||
"hostname": "example.local.",
|
||||
"port": 9123,
|
||||
"properties": {},
|
||||
},
|
||||
data=zeroconf.ZeroconfServiceInfo(
|
||||
host="127.0.0.1",
|
||||
hostname="example.local.",
|
||||
port=9123,
|
||||
properties={},
|
||||
),
|
||||
)
|
||||
|
||||
assert result["description_placeholders"] == {CONF_SERIAL_NUMBER: "CN11A1A00001"}
|
||||
@ -127,7 +128,7 @@ async def test_zeroconf_connection_error(
|
||||
result = await hass.config_entries.flow.async_init(
|
||||
DOMAIN,
|
||||
context={"source": SOURCE_ZEROCONF},
|
||||
data={"host": "127.0.0.1", "port": 9123},
|
||||
data=zeroconf.ZeroconfServiceInfo(host="127.0.0.1", port=9123),
|
||||
)
|
||||
|
||||
assert result["reason"] == "cannot_connect"
|
||||
@ -158,7 +159,7 @@ async def test_zeroconf_device_exists_abort(
|
||||
result = await hass.config_entries.flow.async_init(
|
||||
DOMAIN,
|
||||
context={CONF_SOURCE: SOURCE_ZEROCONF},
|
||||
data={"host": "127.0.0.1", "port": 9123},
|
||||
data=zeroconf.ZeroconfServiceInfo(host="127.0.0.1", port=9123),
|
||||
)
|
||||
|
||||
assert result["reason"] == "already_configured"
|
||||
@ -167,7 +168,7 @@ async def test_zeroconf_device_exists_abort(
|
||||
result = await hass.config_entries.flow.async_init(
|
||||
DOMAIN,
|
||||
context={CONF_SOURCE: SOURCE_ZEROCONF},
|
||||
data={"host": "127.0.0.2", "port": 9123},
|
||||
data=zeroconf.ZeroconfServiceInfo(host="127.0.0.2", port=9123),
|
||||
)
|
||||
|
||||
assert result["reason"] == "already_configured"
|
||||
|
Loading…
x
Reference in New Issue
Block a user