From 4d90bb89b5b71e273ccc2c83b9f73ca889f86d63 Mon Sep 17 00:00:00 2001 From: Tim Empringham Date: Mon, 25 Jan 2021 15:28:51 -0500 Subject: [PATCH] Fixed NoneType error on next rocket. Closes #25. --- custom_components/spacex/sensor.py | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/custom_components/spacex/sensor.py b/custom_components/spacex/sensor.py index fd6e354..f7fc601 100644 --- a/custom_components/spacex/sensor.py +++ b/custom_components/spacex/sensor.py @@ -327,13 +327,14 @@ def device_state_attributes(self): elif self._kind == "spacex_next_launch_rocket": core_counter = 1 for this_core in launch_data["cores_detail"]: - self.attrs["core_" + str(core_counter) + "_serial"] = this_core.get( - "details",{}).get("serial") + if this_core.get("details"): + self.attrs["core_" + str(core_counter) + "_serial"] = this_core["details"].get("serial") + self.attrs["core_" + str(core_counter) + "_block"] = this_core["details"].get("block") + self.attrs["core_" + str(core_counter) + "_flight"] = this_core.get( "flight" ) - self.attrs["core_" + str(core_counter) + "_block"] = this_core.get( - "details",{}).get("block") + self.attrs[ "core_" + str(core_counter) + "_landing_intent" ] = this_core.get("landing_attempt")