|
87 | 87 | NODE_PING_TIMEOUT = 10
|
88 | 88 | NODE_PING_TIMEOUT_BATTERY_POWERED = 60
|
89 | 89 | NODE_MDNS_SUBSCRIPTION_RETRY_TIMEOUT = 30 * 60
|
90 |
| -FALLBACK_NODE_SCANNER_INTERVAL = 30 * 60 |
91 | 90 | CUSTOM_ATTRIBUTES_POLLER_INTERVAL = 30
|
92 | 91 |
|
93 | 92 | MDNS_TYPE_OPERATIONAL_NODE = "_matter._tcp.local."
|
@@ -156,8 +155,6 @@ def __init__(
|
156 | 155 | self._known_commissioning_params_timers: dict[int, asyncio.TimerHandle] = {}
|
157 | 156 | self._aiobrowser: AsyncServiceBrowser | None = None
|
158 | 157 | self._aiozc: AsyncZeroconf | None = None
|
159 |
| - self._fallback_node_scanner_timer: asyncio.TimerHandle | None = None |
160 |
| - self._fallback_node_scanner_task: asyncio.Task | None = None |
161 | 158 | self._thread_node_setup_throttle = asyncio.Semaphore(5)
|
162 | 159 | self._mdns_event_timer: dict[str, asyncio.TimerHandle] = {}
|
163 | 160 | self._polled_attributes: dict[int, set[str]] = {}
|
@@ -218,18 +215,12 @@ async def start(self) -> None:
|
218 | 215 | services,
|
219 | 216 | handlers=[self._on_mdns_service_state_change],
|
220 | 217 | )
|
221 |
| - # set-up fallback node scanner |
222 |
| - self._schedule_fallback_scanner() |
223 | 218 |
|
224 | 219 | async def stop(self) -> None:
|
225 | 220 | """Handle logic on server stop."""
|
226 |
| - # shutdown (and cleanup) mdns browser and fallback node scanner |
| 221 | + # shutdown (and cleanup) mdns browser |
227 | 222 | if self._aiobrowser:
|
228 | 223 | await self._aiobrowser.async_cancel()
|
229 |
| - if self._fallback_node_scanner_timer: |
230 |
| - self._fallback_node_scanner_timer.cancel() |
231 |
| - if (scan_task := self._fallback_node_scanner_task) and not scan_task.done(): |
232 |
| - scan_task.cancel() |
233 | 224 | if self._aiozc:
|
234 | 225 | await self._aiozc.async_close()
|
235 | 226 | # Ensure any in-progress setup tasks are cancelled
|
@@ -1581,43 +1572,6 @@ async def _node_offline(self, node_id: int) -> None:
|
1581 | 1572 | # mark node as unavailable (if it wasn't already)
|
1582 | 1573 | self._node_unavailable(node_id)
|
1583 | 1574 |
|
1584 |
| - async def _fallback_node_scanner(self) -> None: |
1585 |
| - """Scan for operational nodes in the background that are missed by mdns.""" |
1586 |
| - # This code could/should be removed in the future and is added to have a fallback |
1587 |
| - # to discover operational nodes that got somehow missed by zeroconf. |
1588 |
| - # the issue in zeroconf is being investigated and in the meanwhile we have this fallback. |
1589 |
| - for node_id, node in self._nodes.items(): |
1590 |
| - if node.available: |
1591 |
| - continue |
1592 |
| - now = time.time() |
1593 |
| - last_seen = self._node_last_seen_on_mdns.get(node_id, 0) |
1594 |
| - if now - last_seen < FALLBACK_NODE_SCANNER_INTERVAL: |
1595 |
| - continue |
1596 |
| - if await self.ping_node(node_id, attempts=3): |
1597 |
| - LOGGER.info("Node %s discovered using fallback ping", node_id) |
1598 |
| - if task := self._setup_node_create_task(node_id): |
1599 |
| - await task |
1600 |
| - |
1601 |
| - # reschedule self to run at next interval |
1602 |
| - self._schedule_fallback_scanner() |
1603 |
| - |
1604 |
| - def _schedule_fallback_scanner(self) -> None: |
1605 |
| - """Schedule running the fallback node scanner at X interval.""" |
1606 |
| - if existing := self._fallback_node_scanner_timer: |
1607 |
| - existing.cancel() |
1608 |
| - |
1609 |
| - def run_fallback_node_scanner() -> None: |
1610 |
| - self._fallback_node_scanner_timer = None |
1611 |
| - if (existing := self._fallback_node_scanner_task) and not existing.done(): |
1612 |
| - existing.cancel() |
1613 |
| - self._fallback_node_scanner_task = asyncio.create_task( |
1614 |
| - self._fallback_node_scanner() |
1615 |
| - ) |
1616 |
| - |
1617 |
| - self._fallback_node_scanner_timer = self._loop.call_later( |
1618 |
| - FALLBACK_NODE_SCANNER_INTERVAL, run_fallback_node_scanner |
1619 |
| - ) |
1620 |
| - |
1621 | 1575 | async def _custom_attributes_poller(self) -> None:
|
1622 | 1576 | """Poll custom clusters/attributes for changes."""
|
1623 | 1577 | for node_id in tuple(self._polled_attributes):
|
|
0 commit comments