Skip to content

Commit 741fb20

Browse files
committed
Additional warnings around unexpected cache behavior
1 parent acd1119 commit 741fb20

File tree

2 files changed

+14
-8
lines changed

2 files changed

+14
-8
lines changed

custom_components/studer_xcom/coordinator.py

+13-7
Original file line numberDiff line numberDiff line change
@@ -441,19 +441,25 @@ async def _async_read_cache(self):
441441
store = await self._store.async_get_data() or {}
442442
self._cache = store.get("cache", {})
443443
else:
444-
_LOGGER.warning(f"Using empty cache; no store available to read persisted cache from")
444+
_LOGGER.warning(f"Using empty cache; no store available to read from")
445445
self._cache = {}
446446

447447

448448
async def _async_persist_cache(self):
449-
if self._store and (datetime.now() - self._cache_last_write).total_seconds() > CACHE_WRITE_PERIOD:
449+
if self._is_temp:
450+
return
451+
452+
if self._store:
453+
if (datetime.now() - self._cache_last_write).total_seconds() > CACHE_WRITE_PERIOD:
450454

451-
_LOGGER.debug(f"Persist cache")
452-
self._cache_last_write = datetime.now()
455+
_LOGGER.debug(f"Persist cache")
456+
self._cache_last_write = datetime.now()
453457

454-
store = await self._store.async_get_data() or {}
455-
store["cache"] = self._cache
456-
await self._store.async_set_data(store)
458+
store = await self._store.async_get_data() or {}
459+
store["cache"] = self._cache
460+
await self._store.async_set_data(store)
461+
else:
462+
_LOGGER.warning(f"Skip persisting cache; no store available to write to")
457463

458464

459465
def _getModified(self, entity: StuderEntityData) -> Any:

custom_components/studer_xcom/manifest.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,5 +10,5 @@
1010
"issue_tracker": "https://github.com/ankohanse/hass-studer-xcom/issues",
1111
"loggers": ["custom_components.studer_xcom"],
1212
"requirements": ["aioxcom>=1.6.1"],
13-
"version": "2024.11.4"
13+
"version": "2024.12.2"
1414
}

0 commit comments

Comments
 (0)