Skip to content

Commit

Permalink
Fix: The check for incorrect configuration only took effect for a dur…
Browse files Browse the repository at this point in the history
…ation but not for a durration
  • Loading branch information
justinh998 committed Feb 9, 2025
1 parent 9b00290 commit c7ccea4
Showing 1 changed file with 9 additions and 9 deletions.
18 changes: 9 additions & 9 deletions custom_components/average/sensor.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -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
Expand Down

0 comments on commit c7ccea4

Please sign in to comment.