Skip to content

Commit 4d90bb8

Browse files
committed
Fixed NoneType error on next rocket. Closes #25.
1 parent f2e53b5 commit 4d90bb8

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

custom_components/spacex/sensor.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -327,13 +327,14 @@ def device_state_attributes(self):
327327
elif self._kind == "spacex_next_launch_rocket":
328328
core_counter = 1
329329
for this_core in launch_data["cores_detail"]:
330-
self.attrs["core_" + str(core_counter) + "_serial"] = this_core.get(
331-
"details",{}).get("serial")
330+
if this_core.get("details"):
331+
self.attrs["core_" + str(core_counter) + "_serial"] = this_core["details"].get("serial")
332+
self.attrs["core_" + str(core_counter) + "_block"] = this_core["details"].get("block")
333+
332334
self.attrs["core_" + str(core_counter) + "_flight"] = this_core.get(
333335
"flight"
334336
)
335-
self.attrs["core_" + str(core_counter) + "_block"] = this_core.get(
336-
"details",{}).get("block")
337+
337338
self.attrs[
338339
"core_" + str(core_counter) + "_landing_intent"
339340
] = this_core.get("landing_attempt")

0 commit comments

Comments
 (0)