I modified the Xaiomi Vacum card to suit this sensor in lovelace.
Also added in the rounded corner card as well for the second screenshot.
Can share the code if anyone is interested.
I modified the Xaiomi Vacum card to suit this sensor in lovelace.
Also added in the rounded corner card as well for the second screenshot.
Can share the code if anyone is interested.
I think I found the problem: https://www.home-assistant.io/docs/configuration/templating/#templates-using-now
I have another Automation with a time based offset and it’s working fine. It is using the sensor.time
entity. Maybe try to convert the spacex timestamp in a format that you can compare to sensor.time. Maybe it is helpful to you:
- alias: Aufstehlicht
initial_state: True
trigger:
- platform: template
value_template: "{{ states('sensor.time') == (states.input_datetime.wecker_uhrzeit.attributes.timestamp | int - 120 ) | timestamp_custom('%H:%M', False) }}"
condition:
- condition: and
conditions:
- condition: state
entity_id: binary_sensor.workday_sensor
state: 'on'
- condition: state
entity_id: sun.sun
state: below_horizon
action:
- service: script.turn_on
data_template:
entity_id: >
{% if is_state('input_select.wecker_raumauswahl','Schlafzimmer') %} script.sz_wakeup_light
{% elif is_state('input_select.wecker_raumauswahl','Room2') %} script.r2_wakeup_light
{% endif %}
Please share.
please see approx. 6cm above
Amazing, thank you very much, managed to get it working with this code,
- platform: template
value_template: "{{ states('sensor.time') == (states.sensor.spacex_next_launch_time.attributes | int - 600 ) | timestamp_custom('%H:%M', False) }}"
Just put it to 955.500 seconds, to test, and it just popped up with a pushbullet alert for me.
Thank you again.
This is the current code with the rounded corners I am using.
and you will need the card-modder
custom card for the rounded corners, you can easily find it on here with a search.
And here is the background I am using.
- type: custom:card-modder
card:
type: picture-elements
image: /local/spacex.jpg
elements:
- type: state-label
entity: sensor.spacex_next_launch_day
style:
top: 20%
left: 48%
color: rgb(255, 255, 255)
transform: translate(0%,-50%)
pointer-events: none
text-shadow: 1px 1px black
font-family: Trebuchet MS
font-size: 90%
font-weight: bold
border-left-style: solid
border-color: rgb(34, 154, 210)
background-color: rgb(54, 65, 78)
border-radius: 5px
opacity: 0.8
- type: state-label
entity: sensor.spacex_next_launch_time
style:
top: 33%
left: 48%
color: rgb(255, 255, 255)
transform: translate(0%,-50%)
pointer-events: none
text-shadow: 1px 1px black
font-family: Trebuchet MS
font-size: 90%
font-weight: bold
border-left-style: solid
border-color: rgb(34, 154, 210)
background-color: rgb(54, 65, 78)
border-radius: 5px
opacity: 0.8
- type: state-label
entity: sensor.spacex_next_launch_site
style:
top: 7%
left: 8%
color: rgb(255, 255, 255)
transform: translate(0%,-50%)
pointer-events: none
text-shadow: 1px 1px black
font-family: Trebuchet MS
font-size: 90%
font-weight: bold
border-left-style: solid
border-color: rgb(34, 154, 210)
background-color: rgb(54, 65, 78)
border-radius: 5px
opacity: 0.8
- type: state-label
entity: sensor.spacex_next_rocket
style:
top: 46%
left: 48%
color: rgb(255, 255, 255)
transform: translate(0%,-50%)
pointer-events: none
text-shadow: 1px 1px black
font-family: Trebuchet MS
font-size: 90%
font-weight: bold
border-left-style: solid
border-color: rgb(34, 154, 210)
background-color: rgb(54, 65, 78)
border-radius: 5px
opacity: 0.8
- type: state-label
entity: sensor.spacex_next_mission_name
style:
top: 59%
left: 48%
color: rgb(255, 255, 255)
transform: translate(0%,-50%)
pointer-events: none
text-shadow: 1px 1px black
font-family: Trebuchet MS
font-size: 90%
font-weight: bold
border-left-style: solid
border-color: rgb(34, 154, 210)
background-color: rgb(54, 65, 78)
border-radius: 5px
opacity: 0.8
style:
- text-transform: none
style:
background-repeat: no-repeat
background-color: rgba(50,50,50,0.3)
background-size: 100% 68px
border-radius: 20px
border: solid 1px rgba(100,100,100,0.3)
box-shadow: 3px 3px rgba(0,0,0,0.4)
Thank you very much!
So it seems that the automation just triggered for me at 1hr to midnight, and then 10 mins to midnight, not sure what happened there, will have to have a look into it.
Try this…
trigger:
- platform: template
value_template: "{{ (as_timestamp(now()) + 300) | timestamp_custom('%H:%M') == states.sensor.spacex_next_launch_time.state }}"
condition:
- condition: template
value_template: "{{ now().strftime('%m.%d.%Y') == states.sensor.spacex_next_launch_day.state }}"
I was having the same problem, but my templating skills aren’t up to scratch at all. I kept having a play around, but couldn’t ever get anything to work. Was on my list of things to do.
So that would give you a notification 5 minutes before ? The + 300 bit is what confuses me ? But as I said, i don’t know much
Hey @edif30 So it seems the automation didn’t fire for me today when the launch took off a few hours ago.
Don’t suppose you have an clue’s at all.
Many thanks in advance.
I’ve fiddled around with several ways but couldn’t get it to work either. It would all be so much easier if hass had a unix-time-sensor.
Mine didn’t fire today either. I was logged in waiting and wanted to verify everything would work so I checked the template editor and the entire automation was true so it should absolutely have fired. I didn’t get a chance yet but was going to post a question on here. Below is the automation.
#
- id: space_x_launch_notify_5
alias: Space X Launch Notify 5
trigger:
- platform: template
value_template: "{{ (as_timestamp(now()) + 300) | timestamp_custom('%H:%M') == states.sensor.spacex_next_launch_time.state }}"
condition:
- condition: template
value_template: "{{ now().strftime('%m.%d.%Y') == states.sensor.spacex_next_launch_day.state }}"
- condition: time
after: '08:00:00'
- condition: time
before: '22:30:00'
action:
- service_template: >
{% if is_state ('device_tracker.person1' ,'home') %}
script.rocket_man_home
{% else %}
script.rocket_man_not_home
{% endif %}
- service: notify.automation_script_triggers
data:
message:
'{{now().strftime("%Y-%m-%d %H:%M:%S")}} -- space_x_launch_notify_5'
And here is how the output as seen by the template editor which shows the condition and trigger as true
#
- id: space_x_launch_notify_5
alias: Space X Launch Notify 5
trigger:
- platform: template
value_template: "True"
condition:
- condition: template
value_template: "True"
- condition: time
after: '08:00:00'
- condition: time
before: '22:30:00'
action:
- service_template: >
script.rocket_man_home
- service: notify.automation_script_triggers
data:
message:
'2019-01-11 10:29:15 -- space_x_launch_notify_5'
It doesn’t make any sense because that condition and trigger seems as precise as you can get.
I think it has something to do with it just being a template, rather than a entity changing. It needs an entity state change to trigger the template I believe, but how you set that, beyond me.
Also could be completely wrong.
I’m quite sure it has to do with the fact that you should not use as_timestamp(now())
without an entity that updates it’s state: See https://www.home-assistant.io/components/sensor.template/#working-without-entities
could you use time as the trigger and then the two templates as conditions ?
something like
trigger:
platform: time
minutes: '/1'
seconds: 00
condition:
- platform: template
value_template: "{{ (as_timestamp(now()) + 300) | timestamp_custom('%H:%M') == states.sensor.spacex_next_launch_time.state }}"
- condition: template
value_template: "{{ now().strftime('%m.%d.%Y') == states.sensor.spacex_next_launch_day.state }}"
That should run every minute ? and only trigger if both are true ? Not sure if thats a bad thing to have it running every minute ?
Hmm, but then that will trigger every minute after the 10 minutes too…
There is an entity in the template and as long as the value is “true” it should fire. That template says if this = that. So the trigger should fire when it is equal.
but the entity doesn’t change state to cause the trigger to fire which is the problem I believe.
Can it just be something like this then ?
- platform: template
value_template: "{{ (as_timestamp(now()) + 300) | timestamp_custom('%H:%M') == states.sensor.spacex_next_launch_time.state }}"
entity_id: sensor.time
No that won’t work. I am curious if the sensor just has to be swapped in front of the timestamp. Or… we can create a sensor that equals the timestamp +300 and do an == on that. Either way, both would end up being ‘true’. Thats how I understood the value template. If the value = what your equation is, match and then true.