Skip to content

Commit d75237d

Browse files
committed
Make sure to execute all steps in _load_from_cache()
1 parent a318e56 commit d75237d

File tree

1 file changed

+12
-6
lines changed

1 file changed

+12
-6
lines changed

plugwise_usb/nodes/circle.py

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -850,32 +850,37 @@ async def load(self) -> bool:
850850

851851
async def _load_from_cache(self) -> bool:
852852
"""Load states from previous cached information. Returns True if successful."""
853+
result = True
853854
if not await super()._load_from_cache():
854855
_LOGGER.debug("_load_from_cache | super-load failed")
855-
return False
856+
if result:
857+
result = False
856858

857859
# Calibration settings
858860
if not await self._calibration_load_from_cache():
859861
_LOGGER.debug(
860862
"Node %s failed to load calibration from cache", self._mac_in_str
861863
)
862-
return False
864+
if result:
865+
result = False
863866

864867
# Energy collection
865868
if not await self._energy_log_records_load_from_cache():
866869
_LOGGER.warning(
867870
"Node %s failed to load energy_log_records from cache",
868871
self._mac_in_str,
869872
)
870-
return False
873+
if result:
874+
result = False
871875

872876
# Relay
873877
if not await self._relay_load_from_cache():
874878
_LOGGER.debug(
875879
"Node %s failed to load relay state from cache",
876880
self._mac_in_str,
877881
)
878-
return False
882+
if result:
883+
result = False
879884

880885
# Relay init config if feature is enabled
881886
if NodeFeature.RELAY_INIT in self._features:
@@ -884,9 +889,10 @@ async def _load_from_cache(self) -> bool:
884889
"Node %s failed to load relay_init state from cache",
885890
self._mac_in_str,
886891
)
887-
return False
892+
if result:
893+
result = False
888894

889-
return True
895+
return result
890896

891897
@raise_not_loaded
892898
async def initialize(self) -> bool:

0 commit comments

Comments
 (0)