Skip to content

Commit 0853520

Browse files
committed
Remove double load_defaults calls.
Improve fallback to load_defaults in SED
1 parent a8daf03 commit 0853520

File tree

2 files changed

+5
-6
lines changed

2 files changed

+5
-6
lines changed

plugwise_usb/nodes/scan.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -167,7 +167,6 @@ async def _load_defaults(self) -> None:
167167
async def _load_from_cache(self) -> bool:
168168
"""Load states from previous cached information. Returns True if successful."""
169169
if not await super()._load_from_cache():
170-
await self._load_defaults()
171170
return False
172171
self._motion_state = MotionState(
173172
state=self._motion_from_cache(),

plugwise_usb/nodes/sed.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -118,10 +118,11 @@ async def load(self) -> bool:
118118
"""Load and activate SED node features."""
119119
if self._loaded:
120120
return True
121-
if self._cache_enabled:
122-
_LOGGER.debug("Load SED node %s from cache", self._node_info.mac)
123-
await self._load_from_cache()
124-
else:
121+
_LOGGER.debug("Load SED node %s from cache", self._node_info.mac)
122+
if await self._load_from_cache():
123+
self._loaded = True
124+
if not self._loaded:
125+
_LOGGER.debug("Load SED node %s defaults", self._node_info.mac)
125126
self._load_defaults()
126127
self._loaded = True
127128
self._features += SED_FEATURES
@@ -176,7 +177,6 @@ async def _load_defaults(self) -> None:
176177
async def _load_from_cache(self) -> bool:
177178
"""Load states from previous cached information. Returns True if successful."""
178179
if not await super()._load_from_cache():
179-
await self._load_defaults()
180180
return False
181181
self._battery_config = BatteryConfig(
182182
awake_duration=self._awake_duration_from_cache(),

0 commit comments

Comments
 (0)