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
I suppose it would be easier to just compare the minutes, that probably can be done by extracting the minutes part of the srtring than turning it into integers and doing the math. Hower this will fail if the bus leaves lets say 12:05 and it is 11:59 …
still puzzled by why {{as_timestamp( strptime( now().strftime("%H:%M"), "%H:%M" ) )}} comes up empty.
Maybe this has to do with some kind of locale setting or the platform. I’m using hassbian on a raspberry pi. This is my locale:
That I’m not sure of, I’m running a manual install on my OS X server so no experience with the rpi. If you break it apart does any part of the nesting resolve in the template viewer?
The problem I am having is getting an automation from here to evaluate true. I have tried simply setting {{ as_timestamp(states.sensor.go_get_kids.state) | timestamp_custom("%H:%M") == as_timestamp(now()) | timestamp_custom("%H:%M") }} as a template trigger like this:
I then tried to create a binary sensor but that failed as well. If anyone can figure that out, we can piece together the other pieces to make this type of time templating possible.
You might try to create a new sensor to include the date on top of your bus sensor.
something like this: {{now().strftime("%Y") }}-{{now().strftime("%m") }}-{{now().strftime("%d") }} {{ states.sensor.bus.state }}
Then try to work through how to alert based off of that. That’s where I am failing so I don’t have any recommendations there unfortunately.