Hi there,
As it seems that like to fit a square in a circle, I’m trying to add my monthly subscription for electricity to the energy dashboard. I’m almost there but there is one last thing that I cannot do. I will try to list everything that I have tried to see if someone has a better idea on how I should run those things…
Requirements
- A new line in the table with 0 kWh (for not skewing the total Off Peak/Peak sum)
- Increase the cost of subscription by a daily amount (monthly cost * 12 months / 365 days)
First Step
Sensors if declared in Configuration.yaml (measurement or even total_increasing) do not seem to retain values on reboot, so I had to use the Utility Meters in the Helpers section of the UI. A Helper cannot be used without a sensor as source, so I had to created a dummy sensor that stays at zero all the time.
template:
- sensor:
- name: "Energy Electric Subscription Dummy [kWh]"
state_class: total_increasing
unit_of_measurement: kWh
device_class: energy
state: 0
Then I created a Utility Meter called “Energy Electric Subscription” that uses this sensor. I now managed to show the 0 kWh and I can use an entity to track costs.
Second Step
To manage the costs, I tried to add directly to the cost sensor which is automatically generated when the Utility Meter is created. If I set the state by hand, it gets erased one minute later. Wrong approach.
Instead, I use another Utility Meter to track the total costs because this kind of entity can survive a reboot of HA without loosing its last value. This time, if I set some increments by hand with the Developer Tools, it works in the UI, I can see the increments.
My Problem
How can I increase this total costs entity by a fixed amount (0.62) every day at 00:01. By doing this, I would have the right amount reflected in the Energy dashboard with the various aggregates (weekly, monthly, etc.).
Automation does not seem to allow you to modify the value of a Utility Meter and “set_value” only works with Input Text and not sensors.
Has anyone a better idea on how to implement this?
Cheers,
G.