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.
- entity: sensor.spacex_next_launch_day
name: Day
- entity: sensor.spacex_next_launch_time
name: Time
- entity: sensor.spacex_next_launch_site
name: Site
sensor.spacex
state: 1598829480
attributes:
mission_name: SAOCOM 1B, GNOMES-1, Tyvak-0172
launch_site:
site_id: ccafs_slc_40
site_name: CCAFS SLC 40
site_name_long: Cape Canaveral Air Force Station Space Launch Complex 40
rocket:
rocket_id: falcon9
rocket_name: Falcon 9
rocket_type: FT
first_stage:
cores:
- 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
second_stage:
block: 5
payloads:
- payload_id: SAOCOM 1B
norad_id: []
reused: false
customers:
- CONAE
nationality: Argentina
manufacturer: null
payload_type: Satellite
payload_mass_kg: 1600
payload_mass_lbs: 3527.396
orbit: SSO
orbit_params:
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
fairings:
reused: null
recovery_attempt: true
recovered: null
ship: GOMSCHIEF
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
sensor.spacex_next_launch_day
state: 31.08.2020
attrubutes: friendly_name: Next Startdatum
sensor.spacex_next_launch_site
state: CCAFS SLC 40
attrubutes: : friendly_name: Location
sensor.spacex_next_launch_time
state: 01:18
attrubutes: unit_of_measurement: h, friendly_name: Start
sensor.spacex_next_mission_name
state: SAOCOM 1B, GNOMES-1, Tyvak-0172
attrubutes: friendly_name: Mission
sensor.spacex_next_rocket
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.
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.