Use ZeroconfServiceInfo in guardian (#59741)
Co-authored-by: epenet <epenet@users.noreply.github.com>pull/59743/head
parent
032718abb1
commit
0b43cff377
|
@ -112,10 +112,12 @@ class ConfigFlow(config_entries.ConfigFlow, domain=DOMAIN):
|
|||
) -> 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()
|
||||
|
||||
|
|
|
@ -4,6 +4,7 @@ from unittest.mock import patch
|
|||
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 (
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
|
|
Loading…
Reference in New Issue