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
8 changes: 5 additions & 3 deletions homeassistant/components/guardian/config_flow.py
Original file line number Diff line number Diff line change
Expand Up @@ -112,10 +112,12 @@ async def async_step_zeroconf(
) -> FlowResult:
"""Handle the configuration via zeroconf."""
self.discovery_info = {
CONF_IP_ADDRESS: discovery_info["host"],
CONF_PORT: discovery_info["port"],
CONF_IP_ADDRESS: discovery_info[zeroconf.ATTR_HOST],
CONF_PORT: discovery_info[zeroconf.ATTR_PORT],
}
pin = async_get_pin_from_discovery_hostname(discovery_info["hostname"])
pin = async_get_pin_from_discovery_hostname(
discovery_info[zeroconf.ATTR_HOSTNAME]
)
await self._async_set_unique_id(pin)
return await self._async_handle_discovery()

Expand Down
33 changes: 17 additions & 16 deletions tests/components/guardian/test_config_flow.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
from aioguardian.errors import GuardianError

from homeassistant import data_entry_flow
from homeassistant.components import zeroconf
from homeassistant.components.dhcp import HOSTNAME, IP_ADDRESS, MAC_ADDRESS
from homeassistant.components.guardian import CONF_UID, DOMAIN
from homeassistant.components.guardian.config_flow import (
Expand Down Expand Up @@ -83,14 +84,14 @@ async def test_step_user(hass, ping_client):

async def test_step_zeroconf(hass, ping_client):
"""Test the zeroconf step."""
zeroconf_data = {
"host": "192.168.1.100",
"port": 7777,
"hostname": "GVC1-ABCD.local.",
"type": "_api._udp.local.",
"name": "Guardian Valve Controller API._api._udp.local.",
"properties": {"_raw": {}},
}
zeroconf_data = zeroconf.ZeroconfServiceInfo(
host="192.168.1.100",
port=7777,
hostname="GVC1-ABCD.local.",
type="_api._udp.local.",
name="Guardian Valve Controller API._api._udp.local.",
properties={"_raw": {}},
)

result = await hass.config_entries.flow.async_init(
DOMAIN, context={"source": SOURCE_ZEROCONF}, data=zeroconf_data
Expand All @@ -112,14 +113,14 @@ async def test_step_zeroconf(hass, ping_client):

async def test_step_zeroconf_already_in_progress(hass):
"""Test the zeroconf step aborting because it's already in progress."""
zeroconf_data = {
"host": "192.168.1.100",
"port": 7777,
"hostname": "GVC1-ABCD.local.",
"type": "_api._udp.local.",
"name": "Guardian Valve Controller API._api._udp.local.",
"properties": {"_raw": {}},
}
zeroconf_data = zeroconf.ZeroconfServiceInfo(
host="192.168.1.100",
port=7777,
hostname="GVC1-ABCD.local.",
type="_api._udp.local.",
name="Guardian Valve Controller API._api._udp.local.",
properties={"_raw": {}},
)

result = await hass.config_entries.flow.async_init(
DOMAIN, context={"source": SOURCE_ZEROCONF}, data=zeroconf_data
Expand Down