Skip to content

Commit

Permalink
Attempt to fix regression with next_events
Browse files Browse the repository at this point in the history
  • Loading branch information
denysdovhan committed Jul 25, 2024
1 parent 0278f53 commit 9494eaa
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 4 deletions.
2 changes: 1 addition & 1 deletion custom_components/yasno_outages/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ def get_group_schedule(self, city: str, group: str) -> list:

def get_current_event(self, at: datetime.datetime) -> dict | None:
"""Get the current event."""
for event in self.get_events(at, at + datetime.timedelta(hours=1)):
for event in self.get_events(at, at + datetime.timedelta(days=1)):
if event["start"] <= at < event["end"]:
return event
return None
Expand Down
4 changes: 1 addition & 3 deletions custom_components/yasno_outages/coordinator.py
Original file line number Diff line number Diff line change
Expand Up @@ -140,11 +140,9 @@ def next_connectivity(self) -> datetime.date | datetime.datetime | None:
"""Get next connectivity time."""
now = dt_utils.now()
current_event = self.get_event_at(now)
if not current_event:
return None
# If current event is maybe, return the end time
if self._event_to_state(current_event) == STATE_MAYBE:
return current_event.end
return current_event.end if current_event else None
# Otherwise, return the next maybe event's end
event = self._get_next_event_of_type(STATE_MAYBE)
LOGGER.debug("Next connectivity: %s", event)
Expand Down

0 comments on commit 9494eaa

Please sign in to comment.