I have a helper, sensor.um_total_charged_monthly (a UI-created utility meter), that resets monthly and collects from an entity sensor.total_charged. It works as expected, except ....
... the utility meter can increase in value even though the entity does not. This occurs after a HA restart - but only sometimes.
I guess this is caused by the entity sometimes not being available at restart before the utility meter is configured. However, when setting up the input_sensor for the utility meter, I checked Sensor always availableIf activated, the sensor will always show the last known value, even if the source entity is unavailable or unknown - which I assume should prevent the errors I'm seeing. (note that, as the utility meter is UI-created, I can't edit it to ad an availability condition).
I thought I'd work around the problem by creating 2 entities (lastmth & thismth).
thismth would be a template that calculates sensor.total_charged - lastmthand, at end of month, have an automation run to copy thismth to lastmth, and set thismth = 0 but ...
Is there a better way ? Or some way to fix the utility meter?
Thanks, @Tom_l, I'd not found that link in my searching.
No, the source entity is not a template. It's provided by a custom integration. It's a single entity (sensor.wattpilot_totally_charged) and has State class : Total, Unit of measurement : kWh, Device class : energy. The utility meter is not intended for use in the energy dashboard - I just want the previous month total & the mtd total.
There is not an option to include an availibility condition with a UI-created utility meter. If this is a necessary component, shouldn't it be an option in the UI?
Found this link to some detail about yaml-created utility meters Utility Meter. I'll try this.
The availability template is for the source sensor not the utility meter and it protects utility meters just as well as the energy dashboard for the same reasons given in the link.
If your sensor is reporting 0 after a restart instead of unavailable then that is a bug and should be reported the the integration developer.
What does the state of that source sensor show? Does it show drops in it's graph after a HA restart?
Tom stressed out the importance of availability on the source sensor, if that source sensor is a template senor or mqtt sensor. availability isn't an option on the utility meter sensor, also not if it's set up using YAML.
Yes, the source sensor is reporting zero on restart - sometimes. I understand now why my utility meter has issues.
I'll alert the developer. In the interim, to add an availibility to the source sensor, would I have to create a template.sensor that has the source entity value then use that template.sensor as the new source for the utility meter? (since I can't modify the original source entity).