mirror of
https://github.com/home-assistant/core.git
synced 2025-07-14 16:57:10 +00:00
Use ZeroconfServiceInfo in guardian (#59741)
Co-authored-by: epenet <epenet@users.noreply.github.com>
This commit is contained in:
parent
032718abb1
commit
0b43cff377
@ -112,10 +112,12 @@ class ConfigFlow(config_entries.ConfigFlow, domain=DOMAIN):
|
|||||||
) -> FlowResult:
|
) -> FlowResult:
|
||||||
"""Handle the configuration via zeroconf."""
|
"""Handle the configuration via zeroconf."""
|
||||||
self.discovery_info = {
|
self.discovery_info = {
|
||||||
CONF_IP_ADDRESS: discovery_info["host"],
|
CONF_IP_ADDRESS: discovery_info[zeroconf.ATTR_HOST],
|
||||||
CONF_PORT: discovery_info["port"],
|
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)
|
await self._async_set_unique_id(pin)
|
||||||
return await self._async_handle_discovery()
|
return await self._async_handle_discovery()
|
||||||
|
|
||||||
|
@ -4,6 +4,7 @@ from unittest.mock import patch
|
|||||||
from aioguardian.errors import GuardianError
|
from aioguardian.errors import GuardianError
|
||||||
|
|
||||||
from homeassistant import data_entry_flow
|
from homeassistant import data_entry_flow
|
||||||
|
from homeassistant.components import zeroconf
|
||||||
from homeassistant.components.dhcp import HOSTNAME, IP_ADDRESS, MAC_ADDRESS
|
from homeassistant.components.dhcp import HOSTNAME, IP_ADDRESS, MAC_ADDRESS
|
||||||
from homeassistant.components.guardian import CONF_UID, DOMAIN
|
from homeassistant.components.guardian import CONF_UID, DOMAIN
|
||||||
from homeassistant.components.guardian.config_flow import (
|
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):
|
async def test_step_zeroconf(hass, ping_client):
|
||||||
"""Test the zeroconf step."""
|
"""Test the zeroconf step."""
|
||||||
zeroconf_data = {
|
zeroconf_data = zeroconf.ZeroconfServiceInfo(
|
||||||
"host": "192.168.1.100",
|
host="192.168.1.100",
|
||||||
"port": 7777,
|
port=7777,
|
||||||
"hostname": "GVC1-ABCD.local.",
|
hostname="GVC1-ABCD.local.",
|
||||||
"type": "_api._udp.local.",
|
type="_api._udp.local.",
|
||||||
"name": "Guardian Valve Controller API._api._udp.local.",
|
name="Guardian Valve Controller API._api._udp.local.",
|
||||||
"properties": {"_raw": {}},
|
properties={"_raw": {}},
|
||||||
}
|
)
|
||||||
|
|
||||||
result = await hass.config_entries.flow.async_init(
|
result = await hass.config_entries.flow.async_init(
|
||||||
DOMAIN, context={"source": SOURCE_ZEROCONF}, data=zeroconf_data
|
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):
|
async def test_step_zeroconf_already_in_progress(hass):
|
||||||
"""Test the zeroconf step aborting because it's already in progress."""
|
"""Test the zeroconf step aborting because it's already in progress."""
|
||||||
zeroconf_data = {
|
zeroconf_data = zeroconf.ZeroconfServiceInfo(
|
||||||
"host": "192.168.1.100",
|
host="192.168.1.100",
|
||||||
"port": 7777,
|
port=7777,
|
||||||
"hostname": "GVC1-ABCD.local.",
|
hostname="GVC1-ABCD.local.",
|
||||||
"type": "_api._udp.local.",
|
type="_api._udp.local.",
|
||||||
"name": "Guardian Valve Controller API._api._udp.local.",
|
name="Guardian Valve Controller API._api._udp.local.",
|
||||||
"properties": {"_raw": {}},
|
properties={"_raw": {}},
|
||||||
}
|
)
|
||||||
|
|
||||||
result = await hass.config_entries.flow.async_init(
|
result = await hass.config_entries.flow.async_init(
|
||||||
DOMAIN, context={"source": SOURCE_ZEROCONF}, data=zeroconf_data
|
DOMAIN, context={"source": SOURCE_ZEROCONF}, data=zeroconf_data
|
||||||
|
Loading…
x
Reference in New Issue
Block a user