Yes, this beautiful thing:
Home Assistant introduces the Energy Dashboard here.
Answer
Home Assistant stores energy dashboard related data in long term statistics, frequently referred to as LTS. In order to retain your energy dashboard data you must ensure the LTS are transferred from your old entity ID to the new one. To do so, follow these steps:
- Backup your Home Assistant, in case something goes wrong.
- Remove the old entity or remove the integration this entity is associated with.
- Reboot HA OS, or reload your docker container if you run core.
- Verify that the old entity ID has been removed in dev-tools->states.
- Change the entity ID of the new entity to be identical to the old one (the one you just removed):
(
sensor.my_new_energy_device
->sensor.my_old_energy_device
) - Check that statistics have carried over. One way to do this is by checking that the energy dashboard still shows your old graphs.
- (optional, only from HA version >= 2023.4) Change the new entity ID to whatever you like, the statistics should carry over. This feature was added in Home Assistant 2023.4 so this does not work on older versions.
- (optional, only if you completed step 7) Update your Energy Dashboard config to the new entity IDs.
Answer
First of all, make sure you are adding an energy [kWh
or Wh
] entity and not power [kW
or W
]. In case you have a device which provides instantaneous power only, read question #3 for instructions on how to convert power to energy.
For an entity to be visible in the dropdown menu it must have the following attributes, which you can verify in dev-tools->states.
state_class: total_increasing
orstate_class: total
unit_of_measurement: kWh
orunit_of_measurement: Wh
device_class: energy
If all of these attributes are set correctly check dev-tools->statistics to see if there is any issue that needs your attention. Simply pressing FIX ISSUE
is enough in many cases.
-
If your entity is provided by an integration please create an issue on their GitHub page and refer to this FAQ.
-
If your entity is provided by a template sensor, you can specify the correct
device_class
,unit_of_measurement
andstate_class
attributes directly in the template sensor YAML config. See the template sensor docs on how to do this. An example config of a correct energy sensor could be:
template:
- sensor:
- name: 'My Energy Sensor'
device_class: energy
unit_of_measurement: kWh
state_class: total_increasing
state: {{ states.sensor.my_energy_sensor.attributes["energy"] }}
Note that this option is not available in the legacy sensor configuration format, so if you are still using this you will have to move over your YAML config to the more modern format to make these attributes available.
Answer
Power in W is the rate at which energy in Wh is consumed. For example, if a 1kW load is on continuously for 1 hour it will have consumed 1 kWh. Thus to compute energy from power we need to integrate it over time. Luckily for us HA provides a convenient integration for this: Integration - Riemann sum integral, named after the famous German mathematician who first formulated it.
If you have a sensor that provides you with power readings in Watts (uses W as unit_of_measurement
, device_class
of power), then you can use the integration sensor to track how much energy is being spent. Take the next manual YAML configuration as an example:
sensor:
- platform: integration
source: sensor.current_power
name: energy_spent
unit_prefix: k
round: 2
This configuration will provide you with sensor.energy_spent
which will have your energy in kWh
, as a device_class
of energy
.
See also this explanation for a more detailed discussion on power and energy.
Answer
To understand where this weird spike comes from, you need to understand how changes to the state of the sensor are interpreted by Home Assistant.
If the state_class of the sensor is total_increasing
, a lower state (even from e.g. 1000
to 999
) will be interpreted as a reset of the sensor. So in the example above, HA will think the sensor has been reset to 0 and then increased to 999
again. So the value used for the long term statistics will then be 1999
(1000
+ 999
). That means if for some reason your sensor will be 0
temporarily, and then go back the the correct state, the value will be doubled. Therefor it is really important to avoid decreases of the sensor value, which can be avoided by using a proper availability
template in case you are using template sensors.
On the other hand, if the state_class
is total
a decrease of the sensor value will cause a decrease of the value in the long term statistics. So in case such a sensor drops to 0, you will see a negative spike, unless the last_reset
attribute is set to the date and time of the reset, in that case it will be interpreted the same as for the total_increasing
sensor, and new values after the reset will be added to the existing value.
If you have a spike in your data, you can correct this in dev-tools->statistics. Find the sensor there, and press the icon at the end of the line. You then can either:
-
Find the faulty value, and set it to
0
. -
Add a correction value in the same hour, which is the opposite of your faulty value.
NOTE: The states in this view are reported at an interval of 15 minutes, so it might take some effort to find the faulty value.
Answer
Most likely you are not using default_config:
in your configuration.yaml
file. To make the energy dashboard visible add the following line to your config: energy:
6. I want feature x in the energy dashboard or I want to customize item y to my liking, how can I achieve this?
Answer
Unfortunately the frontend of the energy dashboard is currently not configurable. Customization will likely become possible in the future as functionalitity is constantly added to Home Assistant and the energy dashboard is very popular. In the meantime you can either:
- Add the desired functionality yourself, if you're a developer with some spare time. Getting started is very simple.
- Make a feature request here if you're not.
- Add the energy cards to your own custom dashboard. See also question #7.
Answer
There is a popular feature request for this and the HA core PR for it is still open. In the meantime you can use the energy cards with a custom dashboard and combine it with the awesome energy-selector-period-plus community integration, available in HACS.
Answer
The energy dashboard automatically calculates the cost for grid consumption entities and the compensation for return to grid entities by writing the result to internally created entities. These monetary entities are named automatically according to the following format:
'<entity_id>_compensation'
for return to grid entities.'<entity_id>_cost'
for grid consumption entities.
Where <entity_id>
is the entity ID of the input sensor. For example, if your grid consumption entity has entity ID sensor.energy_consumption_tarif_2
then the cost entity will have the entity ID sensor.energy_consumption_tarif_2_cost
. You can find these entities by navigating to dev-tools->states and searching for *_compensation
or *_cost
.
NOTE: Any modification to these entities outside the energy dashboard will likely break things, so be careful.