From f950aa3ca75e94aacc29d09c1a316f10b1535ab9 Mon Sep 17 00:00:00 2001 From: Dmitry Mamontov Date: Wed, 20 Apr 2022 15:50:07 +0300 Subject: [PATCH] Fix save empty devices --- custom_components/miwifi/manifest.json | 2 +- custom_components/miwifi/updater.py | 6 +++++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/custom_components/miwifi/manifest.json b/custom_components/miwifi/manifest.json index 187b546..d1f7acd 100644 --- a/custom_components/miwifi/manifest.json +++ b/custom_components/miwifi/manifest.json @@ -1,7 +1,7 @@ { "domain": "miwifi", "name": "MiWiFi", - "version": "2.4.3", + "version": "2.4.4", "documentation": "https://github.com/dmamontov/hass-miwifi/blob/main/README.md", "issue_tracker": "https://github.com/dmamontov/hass-miwifi/issues", "config_flow": true, diff --git a/custom_components/miwifi/updater.py b/custom_components/miwifi/updater.py index 54f7e12..b8f967a 100644 --- a/custom_components/miwifi/updater.py +++ b/custom_components/miwifi/updater.py @@ -1006,7 +1006,11 @@ async def _async_load_devices(self) -> dict | None: async def _async_save_devices(self) -> None: """Async save devices to Store""" - if self._store is None or (self.is_repeater and not self.is_force_load): + if ( + self._store is None + or (self.is_repeater and not self.is_force_load) + or len(self.devices) == 0 + ): return await self._store.async_save(self.devices)