mirror of
https://github.com/home-assistant/core.git
synced 2025-07-15 01:07:10 +00:00
Use ZeroconfServiceInfo in lookin (#59987)
Co-authored-by: epenet <epenet@users.noreply.github.com>
This commit is contained in:
parent
81e02a39df
commit
8a4d3b2a2e
@ -31,8 +31,8 @@ class LookinFlowHandler(config_entries.ConfigFlow, domain=DOMAIN):
|
||||
self, discovery_info: zeroconf.ZeroconfServiceInfo
|
||||
) -> FlowResult:
|
||||
"""Start a discovery flow from zeroconf."""
|
||||
uid: str = discovery_info["hostname"][: -len(".local.")]
|
||||
host: str = discovery_info["host"]
|
||||
uid: str = discovery_info[zeroconf.ATTR_HOSTNAME][: -len(".local.")]
|
||||
host: str = discovery_info[zeroconf.ATTR_HOST]
|
||||
await self.async_set_unique_id(uid.upper())
|
||||
self._abort_if_unique_id_configured(updates={CONF_HOST: host})
|
||||
|
||||
|
@ -17,14 +17,14 @@ DEFAULT_ENTRY_TITLE = DEVICE_NAME
|
||||
|
||||
ZC_NAME = f"LOOKin_{DEVICE_ID}"
|
||||
ZC_TYPE = "_lookin._tcp."
|
||||
ZEROCONF_DATA: ZeroconfServiceInfo = {
|
||||
"host": IP_ADDRESS,
|
||||
"hostname": f"{ZC_NAME.lower()}.local.",
|
||||
"port": 80,
|
||||
"type": ZC_TYPE,
|
||||
"name": ZC_NAME,
|
||||
"properties": {},
|
||||
}
|
||||
ZEROCONF_DATA = ZeroconfServiceInfo(
|
||||
host=IP_ADDRESS,
|
||||
hostname=f"{ZC_NAME.lower()}.local.",
|
||||
port=80,
|
||||
type=ZC_TYPE,
|
||||
name=ZC_NAME,
|
||||
properties={},
|
||||
)
|
||||
|
||||
|
||||
def _mocked_climate() -> Climate:
|
||||
|
@ -6,6 +6,7 @@ from unittest.mock import patch
|
||||
from aiolookin import NoUsableService
|
||||
|
||||
from homeassistant import config_entries
|
||||
from homeassistant.components import zeroconf
|
||||
from homeassistant.components.lookin.const import DOMAIN
|
||||
from homeassistant.const import CONF_HOST
|
||||
from homeassistant.core import HomeAssistant
|
||||
@ -138,7 +139,7 @@ async def test_discovered_zeroconf(hass):
|
||||
|
||||
entry = hass.config_entries.async_entries(DOMAIN)[0]
|
||||
zc_data_new_ip = ZEROCONF_DATA.copy()
|
||||
zc_data_new_ip["host"] = "127.0.0.2"
|
||||
zc_data_new_ip[zeroconf.ATTR_HOST] = "127.0.0.2"
|
||||
|
||||
with _patch_get_info(), patch(
|
||||
f"{MODULE}.async_setup_entry", return_value=True
|
||||
|
Loading…
x
Reference in New Issue
Block a user