Here is a later template ouput showing correct credit amount:
and the corresponding dashboard output, with negative credit:
If the template outputs are correct, then perhaps there’s something wrong with the way I configured the energy dashboard or energy meter?
Yes very strange.
It looks like it is configured correctly from what you shared earlier though.
I can think of two things potentially.
- something weird with timezones
- other entities with the same friendly name that are being incorrectly used - > you could check for this by searching your entities.
My time zone is correctly set as GMT-7:00 Mountain Time. I searched all entities with grid, and each is unique. I think it may be something wrong with the entity that utility meter created. Do you know where utility meter keeps its files?
You are not using your utility meter on the energy dashboard but are in the calculations. Your utility meters are called Grid Energy Daily Total and Grid Energy Returned Daily Total.
Can you please post some 24 hour history charts of the Grid Energy Total and Grid Energy Returned Total sensors.
Also please try this in the template editor and past the results again.
daily electricity fee: {{states('sensor.daily_electricity_fee') | float(0)}}
electricity tariff: {{states('sensor.electricity_tariff') | float(0)}}
grid energy daily total: {{states('sensor.grid_energy_daily_total') | float(0)}}
grid energy total: {{states('sensor.grid_energy_total') | float(0)}}
grid energy returned daily total: {{states('sensor.grid_energy_returned_daily_total') | float(0)}}
grid energy returned total: {{states('sensor.grid_energy_returned_total') | float(0)}}
{% set supply = states('sensor.daily_electricity_fee') | float(0) %}
{% set usage = states('sensor.grid_energy_daily_total') | float(0) * states('sensor.electricity_tariff') | float(0) %}
Total daily tariff: {{ (supply + usage) | round(2) }}
energy returned daily: {{states('sensor.grid_energy_returned_daily_total') | float(0)}}
Total daily credit: {{ (states('sensor.grid_energy_returned_daily_total') | float(0) * states('sensor.electricity_tariff') | float(0)) | round (2) }}
I’ve been using HA in a docker container, but decided to set up a card with the disc image. It took some time reinstall sensors, devices, etc., but it is running now. I’m sorry to say that it gives the same results, as shown here:
As you see, your template gives correct values, while the energy dashboard does not. It’s clear that the problem lies within the workings of utility meter. The documentation for this helper is sparse, with its reference to a list of supported tariffs, but no info on what those tariffs are or how to deploy them.
I’ve decided to tell energy dashboard not to track costs, but instead to build a overview dashboard card to display those costs. I’ll use the templates you provided to feed that card. Thanks again for your help.
Can you please post a 24 hour history graph of “total daily tariff” where i can see the times on the x axis.
Also utility metre tariffs are of no use to you as you only have a single tariff.
Tariffs in utility metres are used to track the usage in different sensors in order to apply different charges. So the source sensor might be a total consumption sensor but the tariffs might be peak and off-peak splitting the usage into two sensors based on a separate automation telling it when to change over.