Limit zeroconf discovery to name/macaddress when provided (#39877)
Co-authored-by: Paulus Schoutsen <paulus@home-assistant.io>
This commit is contained in:
1 parent
487a74ba5d
commit
9389a7c9be
12 files changed
+306
-56
No files matched your search
@@ -1,5 +1,6 @@
|
||||
"""Support for exposing Home Assistant via Zeroconf."""
|
||||
import asyncio
|
||||
import fnmatch
|
||||
import ipaddress
|
||||
import logging
|
||||
import socket
|
||||
@@ -268,10 +269,26 @@ def setup(hass, config):
|
||||
# likely bad homekit data
|
||||
return
|
||||
|
||||
for domain in zeroconf_types[service_type]:
|
||||
for entry in zeroconf_types[service_type]:
|
||||
if len(entry) > 1:
|
||||
if "macaddress" in entry:
|
||||
if "properties" not in info:
|
||||
continue
|
||||
if "macaddress" not in info["properties"]:
|
||||
continue
|
||||
if not fnmatch.fnmatch(
|
||||
info["properties"]["macaddress"], entry["macaddress"]
|
||||
):
|
||||
continue
|
||||
if "name" in entry:
|
||||
if "name" not in info:
|
||||
continue
|
||||
if not fnmatch.fnmatch(info["name"], entry["name"]):
|
||||
continue
|
||||
|
||||
hass.add_job(
|
||||
hass.config_entries.flow.async_init(
|
||||
domain, context={"source": DOMAIN}, data=info
|
||||
entry["domain"], context={"source": DOMAIN}, data=info
|
||||
)
|
||||
)
|
||||
|
||||
|
||||
Reference in new issue
Block a user