mirror of
https://github.com/home-assistant/core.git
synced 2025-07-16 09:47:13 +00:00
Mitigate NMBS key errors (#50026)
on Liveboard and connections as documented in issue #48824
This commit is contained in:
parent
efb1bb08a4
commit
13dee0f028
@ -152,7 +152,7 @@ class NMBSLiveBoard(SensorEntity):
|
|||||||
"""Set the state equal to the next departure."""
|
"""Set the state equal to the next departure."""
|
||||||
liveboard = self._api_client.get_liveboard(self._station)
|
liveboard = self._api_client.get_liveboard(self._station)
|
||||||
|
|
||||||
if liveboard is None or not liveboard["departures"]:
|
if liveboard is None or not liveboard.get("departures"):
|
||||||
return
|
return
|
||||||
|
|
||||||
next_departure = liveboard["departures"]["departure"][0]
|
next_departure = liveboard["departures"]["departure"][0]
|
||||||
@ -269,7 +269,7 @@ class NMBSSensor(SensorEntity):
|
|||||||
self._station_from, self._station_to
|
self._station_from, self._station_to
|
||||||
)
|
)
|
||||||
|
|
||||||
if connections is None or not connections["connection"]:
|
if connections is None or not connections.get("connection"):
|
||||||
return
|
return
|
||||||
|
|
||||||
if int(connections["connection"][0]["departure"]["left"]) > 0:
|
if int(connections["connection"][0]["departure"]["left"]) > 0:
|
||||||
|
Loading…
x
Reference in New Issue
Block a user