SpaceX Next Launch / Starman Integration

I had been using the REST integration to import SpaceX data into my system for launches and Starman data, but I was getting very frustrated with the stability of the REST connection to the SpaceX API - the integration regularly failed to connect and then returned null values. My automations to alert me of upcoming launches etc were going off far too often as the values pinged back and forth. (Followed the instructions at SpaceX sensors: Starman and next rocket launch to get that working).

So I have written a custom_component which pulls the SpaceX data into a set of sensors:

  • Next Launch Day
  • Next Launch Time
  • Next Launch Mission
  • Next Launch Payload
  • Next Launch Rocket
  • Next Launch Site
  • Next Launch Alert (Binary Sensor) - Launch in the next 24 hours
  • Next Launch Alert (Binary Sensor) - Launch in the next 20 minutes
  • Starman Current Speed
  • Starman Current Distance from Earth

Rather than having to use input_booleans and date/time math in HA, I’ve built the integration to provide binary_sensors which will turn on when the next launch is in the next 24 hours and when the next launch is in the next 20 minutes so you can create alerts or automatons off that state change.

You can find the integration at

Installs through HACS (custom repository) or manual.

Would love your feedback - first integration I have posted this way!

Also added as a fun infobox in Lovelace:

Screenshot from 2020-08-31 13-38-50

Markup for the card to give you the above is:

type: vertical-stack
title: SpaceX
  - type: markdown
    content: >-
      <table ><tr><td> {% if
      states.sensor.spacex_next_launch_mission.attributes.mission_patch != "" %}
        <img src="{{states.sensor.spacex_next_launch_mission.attributes.mission_patch}}" width=250>
      {% endif %}</td> <td>{{
      states.sensor.spacex_next_launch_mission.attributes.details }}
    title: Next Launch
  - entities:
      - entity: sensor.spacex_next_launch_rocket
        name: Rocket
      - entity: sensor.spacex_next_launch_mission
        name: Mission
      - entity: binary_sensor.spacex_next_launch_confirmed
        name: Confirmed
      - entity: sensor.spacex_next_launch_day
        name: Day
      - entity: sensor.spacex_next_launch_time
        name: Time
      - entity: sensor.spacex_next_launch_site
        name: Site
    type: entities
  - type: entities
    title: Starman Tesla Roadster
      - entity: sensor.spacex_starman_speed
      - entity: sensor.spacex_starman_distance
    show_header_toggle: false


After installing integration it hangs at installing. My computer wont startup. cant access via ssh.Computer completely broken.

If I connect a monitor it wont get pass Intel nuc boot page.

What version of HA are you running?

Latest. Seems my SSD died.

Doh! Sorry it had to coincide with installing!

Happened when installing integration. SSD is one week old. So a bit strange.

So the Integration was not the problem… but your SSD ?

Dont know.

Installed it and use your markup card. Missed some sensors:


Great, then it is a faulty SSD on my part. Only a week old.

You’re missing those sensors? Any errors in your logs? How many devices do you see under the SpaceX integration in configuration?

Also icons are not ok.

      - entity: sensor.spacex_next_launch_day
        name: Day
      - entity: sensor.spacex_next_launch_time
        name: Time
      - entity: sensor.spacex_next_launch_site
        name: Site

All 3 have a eye as icon

no errors at all.

These sensors I have in develop tool:


state: 1598829480


mission_name: SAOCOM 1B, GNOMES-1, Tyvak-0172
site_id: ccafs_slc_40
site_name: CCAFS SLC 40
site_name_long: Cape Canaveral Air Force Station Space Launch Complex 40

rocket_id: falcon9
rocket_name: Falcon 9
rocket_type: FT
    - core_serial: B1059
      flight: 4
      block: 5
      gridfins: true
      legs: true
      reused: true
      land_success: null
      landing_intent: true
      landing_type: RTLS
      landing_vehicle: LZ-1
  block: 5
    - payload_id: SAOCOM 1B
      norad_id: []
      reused: false
        - CONAE
      nationality: Argentina
      manufacturer: null
      payload_type: Satellite
      payload_mass_kg: 1600
      payload_mass_lbs: 3527.396
      orbit: SSO
        reference_system: geocentric
        regime: sun-synchronous
        longitude: null
        semi_major_axis_km: null
        eccentricity: null
        periapsis_km: null
        apoapsis_km: null
        inclination_deg: null
        period_min: null
        lifespan_years: null
        epoch: null
        mean_motion: null
        raan: null
        arg_of_pericenter: null
        mean_anomaly: null
  reused: null
  recovery_attempt: true
  recovered: null

details: SpaceX's Falcon 9 will launch the second of the two satellite SAOCOM 1 satellites into a sun-synchronous polar orbit from SLC-40, Cape Canaveral AFS. SAOCOM 1B is a synthetic aperture radar Earth observation satellite to support disaster management. The SAOCOM spacecraft are operated by CONAE, the Argentinian National Space Activities Commission, and are built by INVAP. This mission is also expected to include rideshare payloads Sequoia, and GNOMES-1. This will be the first polar launch from the Space Coast in 60 years. The launch azimuth will be southward and the booster will land at LZ-1.
friendly_name: SpaceX

state: 31.08.2020	
attrubutes: friendly_name: Next Startdatum

state: CCAFS SLC 40	
attrubutes: : friendly_name: Location

state: 01:18	
attrubutes: unit_of_measurement: h, friendly_name: Start

state: SAOCOM 1B, GNOMES-1, Tyvak-0172	
attrubutes: friendly_name: Mission

state: Falcon 9	
attrubutes: friendly_name: Next Roket Ship

That is a very strange output - looks like you’re getting the full output from the Spacex API, not anything from the integration that I wrote.

In your Configuration -> Integrations page do you see the SpaceX integration as being installed?

Does it show any devices? Any entities?

If it is not showing in the Configuration -> Integrations page it doesn’t sound like you have my integration actually installed. This integration uses the UI / Config Flow to install so after installing through HACS you need to reboot, then go to the integration page to add it.

Forgot the step of integration.

I see 2 errors while adding the integration:

2020-08-31 21:36:34 ERROR (MainThread) [homeassistant] Error doing job: Unclosed client session
2020-08-31 21:36:34 ERROR (MainThread) [homeassistant] Error doing job: Unclosed connector

HA 0.114.3
Debian 64Bit

Restart Home Assistant and let me know if it is still there… it should be closing the connection, but I have had challenges with other integrations the same way. Seemed to go away with a restart.

When reboot HA both errors are not coming back!

I’m not sure. But seems that the Add-On have negative result on automations here.

Motion sensors and turning on lights give problems since I installed the SpaceX part.
Now removed it and see if the automation problem is gone …