Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions homeassistant/components/elgato/config_flow.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,8 @@ async def async_step_zeroconf(
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()
Expand Down
31 changes: 16 additions & 15 deletions tests/components/elgato/test_config_flow.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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(
Expand Down Expand Up @@ -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"}
Expand Down Expand Up @@ -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"
Expand Down Expand Up @@ -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"
Expand All @@ -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"
Expand Down