been using this since a very longtime, aided by @petro (please have another look…), and now, all of a sudden, the count of days is a day of, when the alarm time is over 24 hours… (might even be 23 hours and 54 minutes)
Next alarm day:
value_template: >
{% set timestamp = states('sensor.next_alarm_timestamp')|int %}
{% set days = states('sensor.number_of_days_next_alarm_calc') %}
{% set day_dict = {'0': 'Today,', '1': 'Tomorrow,', '2': 'The day after tomorrow,'} %}
{% set date = timestamp|timestamp_custom(' %A, %-d %B') %}
{% if days == '-1' %} Not set
{% elif days in day_dict %} {{day_dict[days] + date}}
{% else %}{{'Next' + date}}
{% endif %}
days to next alarm:
number_of_days_next_alarm:
friendly_name: Days to next alarm
entity_id:
- sensor.time
- sensor.number_of_days_next_alarm_calc
- input_boolean.alarmclock_wd_enabled
- input_boolean.alarmclock_we_enabled
value_template: >
{% set days = states('sensor.number_of_days_next_alarm_calc') %}
{{'Not set' if days == '-1' else days}}
and the number_of_days_next_alarm_calc, the above use in the templates:
value_template: >
{% set timestamp = states('sensor.next_alarm_timestamp')|int %}
{% if timestamp %}
{% set time = now().replace(second=0).replace(microsecond=0) %}
{% set midnight = now().replace(hour=0).replace(minute=0).timestamp() + 86400 %}
{% if timestamp > midnight %}
{{((timestamp - time.timestamp()) // 86000)|int + 1}}
{% else %} 0
{% endif %}
{% else %}
-1
{% endif %}
what could be wrong here, did HA 113 change anything to influence this?