Rocket launch warning



How would you alert the next rocket launch based on the new component ?

I’ve tried this in the template sand box:


next: {{ states(“sensor.next_launch”) }}
next: Falcon 9 Block 5 | SpX CRS-16


at: {{ state_attr(‘sensor.next_launch’, ‘launch_time’) }}
at: December 4, 2018 18:38:51 UTC

Convert to timestamp so we can alert 1 hr in advance:

alert at: {{ as_timestamp(state_attr(‘sensor.next_launch’, ‘launch_time’)) }}
alert at: None

No go. The best solution would be if the component could give us a timestamp, but can someone help me convert the date?


I think that i found a solution.
alert at: {{ as_timestamp(strptime(state_attr('sensor.next_launch', 'launch_time'), '%B %d, %Y %H:%M:%S %Z')) }}


Nice, and then we can start the stream on our TVs.


Thanks. This is what I ended up with:

  • id: launchalert
    alias: ‘Notify 1 hr before next rocket launch’
    • platform: time
      minutes: ‘/60’
      seconds: 00
    • condition: template
      value_template: >-
      {%- if (as_timestamp(now()) > (as_timestamp(strptime(states.sensor.next_launch.attributes.launch_time, ‘%B %d, %Y %H:%M:%S %Z’)) - 3600)) and ( as_timestamp( strptime(states.sensor.next_launch.attributes.launch_time, ‘%B %d, %Y %H:%M:%S %Z’) ) ) - ( as_timestamp( now() ) > 0 ) -%}
      {%- endif -%}
    • service_template: notify.telegramchannel
      title: “Oppskytning om under en time”
      message: “Oppskytning av {{ }} kl {{ states.sensor.next_launch.attributes.launch_time }}. Se {{ }}.”

Will tune it a bit. Timezone adjustments i.e.


It would be nice to have also a lovelace card with a countdown of the launch. maybe next week I’ll look into how to do it


Hey @lars1 I am using @jones custom component SpaceX sensors: Starman and next rocket launch for the SpaceX launches, but I can’t see the to get the notifications working for me from his script.

I have seen your setup, but I am not too good with templating. I have tried to modify it to matches the sensor and time format, but I can’t quite seem to get it right. Don’t suppose if you have a spare moment, you would might seeing where I might have gone wrong or something.

value_template: >-
{%- if (as_timestamp(now()) > (as_timestamp(strptime(states.sensor.spacex.state, ‘%M:%S’)) - 3600)) and ( as_timestamp( strptime(states.sensor.spacex.state, ‘%M:%S’) ) ) - ( as_timestamp( now() ) > 0 ) -%}
{%- endif -%}

It just use’s a time rather than date and year and month

although the main sensor uses this for it’s time.


Many thanks in advance if you can help out.


From what i can see, sensor.spacex is a UNIX time. Since as_timestamp(now()) will give you another UNIX time, you can simply compare these two values.
Try to do something like this

{% if as_timestamp(now()) > states(‘sensor.spacex’) - 3600 %}
{% else %}
{% endif %}


Awesome, thank you very much @marco9446 Will have a play around :slight_smile: