Skip to content

Commit

Permalink
Fix #45 to handle missing payload data on latest launch.
Browse files Browse the repository at this point in the history
  • Loading branch information
djtimca committed Jul 8, 2022
1 parent ac9a96d commit 0937f6a
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 @@ -587,7 +587,10 @@ def state(self):
self._state = latest_launch_data["rocket"]["name"]

elif self._kind == "spacex_latest_launch_payload":
self._state = latest_launch_data["payloads_detail"][0]["name"]
if latest_launch_data["payloads_detail"]:
self._state = latest_launch_data["payloads_detail"][0]["name"]
else:
self._state = ""

elif self._kind == "spacex_starman_speed":
self._state = int(starman_data["speed_kph"])
Expand Down

0 comments on commit 0937f6a

Please sign in to comment.