completely unrelated (it’s a fix to calibrate service when you want to calibrate using a float value)
I’ve no clue what’s going on
I’m nonetheless betting in sensor.shelly_total_power_consumption being the root cause.
Next time share not only the utility_meter sensor but also the source sensor graph.
Well, it IS strange. Happened once, and never again since. It’s counting up like it should.
I also checked the total consumtion value that feeds the utility sensor, but it was flat like the desert. No bumps or abnormalties. I’ll keep an eye on it.
Another issue with another instance of utility_meter.
I use is to give daily, weekly and monthly rain accumulation.
Worked fine for a few days, and suddenly went crazy with numbers after the decimal point.
The meter is always adding 0.31 to itself. Any way that I can just reduce it to one or two numbers after the decimal point?
Hi all,
reopening this discussion as I think I have a similar issue…
I am using Shelly EM to report the energy consumption of two floors with two distinct probes.
What I did is to create a template sensor that sum up the values of these two probes and the use this template sensor within Utility Meter.
It all works fine until i restart HA. When I do that, all the UM values loose sense.
I think the issue is with the status of the template sensor across reboot, which breaks Utility Meter.
This is the template sensor:
After the reboot the daily energy monitor report the total consumption not the daily one.
My template code is
- platform: template
sensors:
energia_complessiva:
friendly_name: Energia Elettrica Complessiva
unit_of_measurement: "kWh"
value_template: >
{% set current_state = states('sensor.energia_complessiva') | float | round(1) %}
{% set new_state = ((states('sensor.shellyem_energy1') | float) + (states('sensor.shellyem_energy2') | float)) | round(2) %}
{% macro max(X, Y) -%} {{X|float if X|float > Y|float else Y|float }} {%- endmacro %}
{{ max(current_state, new_state) }}
and the Utility meter:
utility_meter:
daily_energy:
source: sensor.energia_complessiva
cycle: daily
tariffs:
- mono
weekly_energy:
source: sensor.energia_complessiva
cycle: weekly
tariffs:
- mono
monthly_energy:
source: sensor.energia_complessiva
cycle: monthly
tariffs:
- mono
any useful clue how to prevent this?
thanks
Hmmmmm… My meter gets even more precise these days
This answer might sound strange at first, but please try:
Can you make sure the numbers fed to the utility_meter are strings and not floats ?
If required please convert the floats into strings using a template sensor
Can you show the graphs of your supporting sensors ? I’m betting they have dip too…
No question too strange to ask me, as I’m no pro at all.
This is the definition of my sensor:
- platform: template
sensors:
rainfall_mm:
friendly_name: 'Regen'
unit_of_measurement: 'mm'
value_template: >
{{ states('counter.raingauge_pulses') | multiply(0.31) }}
I have no idea if this results in a string or a float?! For my understanding this should be a string.
Hi,
this is the real sensor (ShellyEM) - no dip:
added to this one:
While this is the template sensor - with a dip at the moment of HA restart:
it seems it’s that hole in the template sensor that breaks utility meter
Can you add “| string()” to the template ?
Yep, the problem is the hole.
Try using a https://www.home-assistant.io/integrations/filter/ to remove the hole.
I can, and I did now. It seems to work, so I will have an eye on it.
{{states('counter.raingauge_pulses') | multiply(0.31) | string()}}
Seems it doesn’t work, even as STRING
Ok, I’ve added an “outlier” filter:
- platform: filter
name: "Energia Complessiva"
entity_id: sensor.energia_somma_piani
filters:
- filter: outlier
window_size: 4
radius: 50
and so far it seems it is removing the zeros:
sensor before filter:
sensor after filter:
finger crossed it may have fixed the issue! thanks!!
I was struggling with getting my utility meters to have the correct unit issue like others above. I was able to reuse an existing utility_meter name by
1 - Remove the sensor from HA
2 - Restarting HA
3 - Deleting that device out of the ../homeassistant/.storage/core.restore_state
file and then restarting HA.
4 - Once restarted, recreate the sensor with the same name and it was reset. I had to wait a minute or two for the energy meter to increase in value so the sensor would initialize.
For some reason, I didn’t understood the utility meter at the beginning and I added the “live” power, instead of the total energy sensor to the utility meeter sensor.
I now can read proper values!, but, I have an issue with the units, they are in Watts and not KW/h,
Deleting the sensor and adding it again on the config file doesn’t help. It remembers it,
I know changing the name will solve it… but… it has the same formatting as the others that are right and would’t want to change them: “sensor.kitchen_monthly_energy”
I guess I need to do what it’s mentioned above, but where is this file located, cant find it with the visual studio.
I’ve decided to PR a fix for this common mistake:
At least sync at startup!,
finally found the hidden file and manually changed the units!
Thanks for the work, others will appreciate.
(also another feature that should be implemented in the utility meeter is not to sum if one of the sensors that add the values is in “unknown state”, managed to do it after reading some trouble from others, but that is definitely a feature that should be default implemented. Probably not posible since the utility meeter doesnt know what sensors compose the sum function, maybe sum them inside the utility meeter instead of using another template)
Every state change seems a bit extreme. Why not just after a restart/reload of the integration?