Skip to content

Commit

Permalink
Fixed bug
Browse files Browse the repository at this point in the history
fixed list out of range error
  • Loading branch information
JonasJoKuJonas committed Oct 17, 2022
1 parent 142f903 commit f9e9088
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions custom_components/webuntis/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -283,17 +283,21 @@ def _next_lesson_to_wake_up(self):
if lesson.code != "cancelled":
time_list.append(lesson.start)

day = now
time_list_new = []
for time in sorted(time_list):
if time < now:
now = now.replace(
if time < day:
day = now.replace(
hour=0, minute=0, second=0, microsecond=0
) + timedelta(days=1)
continue
else:
time_list_new.append(time)

return sorted(time_list_new)[0].astimezone()
if len(time_list_new) > 1:
return sorted(time_list_new)[0].astimezone()
else:
return None


class WebUntisEntity(Entity):
Expand Down

0 comments on commit f9e9088

Please sign in to comment.