SpaceX sensors: Starman and next rocket launch


#43

From my understanding you would need a sensor as trigger that triggers every second. Else you would never match the exact timestamp. For example I have a sensor that counts the hours I am alive and I update it with the entity sensor.date. But it is only updated once a day because thats when sensor.date changes state.


#44

Ah yeah its running in seconds, my bad.

Can we do less than ? Greater than ? so it wouldn’t need an exact second to trigger, just went it gets past that 10 minute window, it would then class as true, and then trigger on the next minute ?

value_template: "{{ (as_timestamp(now()) + 300) | timestamp_custom('%H:%M') < states.sensor.spacex_next_launch_time.state }}"


#45

I opened a feature request fo a UNIX time sensor. Maybe you want to leave your upvote there so we can get this automation to work. See Unix time sensor


#46

Vote left, fingers crossed we can get something sorted out :smiley:


#47

It’s not pretty but I’m pretty sure this will work to trigger an automation ~10 minutes (+/- a few seconds) before launch:

{{ (as_timestamp(states.sensor.date.state + ' ' + states.sensor.time.state) |int ) - ((states.sensor.spacex.state)| int) - 660 < 0}}

You need to have created the ‘time’ & ‘date’ sensors already in your config:

- platform: time_date
  display_options:
    - time
    - date
    - date_time
    - time_date

Those sensors update every minute but once it updates then the comparison will be true around the 10 minute mark.


#48

That’s coming up a True when I paste it into the template editor at the moment,

Next launch isn’t until Feb 9th.

spacex2


#49

oops! Sorry about that.

I pasted the wrong one from my template editor that I was playing around with trying to work it out.

This should work better:

{{ (((states.sensor.spacex.state)| int) - as_timestamp(states.sensor.date.state + ' ' + states.sensor.time.state) |int ) - 660 < 0 }}


#50

No problems, its all good. I have updated the automation to see what happens, shame we have to wait a few weeks to find out, but thank you very much for helping out.