Skip to content

Commit

Permalink
Handle missing payload data. Fixes #40
Browse files Browse the repository at this point in the history
  • Loading branch information
djtimca committed Jun 21, 2022
1 parent 9cadb66 commit fd0d107
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion custom_components/spacex/sensor.py
Original file line number Diff line number Diff line change
Expand Up @@ -556,7 +556,10 @@ def state(self):
self._state = launch_data["rocket"]["name"]

elif self._kind == "spacex_next_launch_payload":
self._state = launch_data["payloads_detail"][0]["name"]
if launch_data["payloads_detail"]:
self._state = launch_data["payloads_detail"][0]["name"]
else:
self._state = ""

elif self._kind == "spacex_latest_launch_mission":
self._state = latest_launch_data["name"]
Expand Down

0 comments on commit fd0d107

Please sign in to comment.