Skip to content

Commit

Permalink
Update sensor.py
Browse files Browse the repository at this point in the history
sort results for inpakken-sensor
  • Loading branch information
reiniertc authored Jun 13, 2024
1 parent dedd43f commit 3c2e7f1
Showing 1 changed file with 20 additions and 2 deletions.
22 changes: 20 additions & 2 deletions custom_components/magister_rooster/sensor.py
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,8 @@ def update(self):
super().update()
if self._events_tomorrow:
filtered_summaries = set(event[2] for event in self._events_tomorrow)
self._state = ", ".join(filtered_summaries)
sorted_summaries = sorted(filtered_summaries, key=lambda s: s[0]) # Sorteren op eerste karakter
self._state = ", ".join(sorted_summaries)
else:
self._state = None

Expand Down Expand Up @@ -160,4 +161,21 @@ def name(self):

def update(self):
super().update()
if
if self._events_today:
first_event = min(self._events_today, key=lambda event: event[0])
self._state = first_event[0].strftime("%H:%M")
else:
self._state = None

class EindtijdVandaagSensor(MagisterRoosterBaseSensor):
@property
def name(self):
return f"{self._name} Eindtijd vandaag"

def update(self):
super().update()
if self._events_today:
last_event = max(self._events_today, key=lambda event: event[1])
self._state = last_event[1].strftime("%H:%M")
else:
self._state = None

0 comments on commit 3c2e7f1

Please sign in to comment.