I want to send a notification to pickup the kids by 5pm every day. So basically I want a notification when to leave accounting for traffic. My logic is 5pm - traffic. I have that working as:
The issue we will run into though, is that because this formats it so weirdly, we can’t build triggers off of this output for notifications. I am working through that piece now, and I can’t get it to fire at the correct time. I think it has to do with the seconds that seem to be unavoidable.
Let me know if you get this working and then also the notification.
Not sure what you mean, your last line does return a timestamp…
Something like ‘-2208909780.0’ depending on when you’re now() is.
It’s based on Epoch/Unix time stamps. Since there is no date it defaults to the beginning (Jan 1 1900).
You don’t care about date though so having both default to that doesn’t affect the time output.
Problem is that will return a time stamp with today’s date and then you’ll be subtracting apples and oranges. Something thing in 1900 and something in 2017. Timestamp is always a date/time representation so if you only have time on one of them you need to have than with the same base date for the math to make sense.
The issue with adding or removing the date is what I am running in to as well. Even if you get a time, without a date (at least in my experience), will not work as a trigger. I think it has to do with creating the timestamp. If we do it as above, the output doesn’t seem to be recognized as a true complete timestamp.
As a side note, I couldn’t get {{as_timestamp( strptime( now().strftime("%H:%M"), "%H:%M" ) )}} to resolve either.
I figured you would be comparing minutes for the automation (integers) not times. i.e. 5:00pm - traffic <= 5 (min) trigger should leave soon, or something like that. Or even a sensor that shows minutes until needing to leave (can always be formatted as pretty hours:minutes) after the fact.
pip3 show Jinja2
Name: Jinja2
Version: 2.9.6
Summary: A small but fast and easy to use stand-alone template engine written in pure python.
Home-page: http://jinja.pocoo.org/
Author: Armin Ronacher
Author-email: [email protected]
License: BSD
Location: /srv/homeassistant/lib/python3.4/site-packages
Requires: MarkupSafe