Rounding on Total Energy Cost doesn't work

Hi All,

I think i found a bug in HA.
So basically i have connected my energy meter to HA, and established Energy dashboard.
Now energy dashboard created a “house_total_active_energy_cost” entity with daily cost of energy.
But on mine installation, value isn’t rounded, so i have a values on dashboard like “4,55265999999989 zł” :slight_smile: it doesn’t looks good.

I’ve tried to customize this entity, using typical template:

  value_template: >-
    {{ states('sensor.house_total_active_energy_cost') | round(2) }}

However it doesn’t seems to work.
Isnt it a bug?
Can i make a workaround somehow?

You are trying to round a string (word). It needs a number.

{{ states('sensor.house_total_active_energy_cost') | float | round(2) }}

You should also think about adding default values in case the state is unknown.

You can’t customize the state of an entity woth customize. value_template is not a valid option for customization.

You need to create a new template sensor based on the existing sensor and thrn use tom’s suggested temlkate.

1 Like

Oh, I thought that was part of a template sensor. Didn’t read the whole post again :man_facepalming:

Thanks guys, creating a new sensors helps, however i don’t know why it’s not done by default by Energy component :slight_smile: