Petro31 / easy-time-jinja

Easy Time calculations for Home Assistant templates
MIT License
73 stars 25 forks source link

FR: add drop in functionality for month() on timestamp entities #27

Closed Mariusthvdb closed 1 week ago

Mariusthvdb commented 9 months ago

followup from Discord

have a timestamp entity like

{{states('sensor.afvalwijzer_plastic')}}

which outputs ' 2024-02-02'

for various dashboards/templates, it would be very nice to be able to do

{% set trash = 'sensor.afvalwijzer_plastic' %}
{% from 'easy_time.jinja' import month %}
{{month(trash)}}

or

month(states(trash))

to output the month name

which would be much nicer than

{{month(as_datetime(states(trash)).month)}}

which currently does the job alright

please consider adding that? thx

Petro31 commented 1 week ago

Added in 2.1.0

Mariusthvdb commented 1 week ago

nice!

% set trash = 'sensor.afvalwijzer_plastic' %}
{% from 'easy_time.jinja' import month, weekday %}
{{weekday(trash)}}  {{month(trash)}}

{{(states(trash)|as_datetime).day}}
Scherm­afbeelding 2024-10-15 om 23 15 59