Skip to content

Commit 9e3ad65

Browse files
committed
Correct/improve circle._load_from_cache(()
1 parent ec5839e commit 9e3ad65

File tree

1 file changed

+13
-5
lines changed

1 file changed

+13
-5
lines changed

plugwise_usb/nodes/circle.py

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -847,6 +847,7 @@ async def load(self) -> bool:
847847
async def _load_from_cache(self) -> bool:
848848
"""Load states from previous cached information. Returns True if successful."""
849849
if not await super()._load_from_cache():
850+
_LOGGER.debug("_load_from_cache | super-load failed")
850851
return False
851852

852853
# Calibration settings
@@ -855,25 +856,32 @@ async def _load_from_cache(self) -> bool:
855856
"Node %s failed to load calibration from cache", self._mac_in_str
856857
)
857858
return False
859+
858860
# Energy collection
859-
if await self._energy_log_records_load_from_cache():
861+
if not await self._energy_log_records_load_from_cache():
860862
_LOGGER.warning(
861863
"Node %s failed to load energy_log_records from cache",
862864
self._mac_in_str,
863865
)
866+
return False
867+
864868
# Relay
865-
if await self._relay_load_from_cache():
869+
if not await self._relay_load_from_cache():
866870
_LOGGER.debug(
867-
"Node %s successfully loaded relay state from cache",
871+
"Node %s failed to load relay state from cache",
868872
self._mac_in_str,
869873
)
874+
return False
875+
870876
# Relay init config if feature is enabled
871877
if NodeFeature.RELAY_INIT in self._features:
872-
if await self._relay_init_load_from_cache():
878+
if not await self._relay_init_load_from_cache():
873879
_LOGGER.debug(
874-
"Node %s successfully loaded relay_init state from cache",
880+
"Node %s failed to load relay_init state from cache",
875881
self._mac_in_str,
876882
)
883+
return False
884+
877885
return True
878886

879887
@raise_not_loaded

0 commit comments

Comments
 (0)