I use energy dashboard to track grid usage, solar production, and gas (LPG) consumption, and it tracks usage accurately. For gas, I pay a set amount per cubic foot, and for solar, I am reimbursed a set amount per kWh fed back into the grid. Those are set to static prices in the dashboard settings, and are displayed accurately on the dashboard page. It is a different matter when it comes to tracking grid costs.
For grid usage, I pay a set amount per kWh plus a daily access fee. (In the summer, that fee is almost as much as the kWh charge!) I point the dashboard to “an entity tracking the total costs.” Here is the code for the template sensors that make up that entity:
As you see, the total daily tariff adds the daily fee to the per kWh charge times the kWh used. Placed in the template section of developer tools, the code produces output such as this:
This output is correct. 4.95 kWh times .1342 plus .5103 is $1.17 (rounded to two places). However, the dashboard is presently showing this:
It’s not always zero; often the dashboard displays a negative cost.
Is there anyone in the community who has ideas on why the dashboard won’t display what is being correctly calculated? Or, is there anyone with code for “an entity tracking total costs” that the dashboard correctly displays? Are there developers of the energy dashboard around? I remain hopeful that somehow this could work.
Which sensor are you using as the cost sensor in the energy dashboard?
The energy dashboard does not support a daily charge. Only $/kWh. So if you are including the daily charge it will be charging you that for every kWh, not just once per day.
As the cost sensor in the energy dashboard, I am using the Total Daily Tariff template, as shown in the posted code. This template correctly calculates in the Developer Tools Template Editor. it does not add the daily charge to every kWh, only once when it is called. As far as I can tell, energy dashboard runs a cost calculation once each hour and displays that. If it takes the sum calculated in the cost sensor and displays that, it would be correct. Is there any way to examine the energy dashboard code?
That calculation, kWh used times cost per kWh, is contained in the “entity tracking total costs,” on the next to last line in code above. If all the dashboard can do is take a figure in a template and multiple it internally, then what is the point of an “entity tracking total costs?” That makes no sense.
I put this question to the community at large. Is there anyone who uses the energy dashboard to track electric costs, and who incurs charges in addition to a per kWh cost, that the dashboard will include? If so, may I see the code?
To be clear, the dashboard takes whatever price is contained in the cost sensor and multiples that figure by the kWh used in the preceding hour, totaling this through the day? I am left wondering why there are two separate entries, one “tracking total costs” and one giving the “current price”, if they are handled exactly the same way by the dashboard.
After reading the threads you linked, I went with the low-usage sensor (.001 kWh) outlined there. I implemented this as a separate consumption and it works. I’ve marked your reply with that link as the solution. Here is the code: