Searching for a solution, I found this feature request:
Since it has not been implemented yet, I’d like some advice on how to work around it (without adding each device as a “energy source” instead of an “individual device”.
I have an electric heater that pulls 1800W connected via a smart plug. I used the ‘powercalc’ integration to make power (W), energy (kWh) and utility (daily, weekly, monthly energy) sensors for it, which works nice.
Now the next step is to add cost (€) sensors (daily, weekly, monthly) for it. But that is where I get stuck. If I had a fixed energy price, I would just make template sensors multiplying the utility meter sensors by the energy cost. But I have separate prices for peak hours and off hours depending on the time of day. How would I go about this? Can I somehow make a template sensor that multiplies energy by cost, but uses a different ‘cost’ value depending on the time? Like the Energy Dashboard does?
Thanks in advance for any tips, hints and shoves in the right direction!
EDIT: Of course (as usual), after writing this, a solution comes to mind:
I could make a separate template sensor “current_energy_cost” that switches its €/kwh value based on the time of day. And then use that sensor to multiply the utility sensors.
Is this the (best) way to go, or is there a cleaner/better solution?
I indeed came across that part, but I have to stare at it for a bit longer to understand how to use it to get cost sensors. I thought it was only for manually making separate kwh sensors per tariff. As opposed to using the gui.
Yes, you get sensors (per timeframe and traiff) for the consumption, which you can use in the energy dashboard or multiply the consumption with the price in a template sensor.
You can do everything that is in the yaml example in the GUI aswell.
Utility meter integration has this tariff feature but it is not very flexibile and seems to assume fixed set of fixed tariffs.
When you have prices for electricity that is made from a sum of market prices per hour and tariffs that change several times per day and these again change every month, then you need something more flexible.
I have the same issue as mentioned in the first post of this thread but a quite different
I have several €/kWh price depending the period of hour of the day and the day in month.
I’m right at now.
My issue is to compute cost. I have a simple template sensor for each device with this type of state :
state = Utility_meter_energy * input_number.cost_€/kwh
And I save with Long term statistics this sensor in a cost utility_meter .
The issue that when the energy provider change the cost tarif (€/kwh) twice years, my cost sensors and utility_meter was updated with the new tarif provider price…
When i change theses tarifs, normaly, the yearly, monthly, weekly, hourly cost mustn’t change.
I would like to have then no cost change on old data of utility_meter but just take into account the new one for incoming energy cunsumption…