I just wanted to share a little project I’ve been working on. I’ve got several automations that inform me, thought my Google speakers, when a certain event has happend. Whenever I call a time it will tell me that something happend at sixteen hours twelve minutes. I prefer a more human approach.
This would make it say “Half dertien” if it was 12:30.
I’ve added an additional “if” statement so if it is 12:xx it will subtract 11, making it say “Half één”.
Same goes for:
{{ now().minute | int - 30 }} minuut over half {{ now().strftime('%-I') | int + 1 }}
I’m trying to convert this to the new format, unfortunately it’s not working and I can’t figure out why; the icon will show but the it won’t display the time.
sensor:
- name: Human spoken time
unique_id: human_spoken_time
state: >
{% if (now().minute | float(0)) == 0 %}
{{ now().strftime('%-I') }} uur
{% elif (now().minute | float(0)) == 1 %}
{{ now().minute }} minuut over {{ now().strftime('%-I') }}
{% elif (now().minute | float(0)) >= 2 and (now().minute | float(0)) <= 14 %}
{{ now().minute }} minuten over {{ now().strftime('%-I') }}
{% elif (now().minute | float(0)) == 15 %}
kwart over {{ now().strftime('%-I') }}
{% elif (now().minute | float(0)) >= 16 and (now().minute | float(0)) <= 29 %}
{{ 30 - now().minute | int }} minuten voor half {{ now().strftime('%-I') | int + 1 }}
{% elif (now().minute | float(0)) == 30 %}
{% if (now().strftime('%-I')) < 12 %}
half {{ now().strftime('%-I') | int + 1 }}
{% elif (now().strftime('%-I')) >= 12 %}
half {{ now().strftime('%-I') | int - 11 }}
{% endif %}
{% elif (now().minute | float(0)) == 31 %}
{% if (now().strftime('%-I')) < 12 %}
{{ now().minute | int - 30 }} minuut over half {{ now().strftime('%-I') | int + 1 }}
{% elif (now().strftime('%-I')) >= 12 %}
{{ now().minute | int - 30 }} minuut over half {{ now().strftime('%-I') | int - 11 }}
{% endif %}
{% elif (now().minute | float(0)) >= 31 and (now().minute | float(0)) <= 44 %}
{{ now().minute | int - 30 }} minuten over half {{ now().strftime('%-I') | int + 1 }}
{% elif (now().minute | float(0)) == 45 %}
kwart voor {{ now().strftime('%-I') | int + 1 }}
{% elif (now().minute | float(0)) >= 46 and (now().minute | float(0)) <=59 %}
{{ 60 - now().minute | int }} minuten voor {{ now().strftime('%-I') | int + 1 }}
{% endif %}
icon: >
{% if now().strftime('%-H') | float(0) >= 0 and now().strftime('%-H') | float(0) <= 6 %}
mdi:weather-night
{% elif now().strftime('%-H') | float(0) >= 6 and now().strftime('%-H') | float(0) <= 12 %}
mdi-weather-sunset
{% elif now().strftime('%-H') | float(0) >= 12 and now().strftime('%-H') | float(0) <= 18 %}
mdi:weather-sunny
{% elif now().strftime('%-H') | float(0) >= 18 and now().strftime('%-H') | float(0) <= 25 %}
mdi:weather-sunset
{% else %}
mdi:clock
{% endif %}```