Jinja template not rendering as expected with format and 2 decimal places

This template

{{ '{:0.2f}'.format(0.1) }}

Should return 0.10, but returns 0.1.

Likewise

{{ '{:0.3f}'.format(0) }}

returns 0 rather than 0.000.

This is using HA 2021.11.0 via Docker. Do others get the same behaviour?

When used in HA as-is, the output strings are re-interpreted as numbers, and applied a default format.

Try with outputting some string along and you’ll see that the format is applied, e.g.

echo {{ '{:0.2f}'.format(0.1) }}

Bottom-line: Real issue, wrong culprit :wink:

PS: When I say real issue, it depends on the context. If it’s purely for display, yes it’s an issue. If you want to force the display format of a numeric state, that’s more a feature request.

PS2: Workaround: Add a unicode invisible character, e.g.

{{ '\U00002063{:0.2f}'.format(0.1) }}