mirror of
https://github.com/home-assistant/core.git
synced 2025-07-23 21:27:38 +00:00
Use ZeroconfServiceInfo in nanoleaf (#60045)
This commit is contained in:
parent
56e93ff0ec
commit
25e5263954
@ -107,9 +107,11 @@ class ConfigFlow(config_entries.ConfigFlow, domain=DOMAIN):
|
||||
) -> FlowResult:
|
||||
"""Handle Nanoleaf Homekit and Zeroconf discovery."""
|
||||
return await self._async_discovery_handler(
|
||||
discovery_info["host"],
|
||||
discovery_info["name"].replace(f".{discovery_info['type']}", ""),
|
||||
discovery_info["properties"]["id"],
|
||||
discovery_info[zeroconf.ATTR_HOST],
|
||||
discovery_info[zeroconf.ATTR_NAME].replace(
|
||||
f".{discovery_info[zeroconf.ATTR_TYPE]}", ""
|
||||
),
|
||||
discovery_info[zeroconf.ATTR_PROPERTIES][zeroconf.ATTR_PROPERTIES_ID],
|
||||
)
|
||||
|
||||
async def async_step_ssdp(self, discovery_info: DiscoveryInfoType) -> FlowResult:
|
||||
|
@ -7,6 +7,7 @@ from aionanoleaf import InvalidToken, NanoleafException, Unauthorized, Unavailab
|
||||
import pytest
|
||||
|
||||
from homeassistant import config_entries
|
||||
from homeassistant.components import zeroconf
|
||||
from homeassistant.components.nanoleaf.const import DOMAIN
|
||||
from homeassistant.const import CONF_HOST, CONF_TOKEN
|
||||
from homeassistant.core import HomeAssistant
|
||||
@ -235,12 +236,12 @@ async def test_discovery_link_unavailable(
|
||||
result = await hass.config_entries.flow.async_init(
|
||||
DOMAIN,
|
||||
context={"source": source},
|
||||
data={
|
||||
"host": TEST_HOST,
|
||||
"name": f"{TEST_NAME}.{type_in_discovery_info}",
|
||||
"type": type_in_discovery_info,
|
||||
"properties": {"id": TEST_DEVICE_ID},
|
||||
},
|
||||
data=zeroconf.ZeroconfServiceInfo(
|
||||
host=TEST_HOST,
|
||||
name=f"{TEST_NAME}.{type_in_discovery_info}",
|
||||
type=type_in_discovery_info,
|
||||
properties={zeroconf.ATTR_PROPERTIES_ID: TEST_DEVICE_ID},
|
||||
),
|
||||
)
|
||||
assert result["type"] == "form"
|
||||
assert result["step_id"] == "link"
|
||||
@ -417,12 +418,12 @@ async def test_import_discovery_integration(
|
||||
result = await hass.config_entries.flow.async_init(
|
||||
DOMAIN,
|
||||
context={"source": source},
|
||||
data={
|
||||
"host": TEST_HOST,
|
||||
"name": f"{TEST_NAME}.{type_in_discovery}",
|
||||
"type": type_in_discovery,
|
||||
"properties": {"id": TEST_DEVICE_ID},
|
||||
},
|
||||
data=zeroconf.ZeroconfServiceInfo(
|
||||
host=TEST_HOST,
|
||||
name=f"{TEST_NAME}.{type_in_discovery}",
|
||||
type=type_in_discovery,
|
||||
properties={zeroconf.ATTR_PROPERTIES_ID: TEST_DEVICE_ID},
|
||||
),
|
||||
)
|
||||
assert result["type"] == "create_entry"
|
||||
assert result["title"] == TEST_NAME
|
||||
|
Loading…
x
Reference in New Issue
Block a user