Skip to content

Commit

Permalink
prevent No lesson in the next %s days from spaming
Browse files Browse the repository at this point in the history
  • Loading branch information
JonasJoKuJonas committed Jun 11, 2024
1 parent fcc9219 commit 48f9f26
Showing 1 changed file with 19 additions and 12 deletions.
31 changes: 19 additions & 12 deletions custom_components/webuntis/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -191,6 +191,7 @@ def __init__(
)
self._loged_in = False
self._last_status_request_failed = False
self._no_lessons = False
self.updating = 0
self.issue = False

Expand Down Expand Up @@ -546,13 +547,16 @@ def _next_class(self):
try:
lesson = lesson_list[0]
except IndexError:
_LOGGER.warning(
"Updating the property _next_class of '%s@%s' failed - No lesson in the next %s days",
self.school,
self.username,
DAYS_TO_FUTURE,
)
if not self._no_lessons:
_LOGGER.info(
"Updating the property _next_class of '%s@%s' failed - No lesson in the next %s days",
self.school,
self.username,
DAYS_TO_FUTURE,
)
self._no_lessons = True
return None
self._no_lessons = False

self.next_class_json = self.get_lesson_json(lesson)

Expand Down Expand Up @@ -586,13 +590,16 @@ def _next_lesson_to_wake_up(self):
try:
return sorted(time_list_new)[0].astimezone()
except IndexError:
_LOGGER.warning(
"Updating the property _next_lesson_to_wake_up of '%s@%s' failed - No lesson in the next %s days",
self.school,
self.username,
DAYS_TO_FUTURE,
)
if not self._no_lessons:
_LOGGER.info(
"Updating the property _next_lesson_to_wake_up of '%s@%s' failed - No lesson in the next %s days",
self.school,
self.username,
DAYS_TO_FUTURE,
)
self._no_lessons = True
return None
self._no_lessons = False

def _next_day_json(self):
if self.next_lesson_to_wake_up is None:
Expand Down

0 comments on commit 48f9f26

Please sign in to comment.