Handle missing next train from NS (#31626)
* Handle missing next train * Ignore next attribute insteadpull/32838/head
parent
83a79a434c
commit
658c48b237
|
@ -191,10 +191,15 @@ class NSDepartureSensor(Entity):
|
||||||
attributes["arrival_delay"] = True
|
attributes["arrival_delay"] = True
|
||||||
|
|
||||||
# Next attributes
|
# Next attributes
|
||||||
if self._trips[1].departure_time_actual is not None:
|
if len(self._trips) > 1:
|
||||||
attributes["next"] = self._trips[1].departure_time_actual.strftime("%H:%M")
|
if self._trips[1].departure_time_actual is not None:
|
||||||
elif self._trips[1].departure_time_planned is not None:
|
attributes["next"] = self._trips[1].departure_time_actual.strftime(
|
||||||
attributes["next"] = self._trips[1].departure_time_planned.strftime("%H:%M")
|
"%H:%M"
|
||||||
|
)
|
||||||
|
elif self._trips[1].departure_time_planned is not None:
|
||||||
|
attributes["next"] = self._trips[1].departure_time_planned.strftime(
|
||||||
|
"%H:%M"
|
||||||
|
)
|
||||||
|
|
||||||
return attributes
|
return attributes
|
||||||
|
|
||||||
|
@ -223,7 +228,7 @@ class NSDepartureSensor(Entity):
|
||||||
|
|
||||||
try:
|
try:
|
||||||
self._trips = self._nsapi.get_trips(
|
self._trips = self._nsapi.get_trips(
|
||||||
trip_time, self._departure, self._via, self._heading, True, 0, 2,
|
trip_time, self._departure, self._via, self._heading, True, 0, 2
|
||||||
)
|
)
|
||||||
if self._trips:
|
if self._trips:
|
||||||
if self._trips[0].departure_time_actual is None:
|
if self._trips[0].departure_time_actual is None:
|
||||||
|
|
Loading…
Reference in New Issue