Entity ID for values in "Energy sources table"?

I added my energy sensors to the energy dashboard and the energy appears on the dashboard, very accurately and easy to read.

Now, i would like to add the cost for every energy source.

My utility company has different price tiers and I want to create an entity to calculate the current price depending on how many kWh I have consumed so far. Then use that entity here:

My understanding is that the entity I need should be a “helper” template and that it must be based on some other entity providing the consumed kWh. This is where I’m Stuck.

Ideally I want to use the entity that appears under the “energy sources” card. Below is mine for this month.

I want to use this instance because it is adjusted automatically when a different time range is used. For instance, this is the same source but with a time frame of “Today”.

What would be the “Entity ID” for these values?

If I go to the sources table and click on this instance, I found that the Entity ID for this sensor is “sensor,meter_electric” which is my RTLAMR2MQTT sensor.


OK, if I use that entity in my new helper-template to calculate the cost depending on the kWh, it will base that calculation on 26,447.30 which is the current reading on my utility meter, instead of using the accumulated energy for this period (6.86 kWh for TODAY or 349.63 for this MONTH).

So, how can I find the entity ID that home assistant uses to show the energy consumption in the “Energy Sources Table”.

Note, i have seen multiple people suggesting to create a “Utility meter” helper to keep track of the energy consumption and assign it a cycle of monthly, quarterly, daily, etc. Then use that instance as the base for the template-helper to calculate the $/kWh.

The problem with this approach is that it will accurately calculate the $/kWh only for that billing cycle and will be wrong for everything else.

For instance, if i create a Utility meter for the montly consumption, then it will base the calculation on 26,447.30. This may result in 0.12$/kWh. However, if i change my time range to “TODAY”, then the sources table will show a power consumption of 6.86 kWh which should use something like 0.15$/kWh but because i based its cost on a different instance that is monthly, then it will use 0.12$/kWh.

Because of this inaccuracy , I want to avoid using the “Utility meter” if possible.

The dashboard calculates it on the fly, so the entity you are looking for isn’t there (yet). So you do need the utility meter to sum the calculate the period you want to calculate the cost for, before you can calculate how much you need to pay per kWh. The utility meter is used to determine the usage in the same period the energy company uses to calculate the tariff.

That sensor you can feed in the energy dashboard as the price per kWh. The dashboard only needs to know the price for now to work properly. So selecting a different period in the dashboard will not have discrepancies. It will use the price it had at the times that the dashboard displays.

I think you fundamentally misunderstand what’s going on here under the hood.

When you select “Entity with the current price”, what happens is this:

  • Energy integration creates a new (hidden) sensor entity called sensor.meter_electric_cost.

  • Anytime sensor.meter_electric increases, say from 100kWh to 101kWh, it multiplies the “current price” by the amount of the increase. It then adds this amount to sensor.meter_electric_cost. So if your current price sensor is 0.15c/kWh, everytime the electric sensor increases by 1kWh, the cost sensor increases by 0.15c. If current price sensor is 0.30c/kWh, the cost sensor increases by 0.30c.

  • The accumulating cost entity is stored in statistics just like the meter_electric sensor. Then when you open your energy panel to look at July of last year, the energy used comes from the history of the energy statistic, and the cost displayed of that energy also comes from the history of the cost statistic.

  • The current state of your “current price” entity, or the “_cost” entity, is not used at all in displaying information on the energy dashboard, only the statistics of the cost entity are used.

2 Likes

Thank you guys.
Let me experiment with this new information (new to me) and i will report back

1 Like