mirror of
https://github.com/home-assistant/core
synced 2024-09-09 12:51:22 +02:00
Add zeroconf discovery to powerview (#50308)
This commit is contained in:
parent
9cab8a19cd
commit
29cd5f20b9
@ -19,6 +19,7 @@ _LOGGER = logging.getLogger(__name__)
|
|||||||
|
|
||||||
DATA_SCHEMA = vol.Schema({vol.Required(CONF_HOST): str})
|
DATA_SCHEMA = vol.Schema({vol.Required(CONF_HOST): str})
|
||||||
HAP_SUFFIX = "._hap._tcp.local."
|
HAP_SUFFIX = "._hap._tcp.local."
|
||||||
|
POWERVIEW_SUFFIX = "._powerview._tcp.local."
|
||||||
|
|
||||||
|
|
||||||
async def validate_input(hass: core.HomeAssistant, hub_address: str) -> dict[str, str]:
|
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]
|
self.discovered_name = discovery_info[HOSTNAME]
|
||||||
return await self.async_step_discovery_confirm()
|
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):
|
async def async_step_homekit(self, discovery_info):
|
||||||
"""Handle HomeKit discovery."""
|
"""Handle HomeKit discovery."""
|
||||||
self.discovered_ip = discovery_info[CONF_HOST]
|
self.discovered_ip = discovery_info[CONF_HOST]
|
||||||
|
@ -14,5 +14,6 @@
|
|||||||
"macaddress": "002674*"
|
"macaddress": "002674*"
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
|
"zeroconf": ["_powerview._tcp.local."],
|
||||||
"iot_class": "local_polling"
|
"iot_class": "local_polling"
|
||||||
}
|
}
|
||||||
|
@ -158,6 +158,11 @@ ZEROCONF = {
|
|||||||
"domain": "plugwise"
|
"domain": "plugwise"
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
|
"_powerview._tcp.local.": [
|
||||||
|
{
|
||||||
|
"domain": "hunterdouglas_powerview"
|
||||||
|
}
|
||||||
|
],
|
||||||
"_printer._tcp.local.": [
|
"_printer._tcp.local.": [
|
||||||
{
|
{
|
||||||
"domain": "brother",
|
"domain": "brother",
|
||||||
|
@ -16,6 +16,11 @@ HOMEKIT_DISCOVERY_INFO = {
|
|||||||
"properties": {"id": "AA::BB::CC::DD::EE::FF"},
|
"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"}
|
DHCP_DISCOVERY_INFO = {"hostname": "Hunter Douglas Powerview Hub", "ip": "1.2.3.4"}
|
||||||
|
|
||||||
DISCOVERY_DATA = [
|
DISCOVERY_DATA = [
|
||||||
@ -27,6 +32,7 @@ DISCOVERY_DATA = [
|
|||||||
config_entries.SOURCE_DHCP,
|
config_entries.SOURCE_DHCP,
|
||||||
DHCP_DISCOVERY_INFO,
|
DHCP_DISCOVERY_INFO,
|
||||||
),
|
),
|
||||||
|
(config_entries.SOURCE_ZEROCONF, ZEROCONF_DISCOVERY_INFO),
|
||||||
]
|
]
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user