Use a single service browser for zeroconf discovery (#35997)
parent
cda2da62cf
commit
b0578018cb
|
@ -98,7 +98,7 @@ class HaServiceBrowser(ServiceBrowser):
|
|||
# To avoid overwhemling the system we pre-filter here and only process
|
||||
# DNSPointers for the configured record name (type)
|
||||
#
|
||||
if record.name != self.type or not isinstance(record, DNSPointer):
|
||||
if record.name not in self.types or not isinstance(record, DNSPointer):
|
||||
return
|
||||
super().update_record(zc, now, record)
|
||||
|
||||
|
@ -224,11 +224,12 @@ def setup(hass, config):
|
|||
)
|
||||
)
|
||||
|
||||
for service in ZEROCONF:
|
||||
HaServiceBrowser(zeroconf, service, handlers=[service_update])
|
||||
types = list(ZEROCONF)
|
||||
|
||||
if HOMEKIT_TYPE not in ZEROCONF:
|
||||
HaServiceBrowser(zeroconf, HOMEKIT_TYPE, handlers=[service_update])
|
||||
types.append(HOMEKIT_TYPE)
|
||||
|
||||
HaServiceBrowser(zeroconf, types, handlers=[service_update])
|
||||
|
||||
return True
|
||||
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
"domain": "zeroconf",
|
||||
"name": "Zero-configuration networking (zeroconf)",
|
||||
"documentation": "https://www.home-assistant.io/integrations/zeroconf",
|
||||
"requirements": ["zeroconf==0.26.1"],
|
||||
"requirements": ["zeroconf==0.26.2"],
|
||||
"dependencies": ["api"],
|
||||
"codeowners": ["@robbiet480", "@Kane610"],
|
||||
"quality_scale": "internal"
|
||||
|
|
|
@ -25,7 +25,7 @@ ruamel.yaml==0.15.100
|
|||
sqlalchemy==1.3.17
|
||||
voluptuous-serialize==2.3.0
|
||||
voluptuous==0.11.7
|
||||
zeroconf==0.26.1
|
||||
zeroconf==0.26.2
|
||||
|
||||
pycryptodome>=3.6.6
|
||||
|
||||
|
|
|
@ -2239,7 +2239,7 @@ youtube_dl==2020.05.08
|
|||
zengge==0.2
|
||||
|
||||
# homeassistant.components.zeroconf
|
||||
zeroconf==0.26.1
|
||||
zeroconf==0.26.2
|
||||
|
||||
# homeassistant.components.zha
|
||||
zha-quirks==0.0.39
|
||||
|
|
|
@ -906,7 +906,7 @@ xmltodict==0.12.0
|
|||
ya_ma==0.3.8
|
||||
|
||||
# homeassistant.components.zeroconf
|
||||
zeroconf==0.26.1
|
||||
zeroconf==0.26.2
|
||||
|
||||
# homeassistant.components.zha
|
||||
zha-quirks==0.0.39
|
||||
|
|
|
@ -29,9 +29,10 @@ def mock_zeroconf():
|
|||
yield mock_zc.return_value
|
||||
|
||||
|
||||
def service_update_mock(zeroconf, service, handlers):
|
||||
def service_update_mock(zeroconf, services, handlers):
|
||||
"""Call service update handler."""
|
||||
handlers[0](zeroconf, service, f"name.{service}", ServiceStateChange.Added)
|
||||
for service in services:
|
||||
handlers[0](zeroconf, service, f"name.{service}", ServiceStateChange.Added)
|
||||
|
||||
|
||||
def get_service_info_mock(service_type, name):
|
||||
|
@ -76,7 +77,7 @@ async def test_setup(hass, mock_zeroconf):
|
|||
mock_zeroconf.get_service_info.side_effect = get_service_info_mock
|
||||
assert await async_setup_component(hass, zeroconf.DOMAIN, {zeroconf.DOMAIN: {}})
|
||||
|
||||
assert len(mock_service_browser.mock_calls) == len(zc_gen.ZEROCONF)
|
||||
assert len(mock_service_browser.mock_calls) == 1
|
||||
expected_flow_calls = 0
|
||||
for matching_components in zc_gen.ZEROCONF.values():
|
||||
expected_flow_calls += len(matching_components)
|
||||
|
|
Loading…
Reference in New Issue