tosion
1
Please help with rounding?
This works
day_average_price:
friendly_name: day_average_price
value_template: >
{{states.sensor.nordpool_kwh_fi_eur_3_10_024.attributes.average| round(2)}}
This does not?
start_price:
friendly_name: start_price
value_template: >
{{state_attr('sensor.nordpool_kwh_fi_eur_3_10_024', 'average' ) * states('input_number.price_percentage') | round(2)}}
How can I get this second one working?
tom_l
2
You are only rounding the last state. Put brackets around the lot:
{{ ( state_attr('sensor.nordpool_kwh_fi_eur_3_10_024', 'average') * states('input_number.price_percentage') )| round(2) }}
tosion
3
I tried that one too but the result was:
tom_l
4
Also you need to convert the second state to a number.
{{ ( state_attr('sensor.nordpool_kwh_fi_eur_3_10_024', 'average') * states('input_number.price_percentage')|float(0) )| round(2) }}
1 Like