I’m using an automation to send myself a message containing the latest corona confirmed value. However, in NL, it’s exceeding 10.000, which makes the number large and not easy to read.
So now the number in my message is ‘10923’, and I’d like to format that into ‘10.923’. I figure it could be done with templating, but I can’t find an example to start with.
Thanks @Burningstone, that does like nice I’ll use that.
For even larger numbers (ie. millions) I guess I could use an if/else statement to check the size, split the number and then stitch it back together with multiple dots in between. Or do you have a better suggestion?
divide I’d say
it depends on your use case so you need to decide how to you’d like to see your data as it can be as flexible as your imagination
I use the following approach when displaying time in compact mode - if it’s just minutes I generate 5 min but if it’s hours it becomes 2h 5m or 3 hours (if minutes is 0) so it takes about the same space on screen
Here’s one of examples for you to get the idea
{% set etime = states.sensor.ender_3_pro_time_remaining.state | int %}
{% set seconds = etime % 60 %}
{% set minutes = ((etime % 3600) / 60) | int %}
{% set hours = ((etime % 86400) / 3600) | int %}
{% set days = (etime / 86400) | int %}
{%- if days -%}
{{days}} day{{'s, ' if days > 1 else ', '}}
{%- endif -%}
{%- if hours -%}
{{hours}} hour{{'s, ' if hours > 1 else ', '}}
{%- endif -%}
{{minutes}} minute{{'s' if minutes > 1 else ''}}