Hello everybody
I am trying to to create few binary sensors to use on the dashboard to show different sections based on their state.
Example show the Christmas control lights this period, Halloween lights on last week of October, etc.
This is the “code” for the first sensor:
{{ now().strftime('%Y-%m-%d') >= states('input_datetime.natale_periodo_inizio') and now().strftime('%Y-%m-%d') <= states('input_datetime.natale_periodo_fine') }}
where:
- today is 03.12.2024
- natale_periodo_inizio is set to 28.11.2024
- natale_periodo_fine is set to 07.01.2025
output: true
It works, but is not optimal because it also uses the year for the comparison.
So on next year I will have to update dates on helpers to get the templates works correctly.
Is it possible to define an helper just for day/month and use this for the comparison?
something like this:
{% set today = 03.12 %}
{% set begin= 28.11 %}
{% set end = 07.01 %}
{{ today >= begin and today <= end }}