Was delighted today to find the “Launch Library” integration today…
… Then bummed when I couldn’t find a way to get an automation to trigger from the time-to-launch sensor.
What does it take to get sensors like those to be exposed as a trigger for an automation?
Today I stumbled on your same problem If you want we can try and solve it together. I will start with this automation and will improve it along the way.
For now this will send a notification when launch time is lest than 1 day (to be honest I dont think this will work but this is a start)
Hey! Just noticed your message, and I’d like to work on that automation with you, as you suggested… just as soon as I fix this @#$!@ WLED problem (hopefully sometime tonight).
That trigger will never fire because the sensor’s state is a datetime string not a number. You could use a numeric state trigger if you added a value_template, but it would be easier to just use a template trigger:
Starting from your efforts, I ended up with the following, which gives a 2-hour heads-up:
alias: "Notification: Upcoming Space Launch"
description: ""
trigger:
- platform: template
value_template: >-
{{ now() >= states('sensor.launch_time') | as_datetime -
timedelta(hours=2) }}
condition:
- condition: not
conditions:
- condition: state
entity_id: sensor.launch_time
attribute: stream_live
state: false
action:
- action: notify.mobile_app_brendan_galaxy_s22_ultra
metadata: {}
data:
message: Space Launch in 2 hours
data:
actions:
- action: URI
title: Open Launch info
uri: /config/devices/device/e0236a78e08cb98ad6ead5744f6d2e1e
mode: single
The main thing I haven’t tested is the “steam_live” attribute. It turns out the stream_live attribute is a timestamp - and is set to false when there is no live stream - so I’ve reversed that logic in my edit above.
The URI given to “Open Launch info” is going to the main service page in HA. I’m sure we could still improve the message slightly so it gives more information.