1
mirror of https://github.com/home-assistant/core synced 2024-08-02 23:40:32 +02:00

Add zeroconf discovery to powerview (#50308)

This commit is contained in:
J. Nick Koston 2021-05-09 04:41:27 -05:00 committed by GitHub
parent 9cab8a19cd
commit 29cd5f20b9
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 22 additions and 0 deletions

View File

@ -19,6 +19,7 @@ _LOGGER = logging.getLogger(__name__)
DATA_SCHEMA = vol.Schema({vol.Required(CONF_HOST): str})
HAP_SUFFIX = "._hap._tcp.local."
POWERVIEW_SUFFIX = "._powerview._tcp.local."
async def validate_input(hass: core.HomeAssistant, hub_address: str) -> dict[str, str]:
@ -91,6 +92,15 @@ class ConfigFlow(config_entries.ConfigFlow, domain=DOMAIN):
self.discovered_name = discovery_info[HOSTNAME]
return await self.async_step_discovery_confirm()
async def async_step_zeroconf(self, discovery_info):
"""Handle zeroconf discovery."""
self.discovered_ip = discovery_info[CONF_HOST]
name = discovery_info[CONF_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):
"""Handle HomeKit discovery."""
self.discovered_ip = discovery_info[CONF_HOST]

View File

@ -14,5 +14,6 @@
"macaddress": "002674*"
}
],
"zeroconf": ["_powerview._tcp.local."],
"iot_class": "local_polling"
}

View File

@ -158,6 +158,11 @@ ZEROCONF = {
"domain": "plugwise"
}
],
"_powerview._tcp.local.": [
{
"domain": "hunterdouglas_powerview"
}
],
"_printer._tcp.local.": [
{
"domain": "brother",

View File

@ -16,6 +16,11 @@ HOMEKIT_DISCOVERY_INFO = {
"properties": {"id": "AA::BB::CC::DD::EE::FF"},
}
ZEROCONF_DISCOVERY_INFO = {
"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"}
DISCOVERY_DATA = [
@ -27,6 +32,7 @@ DISCOVERY_DATA = [
config_entries.SOURCE_DHCP,
DHCP_DISCOVERY_INFO,
),
(config_entries.SOURCE_ZEROCONF, ZEROCONF_DISCOVERY_INFO),
]