mirror of
https://github.com/home-assistant/core.git
synced 2025-07-22 04:37:06 +00:00
Use ServiceInfo in hunterdouglas_powerview (#59981)
Co-authored-by: epenet <epenet@users.noreply.github.com>
This commit is contained in:
parent
c557da028a
commit
d6c5aaa0cb
@ -8,8 +8,9 @@ import async_timeout
|
||||
import voluptuous as vol
|
||||
|
||||
from homeassistant import config_entries, core, exceptions
|
||||
from homeassistant.components.dhcp import HOSTNAME, IP_ADDRESS
|
||||
from homeassistant.components import dhcp, zeroconf
|
||||
from homeassistant.const import CONF_HOST, CONF_NAME
|
||||
from homeassistant.data_entry_flow import FlowResult
|
||||
from homeassistant.helpers.aiohttp_client import async_get_clientsession
|
||||
|
||||
from . import async_get_device_info
|
||||
@ -85,25 +86,29 @@ class ConfigFlow(config_entries.ConfigFlow, domain=DOMAIN):
|
||||
|
||||
return info, None
|
||||
|
||||
async def async_step_dhcp(self, discovery_info):
|
||||
async def async_step_dhcp(self, discovery_info: dhcp.DhcpServiceInfo) -> FlowResult:
|
||||
"""Handle DHCP discovery."""
|
||||
self.discovered_ip = discovery_info[IP_ADDRESS]
|
||||
self.discovered_name = discovery_info[HOSTNAME]
|
||||
self.discovered_ip = discovery_info[dhcp.IP_ADDRESS]
|
||||
self.discovered_name = discovery_info[dhcp.HOSTNAME]
|
||||
return await self.async_step_discovery_confirm()
|
||||
|
||||
async def async_step_zeroconf(self, discovery_info):
|
||||
async def async_step_zeroconf(
|
||||
self, discovery_info: zeroconf.ZeroconfServiceInfo
|
||||
) -> FlowResult:
|
||||
"""Handle zeroconf discovery."""
|
||||
self.discovered_ip = discovery_info[CONF_HOST]
|
||||
name = discovery_info[CONF_NAME]
|
||||
self.discovered_ip = discovery_info[zeroconf.ATTR_HOST]
|
||||
name = discovery_info[zeroconf.ATTR_NAME]
|
||||
if name.endswith(POWERVIEW_SUFFIX):
|
||||
name = name[: -len(POWERVIEW_SUFFIX)]
|
||||
self.discovered_name = name
|
||||
return await self.async_step_discovery_confirm()
|
||||
|
||||
async def async_step_homekit(self, discovery_info):
|
||||
async def async_step_homekit(
|
||||
self, discovery_info: zeroconf.ZeroconfServiceInfo
|
||||
) -> FlowResult:
|
||||
"""Handle HomeKit discovery."""
|
||||
self.discovered_ip = discovery_info[CONF_HOST]
|
||||
name = discovery_info[CONF_NAME]
|
||||
self.discovered_ip = discovery_info[zeroconf.ATTR_HOST]
|
||||
name = discovery_info[zeroconf.ATTR_NAME]
|
||||
if name.endswith(HAP_SUFFIX):
|
||||
name = name[: -len(HAP_SUFFIX)]
|
||||
self.discovered_name = name
|
||||
|
@ -6,22 +6,25 @@ from unittest.mock import AsyncMock, MagicMock, patch
|
||||
import pytest
|
||||
|
||||
from homeassistant import config_entries
|
||||
from homeassistant.components import dhcp, zeroconf
|
||||
from homeassistant.components.hunterdouglas_powerview.const import DOMAIN
|
||||
|
||||
from tests.common import MockConfigEntry, load_fixture
|
||||
|
||||
HOMEKIT_DISCOVERY_INFO = {
|
||||
"name": "Hunter Douglas Powerview Hub._hap._tcp.local.",
|
||||
"host": "1.2.3.4",
|
||||
"properties": {"id": "AA::BB::CC::DD::EE::FF"},
|
||||
}
|
||||
HOMEKIT_DISCOVERY_INFO = zeroconf.ZeroconfServiceInfo(
|
||||
name="Hunter Douglas Powerview Hub._hap._tcp.local.",
|
||||
host="1.2.3.4",
|
||||
properties={"id": "AA::BB::CC::DD::EE::FF"},
|
||||
)
|
||||
|
||||
ZEROCONF_DISCOVERY_INFO = {
|
||||
"name": "Hunter Douglas Powerview Hub._powerview._tcp.local.",
|
||||
"host": "1.2.3.4",
|
||||
}
|
||||
ZEROCONF_DISCOVERY_INFO = zeroconf.ZeroconfServiceInfo(
|
||||
name="Hunter Douglas Powerview Hub._powerview._tcp.local.",
|
||||
host="1.2.3.4",
|
||||
)
|
||||
|
||||
DHCP_DISCOVERY_INFO = {"hostname": "Hunter Douglas Powerview Hub", "ip": "1.2.3.4"}
|
||||
DHCP_DISCOVERY_INFO = dhcp.DhcpServiceInfo(
|
||||
hostname="Hunter Douglas Powerview Hub", ip="1.2.3.4"
|
||||
)
|
||||
|
||||
DISCOVERY_DATA = [
|
||||
(
|
||||
|
Loading…
x
Reference in New Issue
Block a user