I need some help, I’m totally stuck on what I thought would be simple.
I have an input for a time where I need some automations to run by. I want to look up how many minutes from now until then. I cannot for the life of me work out how to calculate the minutes as the input_datetime doesn’t have a date, so I get scrambled answers.
My failed attempts are below. Any suggestions?
This is the input I’m working with (currently set to “9:00pm”)
input_datetime:
need_to_be_ready:
name: Hot Tub Auto Time
has_date: false
has_time: true
This worked perfectly - thank you so much! Also unlike the other options I tried I can see the logic int his so can tweak and re-use elsewhere, and learning is always the aim on these things, so thank you!
I agree this worked flawlessly and was the best explanation I’ve found on the issue. Question on the “If it’s a time only input_datetime:” version… Is there a way to have it countdown hours and minutes instead of just minutes?
The above method will return a string like: 3 hours 57 minutes, 2 hours, or 1 minute. If you need a different format it is possible to use additional filters and functions to modify it to your needs. You’ll need to share what format you want returned for us to help, make sure to specify what should happen when only one unit has a value to return.
You may also want to take a look at a couple custom template macros made by community members for relative time calculations: