From c2174c9fd8a700aae39cefb27651f6ebe6104e77 Mon Sep 17 00:00:00 2001 From: Marc Dirix Date: Sat, 21 Jun 2025 10:15:28 +0200 Subject: [PATCH 1/5] ignore appdata_store folder --- .gitignore | 1 + 1 file changed, 1 insertion(+) diff --git a/.gitignore b/.gitignore index 6d2dd5d23..8dad5e02e 100644 --- a/.gitignore +++ b/.gitignore @@ -17,3 +17,4 @@ fixtures/* *.sedbck tmp .cache +appdata_folder From 9b9c665effd1b7ad1f2cadedb9aa0e6e1f120d77 Mon Sep 17 00:00:00 2001 From: Marc Dirix Date: Sat, 21 Jun 2025 10:49:29 +0200 Subject: [PATCH 2/5] reduce complexity by splitting full and quick version of registration collection --- plugwise_usb/network/registry.py | 69 +++++++++++++++++++------------- 1 file changed, 41 insertions(+), 28 deletions(-) diff --git a/plugwise_usb/network/registry.py b/plugwise_usb/network/registry.py index 237986480..67bdd1138 100644 --- a/plugwise_usb/network/registry.py +++ b/plugwise_usb/network/registry.py @@ -108,7 +108,7 @@ async def start(self) -> None: if self._cache_enabled: await self.restore_network_cache() await self.load_registry_from_cache() - await self.update_missing_registrations(quick=True) + await self.update_missing_registrations_quick() async def restore_network_cache(self) -> None: """Restore previously saved cached network and node information.""" @@ -179,10 +179,10 @@ def update_network_registration( if self._network_cache is not None: self._network_cache.update_registration(address, mac, node_type) - async def update_missing_registrations(self, quick: bool = False) -> None: # noqa: PLR0912 - """Retrieve all unknown network registrations from network controller.""" + async def update_missing_registrations_full(self) -> None: + """Full retrieval of all unknown network registrations from network controller.""" for address in range(0, 64): - if self._registry.get(address) is not None and not quick: + if self._registry.get(address) is not None: mac, _ = self._registry[address] if mac == "": self._first_free_address = min(self._first_free_address, address) @@ -194,37 +194,50 @@ async def update_missing_registrations(self, quick: bool = False) -> None: # no self._first_free_address = min( self._first_free_address, nextaddress ) - if quick: - break _LOGGER.debug( "Network registration at address %s is %s", str(nextaddress), "'empty'" if mac == "" else f"set to {mac}", ) self.update_network_registration(nextaddress, mac, None) - await sleep(0.1) - if not quick: - await sleep(10) - if quick: - if self._registration_task is None or self._registration_task.done(): - self._registration_task = create_task( - self.update_missing_registrations(quick=False) + await sleep(10) + _LOGGER.debug("Full network registration finished") + self._scan_completed = True + if self._cache_enabled: + _LOGGER.debug("Full network registration finished, save to cache") + await self.save_registry_to_cache() + _LOGGER.debug("Full network registration finished, post") + _LOGGER.info("Full network discovery completed") + if self._full_scan_finished is not None: + await self._full_scan_finished() + self._full_scan_finished = None + + async def update_missing_registrations_quick(self) -> None: + """Quick retrieval of all unknown network registrations from network controller.""" + for address in range(0, 64): + registration = await self.retrieve_network_registration(address, False) + if registration is not None: + nextaddress, mac = registration + if mac == "": + self._first_free_address = min( + self._first_free_address, nextaddress + ) + break + _LOGGER.debug( + "Network registration at address %s is %s", + str(nextaddress), + "'empty'" if mac == "" else f"set to {mac}", ) - if self._quick_scan_finished is not None: - await self._quick_scan_finished() - self._quick_scan_finished = None - _LOGGER.info("Quick network registration discovery finished") - else: - _LOGGER.debug("Full network registration finished") - self._scan_completed = True - if self._cache_enabled: - _LOGGER.debug("Full network registration finished, save to cache") - await self.save_registry_to_cache() - _LOGGER.debug("Full network registration finished, post") - _LOGGER.info("Full network discovery completed") - if self._full_scan_finished is not None: - await self._full_scan_finished() - self._full_scan_finished = None + self.update_network_registration(nextaddress, mac, None) + await sleep(0.1) + if self._registration_task is None or self._registration_task.done(): + self._registration_task = create_task( + self.update_missing_registrations_full() + ) + if self._quick_scan_finished is not None: + await self._quick_scan_finished() + self._quick_scan_finished = None + _LOGGER.info("Quick network registration discovery finished") def update_node_registration(self, mac: str) -> int: """Register (re)joined node to Plugwise network and return network address.""" From ece7d4f29f9693544809b3ce2b4660b185769a40 Mon Sep 17 00:00:00 2001 From: Marc Dirix Date: Sat, 21 Jun 2025 10:53:14 +0200 Subject: [PATCH 3/5] update changelog --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 03578c980..f952f3d11 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,7 @@ - PR [#261](https://github.com/plugwise/python-plugwise-usb/pull/261): Sense: bugfix parsing of humidity value as an unsigned int - PR #263 Maintenance chores and re-instatement of ruff, deprecate pre-commit cloud runs (just leveraging renovate) - PR #264 Maintenance chores Rework Github Actions workflow +- PR [#269](https://github.com/plugwise/python-plugwise-usb/pull/269) Implementation of ruff fixes ## v0.44.3 - 2025-06-12 From a96f239d662957f1fca7e895ab0ce18186799fde Mon Sep 17 00:00:00 2001 From: Marc Dirix Date: Sat, 21 Jun 2025 10:59:22 +0200 Subject: [PATCH 4/5] add PR271 to changelog --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index f952f3d11..4ead5b28c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,7 @@ - PR #263 Maintenance chores and re-instatement of ruff, deprecate pre-commit cloud runs (just leveraging renovate) - PR #264 Maintenance chores Rework Github Actions workflow - PR [#269](https://github.com/plugwise/python-plugwise-usb/pull/269) Implementation of ruff fixes +- PR [#271](https://github.com/plugwise/python-plugwise-usb/pull/271) Ruff fix: split update_missing_restrations in quick and full version ## v0.44.3 - 2025-06-12 From 51434d960412b6de9647d96712b46ce4f5e61487 Mon Sep 17 00:00:00 2001 From: Marc Dirix Date: Sat, 21 Jun 2025 11:12:07 +0200 Subject: [PATCH 5/5] fix type in changelog --- CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 4ead5b28c..f56938429 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,7 +6,7 @@ - PR #263 Maintenance chores and re-instatement of ruff, deprecate pre-commit cloud runs (just leveraging renovate) - PR #264 Maintenance chores Rework Github Actions workflow - PR [#269](https://github.com/plugwise/python-plugwise-usb/pull/269) Implementation of ruff fixes -- PR [#271](https://github.com/plugwise/python-plugwise-usb/pull/271) Ruff fix: split update_missing_restrations in quick and full version +- PR [#271](https://github.com/plugwise/python-plugwise-usb/pull/271) Ruff fix: split update_missing_registrations in quick and full version ## v0.44.3 - 2025-06-12