Skip to content

Commit 9a59910

Browse files
committed
further CR fixes
1 parent e4b4fb2 commit 9a59910

File tree

1 file changed

+16
-3
lines changed

1 file changed

+16
-3
lines changed

plugwise_usb/nodes/sense.py

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -341,6 +341,11 @@ def temperature_direction(self) -> bool:
341341
return self._hysteresis_config.temperature_direction
342342
return DEFAULT_SENSE_HYSTERESIS_TEMPERATURE_DIRECTION
343343

344+
@property
345+
def dirty(self) -> bool:
346+
"""Sense hysteresis configuration dirty flag."""
347+
return self._hysteresis_config.dirty
348+
344349
# end region
345350

346351
# region Configuration actions
@@ -634,9 +639,17 @@ async def _run_awake_tasks(self) -> None:
634639
self._configure_sense_humidity_task(),
635640
self._configure_sense_temperature_task(),
636641
)
637-
if not all(configure_result):
642+
if all(configure_result):
638643
self._hysteresis_config = replace(self._hysteresis_config, dirty=False)
639644
await self._sense_configure_update()
645+
else:
646+
_LOGGER.warning(
647+
"Sense hysteresis configuration partially failed for %s "
648+
"(humidity=%s, temperature=%s); will retry on next wake.",
649+
self.name,
650+
configure_result[0],
651+
configure_result[1],
652+
)
640653

641654
async def _configure_sense_humidity_task(self) -> bool:
642655
"""Configure Sense humidity hysteresis device settings. Returns True if successful."""
@@ -648,7 +661,7 @@ async def _configure_sense_humidity_task(self) -> bool:
648661
if self.humidity_enabled:
649662
if self.humidity_lower_bound > self.humidity_upper_bound:
650663
raise ValueError(
651-
"Invalid humidity lower bound {self.humidity_lower_bound}. It must be equal or below the upper bound {self.humidity_upper_bound}."
664+
f"Invalid humidity lower bound {self.humidity_lower_bound}. It must be equal or below the upper bound {self.humidity_upper_bound}."
652665
)
653666
humidity_lower_bound = int(
654667
(self.humidity_lower_bound + SENSE_HUMIDITY_OFFSET)
@@ -702,7 +715,7 @@ async def _configure_sense_temperature_task(self) -> bool:
702715
if self.temperature_enabled:
703716
if self.temperature_lower_bound > self.temperature_upper_bound:
704717
raise ValueError(
705-
"Invalid temperature lower bound {self.temperature_lower_bound}. It must be equal or below the upper bound {self.temperature_upper_bound}."
718+
f"Invalid temperature lower bound {self.temperature_lower_bound}. It must be equal or below the upper bound {self.temperature_upper_bound}."
706719
)
707720
temperature_lower_bound = int(
708721
(self.temperature_lower_bound + SENSE_TEMPERATURE_OFFSET)

0 commit comments

Comments
 (0)