From 13dee0f028789d0fe262155d800153dd3b05bc38 Mon Sep 17 00:00:00 2001 From: Marius <33354141+Mariusthvdb@users.noreply.github.com> Date: Mon, 3 May 2021 17:06:46 +0200 Subject: [PATCH] Mitigate NMBS key errors (#50026) on Liveboard and connections as documented in issue #48824 --- homeassistant/components/nmbs/sensor.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/homeassistant/components/nmbs/sensor.py b/homeassistant/components/nmbs/sensor.py index 32e4fd87e29..58ad547eaec 100644 --- a/homeassistant/components/nmbs/sensor.py +++ b/homeassistant/components/nmbs/sensor.py @@ -152,7 +152,7 @@ class NMBSLiveBoard(SensorEntity): """Set the state equal to the next departure.""" 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 next_departure = liveboard["departures"]["departure"][0] @@ -269,7 +269,7 @@ class NMBSSensor(SensorEntity): self._station_from, self._station_to ) - if connections is None or not connections["connection"]: + if connections is None or not connections.get("connection"): return if int(connections["connection"][0]["departure"]["left"]) > 0: