mirror of
https://github.com/home-assistant/core.git
synced 2025-07-13 16:27:08 +00:00
Use ZeroconfServiceInfo in gogogate2 (#59746)
Co-authored-by: epenet <epenet@users.noreply.github.com>
This commit is contained in:
parent
f751d6e064
commit
9ccee205ca
@ -7,6 +7,7 @@ from ismartgate.const import GogoGate2ApiErrorCode, ISmartGateApiErrorCode
|
||||
import voluptuous as vol
|
||||
|
||||
from homeassistant import data_entry_flow
|
||||
from homeassistant.components import zeroconf
|
||||
from homeassistant.components.dhcp import IP_ADDRESS, MAC_ADDRESS
|
||||
from homeassistant.config_entries import ConfigFlow
|
||||
from homeassistant.const import (
|
||||
@ -35,10 +36,12 @@ class Gogogate2FlowHandler(ConfigFlow, domain=DOMAIN):
|
||||
self._ip_address = None
|
||||
self._device_type = None
|
||||
|
||||
async def async_step_homekit(self, discovery_info):
|
||||
async def async_step_homekit(
|
||||
self, discovery_info: zeroconf.ZeroconfServiceInfo
|
||||
) -> data_entry_flow.FlowResult:
|
||||
"""Handle homekit discovery."""
|
||||
await self.async_set_unique_id(discovery_info["properties"]["id"])
|
||||
return await self._async_discovery_handler(discovery_info["host"])
|
||||
await self.async_set_unique_id(discovery_info[zeroconf.ATTR_PROPERTIES]["id"])
|
||||
return await self._async_discovery_handler(discovery_info[zeroconf.ATTR_HOST])
|
||||
|
||||
async def async_step_dhcp(self, discovery_info):
|
||||
"""Handle dhcp discovery."""
|
||||
|
@ -6,6 +6,7 @@ from ismartgate.common import ApiError
|
||||
from ismartgate.const import GogoGate2ApiErrorCode
|
||||
|
||||
from homeassistant import config_entries
|
||||
from homeassistant.components import zeroconf
|
||||
from homeassistant.components.gogogate2.const import (
|
||||
DEVICE_TYPE_GOGOGATE2,
|
||||
DEVICE_TYPE_ISMARTGATE,
|
||||
@ -106,7 +107,9 @@ async def test_form_homekit_unique_id_already_setup(hass):
|
||||
result = await hass.config_entries.flow.async_init(
|
||||
DOMAIN,
|
||||
context={"source": config_entries.SOURCE_HOMEKIT},
|
||||
data={"host": "1.2.3.4", "properties": {"id": MOCK_MAC_ADDR}},
|
||||
data=zeroconf.ZeroconfServiceInfo(
|
||||
host="1.2.3.4", properties={"id": MOCK_MAC_ADDR}
|
||||
),
|
||||
)
|
||||
assert result["type"] == RESULT_TYPE_FORM
|
||||
assert result["errors"] == {}
|
||||
@ -126,7 +129,9 @@ async def test_form_homekit_unique_id_already_setup(hass):
|
||||
result = await hass.config_entries.flow.async_init(
|
||||
DOMAIN,
|
||||
context={"source": config_entries.SOURCE_HOMEKIT},
|
||||
data={"host": "1.2.3.4", "properties": {"id": MOCK_MAC_ADDR}},
|
||||
data=zeroconf.ZeroconfServiceInfo(
|
||||
host="1.2.3.4", properties={"id": MOCK_MAC_ADDR}
|
||||
),
|
||||
)
|
||||
assert result["type"] == RESULT_TYPE_ABORT
|
||||
|
||||
@ -143,7 +148,9 @@ async def test_form_homekit_ip_address_already_setup(hass):
|
||||
result = await hass.config_entries.flow.async_init(
|
||||
DOMAIN,
|
||||
context={"source": config_entries.SOURCE_HOMEKIT},
|
||||
data={"host": "1.2.3.4", "properties": {"id": MOCK_MAC_ADDR}},
|
||||
data=zeroconf.ZeroconfServiceInfo(
|
||||
host="1.2.3.4", properties={"id": MOCK_MAC_ADDR}
|
||||
),
|
||||
)
|
||||
assert result["type"] == RESULT_TYPE_ABORT
|
||||
|
||||
@ -154,7 +161,9 @@ async def test_form_homekit_ip_address(hass):
|
||||
result = await hass.config_entries.flow.async_init(
|
||||
DOMAIN,
|
||||
context={"source": config_entries.SOURCE_HOMEKIT},
|
||||
data={"host": "1.2.3.4", "properties": {"id": MOCK_MAC_ADDR}},
|
||||
data=zeroconf.ZeroconfServiceInfo(
|
||||
host="1.2.3.4", properties={"id": MOCK_MAC_ADDR}
|
||||
),
|
||||
)
|
||||
assert result["type"] == RESULT_TYPE_FORM
|
||||
assert result["errors"] == {}
|
||||
@ -227,7 +236,9 @@ async def test_discovered_by_homekit_and_dhcp(hass):
|
||||
result = await hass.config_entries.flow.async_init(
|
||||
DOMAIN,
|
||||
context={"source": config_entries.SOURCE_HOMEKIT},
|
||||
data={"host": "1.2.3.4", "properties": {"id": MOCK_MAC_ADDR}},
|
||||
data=zeroconf.ZeroconfServiceInfo(
|
||||
host="1.2.3.4", properties={"id": MOCK_MAC_ADDR}
|
||||
),
|
||||
)
|
||||
assert result["type"] == RESULT_TYPE_FORM
|
||||
assert result["errors"] == {}
|
||||
|
Loading…
x
Reference in New Issue
Block a user