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