I have a utility meter entity that tracks the kWh comsumed in the peak and off peaks periods.
I then have a template entity that calculate the yearly cost
Store the tariff in a helper. Take your daily consumption (take the previous period attribute from a utility meter with a daily cycle). Do this by triggering an automation on a specific time and take this previous value together with the tariff helper to calculate the last day’s total. Make a second helper, an input number, to store the running total. Add your new (calculated) value to the helper’s value. Wrap this helper in a template sensor and give it a state class for long-term tracking.
Now, if you change the tariff today, with tomorrow’s run it will calculate the total for today using the new tariff.
How can I apply the result of an operation (unit rate * daily consumption) to an input number?
The only services I see are ‘increment’ and ‘set’ (which needs a defined value)
In fact, you don’t even need that helper I just realised now. You only need the sensor I referred to as the wrapper sensor. In it’s value template you can reference the current value too.
Ok, but this way my sensor will only update every 24 hours, right? Right now it’s continuously updating (almost every second) but I can’t change the tariff without affecting its value
P.S. I don’t think input number set can take a template