Easy Time Macros for Templates!

Those also only work with datetimes or entity_id’s.

They sure do, like practically everything else in HA related to date, time and mathematical operations. What else would one use than a date/time related format?

Even if you have minutes or seconds, you can convert that to a timestamp and use it, or am I off here?

You’re off here, just try it

{{ time_since(120) }}
{{ time_until(120) }}

{{ time_since(now()-timedelta(seconds=120)) }}
{{ time_until(now()+timedelta(seconds=120)) }}
{{ relative_time(now()) }}

Sorry, you misunderstood or I wasn’t clear, I’m totally with you on that one aka. that’s what I’m saying or trying to say… :rofl: :rofl:

Ah, I thought you ment “they sure do accept ints”

1 Like

Sorry, not my best english-is-not-my-native-language-day… :rofl: :rofl:

I’m trying to learn Italian at the moment, and I can safely say it doesn’t make my english better… :rofl: :rofl: Not to talk about my native language German, getting a mix out of english, german and italian is mostly funny for others… :rofl: :rofl:

1 Like

Thanks understood the issue :).

EDIT: @petro do you think also an option with capitalize make sense?

See idea from button card helpers:

Is there a way of calculating the time until each season change with this?

Yes, you can use one of the many functions. easy_time, count_the_days, easy_time_between, etc.

Thanks, but does easy_time “know” the date and time of the season changes?

You’d have to come up with that. Seasons are different for every timezone and area of the world.

Why don’t you use the season integration? Is there something not working? :slight_smile:

I don’t think season tells you dates. It tells you what the current season is.

2 Likes

You’re totally right, Nick! :slight_smile: I have a template sensor with the date, and I was quite sure it uses the season integration. After checking, turns out, I’m importing the date from a calendar :open_mouth:

4 posts were split to a new topic: Exposing season transitions as timestamp sensors

Amazing that you added the German translations! I just tried to set-up a card but am running into the issue that the sentence structure is wrong:
image

I have also opened an issue here:
Wrong order for relative_time in German · Issue #37 · Petro31/easy-time-jinja (github.com)

and also tried to add some code to fix it (list of languages with different order), but unfortunately couldn’t quite get it to work.

Does anybody have an idea on how to fix this?

Just want to check in to see if anybody has an idea on how to get this to work with a sentence structure that differs by language?

2.1.0.1

New Features

  • 2 new macros:
    1. hour - translates hour of the day, e.g. midnight → 1, 2… etc → noon, → 13, 14 etc
    2. clock_phrase - translates the current time to a long phrase, e.g. half past 11, or quarter to 10, etc.
  • month and weekday now support entity_id’s as inputs.

Bug Fixes

  • Fixed an issue with speak_the_days returning the wrong day when the value is in the past.
  • Fixed an issue with easy_relative_time using now()
  • Fixed vor <relative time> for German.
2 Likes

Do I need to update the translations for these new macro’s?

Maybe? I can remember. I think the clock one might need translations