mirror of
https://github.com/home-assistant/core.git
synced 2025-07-23 21:27:38 +00:00
Use ZeroconfServiceInfo in tado (#60111)
Co-authored-by: epenet <epenet@users.noreply.github.com>
This commit is contained in:
parent
eb70d328ca
commit
39149e19f7
@ -6,8 +6,10 @@ import requests.exceptions
|
||||
import voluptuous as vol
|
||||
|
||||
from homeassistant import config_entries, core, exceptions
|
||||
from homeassistant.components import zeroconf
|
||||
from homeassistant.const import CONF_PASSWORD, CONF_USERNAME
|
||||
from homeassistant.core import callback
|
||||
from homeassistant.data_entry_flow import FlowResult
|
||||
|
||||
from .const import CONF_FALLBACK, DOMAIN, UNIQUE_ID
|
||||
|
||||
@ -80,13 +82,16 @@ class ConfigFlow(config_entries.ConfigFlow, domain=DOMAIN):
|
||||
step_id="user", data_schema=DATA_SCHEMA, errors=errors
|
||||
)
|
||||
|
||||
async def async_step_homekit(self, discovery_info):
|
||||
async def async_step_homekit(
|
||||
self, discovery_info: zeroconf.ZeroconfServiceInfo
|
||||
) -> FlowResult:
|
||||
"""Handle HomeKit discovery."""
|
||||
self._async_abort_entries_match()
|
||||
properties = {
|
||||
key.lower(): value for (key, value) in discovery_info["properties"].items()
|
||||
key.lower(): value
|
||||
for (key, value) in discovery_info[zeroconf.ATTR_PROPERTIES].items()
|
||||
}
|
||||
await self.async_set_unique_id(properties["id"])
|
||||
await self.async_set_unique_id(properties[zeroconf.ATTR_PROPERTIES_ID])
|
||||
return await self.async_step_user()
|
||||
|
||||
def _username_already_configured(self, user_input):
|
||||
|
@ -5,6 +5,7 @@ from unittest.mock import MagicMock, patch
|
||||
import requests
|
||||
|
||||
from homeassistant import config_entries
|
||||
from homeassistant.components import zeroconf
|
||||
from homeassistant.components.tado.const import DOMAIN
|
||||
from homeassistant.const import CONF_PASSWORD, CONF_USERNAME
|
||||
|
||||
@ -126,7 +127,9 @@ async def test_form_homekit(hass):
|
||||
result = await hass.config_entries.flow.async_init(
|
||||
DOMAIN,
|
||||
context={"source": config_entries.SOURCE_HOMEKIT},
|
||||
data={"properties": {"id": "AA:BB:CC:DD:EE:FF"}},
|
||||
data=zeroconf.ZeroconfServiceInfo(
|
||||
properties={zeroconf.ATTR_PROPERTIES_ID: "AA:BB:CC:DD:EE:FF"}
|
||||
),
|
||||
)
|
||||
assert result["type"] == "form"
|
||||
assert result["errors"] == {}
|
||||
@ -145,6 +148,8 @@ async def test_form_homekit(hass):
|
||||
result = await hass.config_entries.flow.async_init(
|
||||
DOMAIN,
|
||||
context={"source": config_entries.SOURCE_HOMEKIT},
|
||||
data={"properties": {"id": "AA:BB:CC:DD:EE:FF"}},
|
||||
data=zeroconf.ZeroconfServiceInfo(
|
||||
properties={zeroconf.ATTR_PROPERTIES_ID: "AA:BB:CC:DD:EE:FF"}
|
||||
),
|
||||
)
|
||||
assert result["type"] == "abort"
|
||||
|
Loading…
x
Reference in New Issue
Block a user