BTW, you can change the argument of the round() function to the number of decimal places you want in the ultimate result. 0, which is the default, will create an integer (i.e., no fractional part.)
sensor.solar_consumo-vertido should perhaps be sensor.solar_consumo_vertido with two underscores? And youâre missing the quotes (") at the end of the line.
Hello, sorry for bringing this up again after such a long time, but I am having difficulty in doing almost the same thing as the person who started this thread with slightly different values and I am using the value of an input number helper.
This is what I have written but it does not seem to work.
Iâve been following some if the info here and itâs been really helpful
Iâve managed to get the maths to work ( / 20) but Iâd really like it to display 2 decimal point values whatever (since itâs ÂŁ)
I looked at the Jinja doc here but the "%0.2f" | led to the value breaking
- platform: template
sensors:
a_dadpoints_pounds: # this is the name of the sensor
value_template: "{{ states('input_number.a_s_dad_points')|float / 20 | float(2) }}"
e_dadpoints_pounds: # this is the name of the sensor
value_template: "{{ states('input_number.e_s_dad_points')|float / 20 | float(2) }}"
Finally, Iâm only using this for display on a card, so Iâd actually then like to convert that to text and concatenate with the ÂŁ symbol at the front - struggling to find how to do thatâŚ