mobrembski
(Michał Obrembski)
November 14, 2021, 10:56am
1
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ł” it doesn’t looks good.
I’ve tried to customize this entity, using typical template:
sensor.house_total_active_energy_cost:
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?
tom_l
November 14, 2021, 11:14am
2
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.
I keep seeing the same question about the new default argument for the templating. This post will cover all possible ways to define default.
All the methods that were changed:
acos
as_timestamp
asin
atan
atan2
cos
float
log
round
sin
sqrt
strptime
tan
timestamp_custom
timestamp_local
timestamp_utc
Each of them have the exact same default functionality but a different number of arguments. There are multiple ways to use these functions, and this is where all the confusion lies.
Understandi…
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
tom_l
November 14, 2021, 1:16pm
4
Oh, I thought that was part of a template sensor. Didn’t read the whole post again
mobrembski
(Michał Obrembski)
November 15, 2021, 1:26pm
5
Thanks guys, creating a new sensors helps, however i don’t know why it’s not done by default by Energy component