I try to format a template sensor to show only 2 digit after the decimal point. With “{0:,.2f}”.format" in the development tool, all works fine. However, when I use the same in the configuration file, I get errors.
Hi guys, many thanks. The trick with the multiline worked!!
Is there somewhere a comprehensive overview of the rules for single quotes, dubble quotes, brackets, intendation etc. This language is driving me crazy.
Please consider marking my post above with the Solution tag. It will automatically place a check-mark next to the topic’s title which signals to other users that this topic has been resolved. This helps users find answers to similar questions.
Note that the formatting won’t work. The result of a template is always a string. The template parser will try to parse it to a native Python type and then apply that type.
So if the result is something like 12.30 it will be parsed to a floating point number and the state of your sensor will be 12.3
So the result will be the same as rounding to 2 digits
You should also consider adding default values for the float filter or adding an availability template