I’m goin mad. I have an imput_datetime where the last run is registered. Also have an input_number to store the expected date duration in days for the next time run. I’d line to make a template sensor, which swows the next run date if the last run date + elapse days is later than today and shows today it the last run+elapse days is earlier or equals today.
The code below gives alwasy today’s date. What I do wrong?
I have this:
next_run:
value_template: >-
{% if (states('input_datetime.last_run') | as_datetime | as_local + timedelta(days= (states('input_select.elapse') | int(0)) )).date() < now().date() %}
{{ states('sensor.date') }}
{% else %}
{{ (states('input_datetime.last_run) | as_datetime | as_local + timedelta(days= (states('input_select.elapse') | int(0)) )).date() }}
{% endif %}