Sum up sensors value template not rounded correctly

Hi all , it seems that my value_template is incorrectly coded, but i don’t find my error.
I aggregate energy sensors in another one, using this sensor code :

      energy_total_kwh:
        friendly_name: 'Energy Total'
        value_template: "{{ (states('sensor.Priska_plus_01_cumul') | float + states('sensor.shelly_mobile_plug_energy') | float + states('sensor.shelly_parents_chauffage_energy') | float + states('sensor.shelly_chauffage_matteo_energy') | float + states('sensor.shelly_clim_enfants_energy') | float + states('sensor.shelly_couloir_chauffage_energy') | float + states('sensor.shelly_bureau_chauffage_energy') | float + states('sensor.shelly_bureau_energy') | float + states('sensor.shelly_1pm_clim_salon_energy') | float + states('sensor.shellyplug_s_ab8f3a_energy.') | float + states('sensor.shelly_sous_sol_frigos_energy') | float + states('sensor.shelly_sous_sol_chauffe_eau_energy') | float + states('sensor.shelly_frigo_plaque_terrasse_energy') | float) | round(2) }}"
        unit_of_measurement: kWh

I used the round(2) attribute at the end of the template, but it’s not correctly rounded in frontend :

energy

My utility_meter :

  energy_total_monthly_ch_house:
    source: sensor.energy_total_kwh
    cycle: monthly

Any advice about my mistake ?

Thanks, regards, Thomas.

I believe that’s due to a phenomenon known as Machine Epsilon. You can read more about it here:

Try this version and see if it works any better:

      energy_total_kwh:
        friendly_name: 'Energy Total'
        unit_of_measurement: kWh
        value_template: >
          {% set sensors = expand('sensor.Priska_plus_01_cumul', 'sensor.shelly_mobile_plug_energy',
                           'sensor.shelly_parents_chauffage_energy', 'sensor.shelly_chauffage_matteo_energy',
                           'sensor.shelly_clim_enfants_energy', 'sensor.shelly_couloir_chauffage_energy',
                           'sensor.shelly_bureau_chauffage_energy', 'sensor.shelly_bureau_energy',
                           'sensor.shelly_1pm_clim_salon_energy', 'sensor.shellyplug_s_ab8f3a_energy',
                           'sensor.shelly_sous_sol_frigos_energy', 'sensor.shelly_sous_sol_chauffe_eau_energy',
                           'sensor.shelly_frigo_plaque_terrasse_energy') %}
          {{ '{:.2f}'.format(sensors | map(attribute='state') | map('float') | sum) }}

Thanks for pointing me to the right direction, i did’nt know about Machine Epsilon.
I tried your syntax, but unfortunately got the same results.
I think this has been asked multiple times, but i imagine there’s no way to force the rounding in frontend ?

I don’t think you’ve understood that it is rounding and what you seeing is a rare byproduct of the rounding process.

You can try the suggestion offered in the linked post (convert to string and slice off the undesirable parts).

U’re right, i’ll give it a shot tomorrow. Thanks again, i would have been looking for days if u didn’t mention this “rare byproduct”. :grinning: