|
51 | 51 |
|
52 | 52 | LOGGER = logging.getLogger(__name__)
|
53 | 53 | INTERVIEW_TASK_LIMIT = 5
|
| 54 | +MAX_POLL_INTERVAL = 600 |
54 | 55 |
|
55 | 56 | # a list of attributes we should always watch on all nodes
|
56 | 57 | DEFAULT_SUBSCRIBE_ATTRIBUTES: set[tuple[int | str, int | str, int | str]] = {
|
@@ -698,6 +699,18 @@ def resubscription_attempted(
|
698 | 699 | if node.available:
|
699 | 700 | node.available = False
|
700 | 701 | self.server.signal_event(EventType.NODE_UPDATED, node)
|
| 702 | + if nextResubscribeIntervalMsec / 1000 > MAX_POLL_INTERVAL: |
| 703 | + # workaround to handle devices that are unplugged |
| 704 | + # from power for a longer period of time |
| 705 | + # cancel subscription and add this node to our node polling job |
| 706 | + # TODO: fix this once OerationalNodeDiscovery is available: |
| 707 | + # https://github.com/project-chip/connectedhomeip/pull/26718 |
| 708 | + sub.Shutdown() |
| 709 | + self._subscriptions.pop(node_id) |
| 710 | + assert self.server.loop |
| 711 | + self.server.loop.create_task( |
| 712 | + self._check_interview_and_subscription(node_id, MAX_POLL_INTERVAL) |
| 713 | + ) |
701 | 714 |
|
702 | 715 | def resubscription_succeeded(
|
703 | 716 | transaction: Attribute.SubscriptionTransaction,
|
@@ -757,8 +770,9 @@ def reschedule() -> None:
|
757 | 770 | asyncio.create_task,
|
758 | 771 | self._check_interview_and_subscription(
|
759 | 772 | node_id,
|
760 |
| - # increase interval at each attempt with maximum of 10 minutes |
761 |
| - min(reschedule_interval + 10, 600), |
| 773 | + # increase interval at each attempt with maximum of |
| 774 | + # MAX_POLL_INTERVAL seconds (= 10 minutes) |
| 775 | + min(reschedule_interval + 10, MAX_POLL_INTERVAL), |
762 | 776 | ),
|
763 | 777 | )
|
764 | 778 |
|
@@ -794,6 +808,8 @@ def reschedule() -> None:
|
794 | 808 | "will retry later in the background.",
|
795 | 809 | node_id,
|
796 | 810 | )
|
| 811 | + # TODO: fix this once OperationalNodeDiscovery is available: |
| 812 | + # https://github.com/project-chip/connectedhomeip/pull/26718 |
797 | 813 | reschedule()
|
798 | 814 |
|
799 | 815 | @staticmethod
|
@@ -845,7 +861,7 @@ async def _resolve_node(self, node_id: int, retries: int = 3) -> None:
|
845 | 861 | raise RuntimeError("Device Controller not initialized.")
|
846 | 862 | try:
|
847 | 863 | async with node_lock, self._resolve_lock:
|
848 |
| - LOGGER.info("Attempting to resolve node %s...", node_id) |
| 864 | + LOGGER.debug("Attempting to resolve node %s...", node_id) |
849 | 865 | await self._call_sdk(
|
850 | 866 | self.chip_controller.ResolveNode,
|
851 | 867 | nodeid=node_id,
|
|
0 commit comments