[solved] Notification current time w/ piper & omit minutes if 00

I’m trying to have a notification of the current time with tts.piper

This is the template I use in the message part:

{{ (now().timestamp())|timestamp_custom('%H:%M') }}

It’s read with the hours and minutes as 1 number.
If I break the hours and minutes apart a ‘0’ is added before the hour if the time is 0 - 9 o’clock.
Did the same with tts.google_say and the time is read correctly + even added the moment of the day to it. (morning, afternoon, evening)

The moment of the day can be added, so that’s not an issue.
Is it possible though to have 3 o’clock read as 3 and not 03?

You could try this:

{{ (now().timestamp())|timestamp_custom('%-H:%-M') }}
1 Like

THANK you, this works!!! :bowing_man: :+1:

@pdwonline (or anyone else): when the time is on the hour (e.g. 11:00) the second number is read as 0 which of course is correct.
Is there a way to omit that part in case it’s 00?

That would be something like this:

{% set minutes = (now().timestamp())|timestamp_custom('%-M') |int(0) %}
{{(now().timestamp())|timestamp_custom('%-H')}}
{%- if minutes > 0 -%}:{{minutes}}{%- endif %}

2 Likes

Thank you @pdwonline, again! :star_struck: