diff --git a/homeassistant/components/nmbs/sensor.py b/homeassistant/components/nmbs/sensor.py index c6dd7b963ff..23b8bbea46b 100644 --- a/homeassistant/components/nmbs/sensor.py +++ b/homeassistant/components/nmbs/sensor.py @@ -152,6 +152,10 @@ class NMBSLiveBoard(Entity): def update(self): """Set the state equal to the next departure.""" liveboard = self._api_client.get_liveboard(self._station) + + if liveboard is None or not liveboard["departures"]: + return + next_departure = liveboard["departures"]["departure"][0] self._attrs = next_departure @@ -266,6 +270,9 @@ class NMBSSensor(Entity): self._station_from, self._station_to ) + if connections is None or not connections["connection"]: + return + if int(connections["connection"][0]["departure"]["left"]) > 0: next_connection = connections["connection"][1] else: