Hello community,
my counting sensor for a contract duration is not working since the new year.
- sensor:
- name: "Stromverbrauch - Monate"
unique_id: stromverbrauch_monate
state: >
{% if (now().timestamp() | timestamp_custom('%Y') | float(default=0)) < (as_timestamp(states('input_datetime.stromvertrag_vertragsbeginn_aktuell')) | timestamp_custom('%Y') | float(default=0)) %}
{{ (min(12,(now().timestamp() | timestamp_custom('%m') | float(default=0)) - (as_timestamp(states('input_datetime.stromvertrag_vertragsbeginn_aktuell')) | timestamp_custom('%m') | float(default=0)) + 13)) | int(default=0)}}
{% else %}
{{ ((now().timestamp() | timestamp_custom('%m') | float(default=0)) - (as_timestamp(states('input_datetime.stromvertrag_vertragsbeginn_aktuell')) | timestamp_custom('%m') | float(default=0)) + 1) | int(default=0)}}
{% endif %}
unit_of_measurement: Monate
It worked well until switching to 2025. Now I only get 1 as result.
The input.datetime is 01.12.2024. So the result should be 13.
Any ideas?
Thanks.
3 posts - 3 participants