Skip to content

Commit 1498e45

Browse files
committed
CR: Fix typo in docstring
CR: Fix incorrect bitwise operator for dirty flag CR: Fix boolean cache retrieval logic
1 parent 7eb1be7 commit 1498e45

File tree

3 files changed

+6
-6
lines changed

3 files changed

+6
-6
lines changed

plugwise_usb/nodes/node.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -659,9 +659,9 @@ def _get_cache_as_bool(self, setting: str) -> bool | None:
659659
"""Retrieve bool of specified setting from cache memory."""
660660
if not self._cache_enabled:
661661
return None
662-
if self._node_cache.get_state(setting) == "True":
663-
return True
664-
return False
662+
if (bool_value := self._node_cache.get_state(setting)) is None:
663+
return None
664+
return bool_value == "True"
665665

666666
def _get_cache_as_datetime(self, setting: str) -> datetime | None:
667667
"""Retrieve value of specified setting from cache memory and return it as datetime object."""

plugwise_usb/nodes/scan.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -164,7 +164,7 @@ async def _load_from_cache(self) -> bool:
164164
if (sensitivity_level := self._sensitivity_level_from_cache()) is None:
165165
dirty = True
166166
sensitivity_level = DEFAULT_SENSITIVITY
167-
dirty &= self._motion_config_dirty_from_cache()
167+
dirty |= self._motion_config_dirty_from_cache()
168168

169169
self._motion_config = MotionConfig(
170170
daylight_mode=daylight_mode,

plugwise_usb/nodes/sed.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -161,7 +161,7 @@ async def _load_from_cache(self) -> bool:
161161
if (sleep_duration := self._sleep_duration_from_cache()) is None:
162162
dirty = True
163163
sleep_duration = SED_DEFAULT_SLEEP_DURATION
164-
dirty &= self._sed_config_dirty_from_cache()
164+
dirty |= self._sed_config_dirty_from_cache()
165165
self._battery_config = BatteryConfig(
166166
awake_duration=awake_duration,
167167
clock_interval=clock_interval,
@@ -331,7 +331,7 @@ async def set_sleep_duration(self, minutes: int) -> bool:
331331
# region Properties
332332
@property
333333
def dirty(self) -> int:
334-
"""Battry configuration dirty flag."""
334+
"""Battery configuration dirty flag."""
335335
return self._battery_config.dirty
336336

337337
@property

0 commit comments

Comments
 (0)