From c7ccea478c8a8ab0b126e1372d61b7c2056fdc4c Mon Sep 17 00:00:00 2001 From: Justin Hahn Date: Sun, 9 Feb 2025 21:18:52 +0100 Subject: [PATCH] Fix: The check for incorrect configuration only took effect for a duration but not for a durration --- custom_components/average/sensor.py | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/custom_components/average/sensor.py b/custom_components/average/sensor.py index 47d5b19..524223a 100644 --- a/custom_components/average/sensor.py +++ b/custom_components/average/sensor.py @@ -388,15 +388,6 @@ async def _async_update_period(self) -> None: # noqa: PLR0912 'Parsing error: field "end" must be a datetime or a timestamp' ) return - if ( - (end is not None or start is not None) - and self.ignoreundef == 0 - and self.calculatetillnowundef == 1 - ): - _LOGGER.exception( - "Wrong Configuration! You cant set calculate_to_end_undef to 1 when ignore_undef is 0 / not set" - ) - return # Calculate start or end using the duration if self._duration is not None: @@ -411,6 +402,15 @@ async def _async_update_period(self) -> None: # noqa: PLR0912 _LOGGER.debug("Calculation period: start=%s, end=%s", start, end) if start is None or end is None: return + if ( + (end is not None or start is not None) + and self.ignoreundef == 0 + and self.calculatetillnowundef == 1 + ): + _LOGGER.exception( + "Wrong Configuration! You cant set calculate_to_end_undef to 1 when ignore_undef is 0 / not set" + ) + return if start > end: start, end = end, start