How to delete Energy configuration and start again?

Since upgrading to HA 2021.9, I am no longer able to access the settings page for energy. I can still see the energy dashboard and it appears to be working correctly, however I am unable to edit or make changes to the energy configuration.

When I click on Configuration —> Energy, I get a page that says “Unknown error, Go Back”.

Is there a way to delete the configuration and start fresh?

System Health

version: core-2021.9.3
installation_type: Home Assistant Container
dev: false
hassio: false
docker: true
user: root
virtualenv: false
python_version: 3.9.6
os_name: Linux
os_version: 5.4.0-81-generic
arch: x86_64
timezone: America/Toronto


GitHub API: ok
Github API Calls Remaining: 5000
Installed Version: 1.15.2
Stage: running
Available Repositories: 880
Installed Repositories: 13


logged_in: true
subscription_expiration: September 16, 2021, 8:00 PM
relayer_connected: true
remote_enabled: true
remote_connected: true
alexa_enabled: false
google_enabled: true
can_reach_cert_server: ok
can_reach_cloud_auth: ok
can_reach_cloud: ok


dashboards: 4
resources: 7
error: /config/ui-lovelace.yaml not found
views: 17
mode: yaml


api_endpoint_reachable: ok

I got the same problem, anyone who can help with a solution.

See if you have .storage/energy in your config directory and try renaming it to energy.old.
I’d stop Home Assistant before removing or editing this file.

1 Like

@ondras12345 , when I rename the energy file to energy.old are the database and sensor data names then kept in place?

The file .storage/energy should only contain configuration for the Energy component. Sensor state history and configuration of the individual sensors should not be affected. You can open the file in a text editor to see what configuration you’ll loose by removing/renaming it.
Make a backup of your config directory and the database (home-assistant_v2.db), just in case.
I’d also shut down Home Assistant before removing the file.

I edited the energy-file (I had an impression what went wrong during setup of the energy card) and everything looks oke now. Thank you.

I have the same issue. I changed the costs (and somehow entered a comma instead of a point decimal); now I also get the error. Dashbpard works (with 0 for costs). But when I enter the configuration via Lovelace UI I get the error described above.

However, I do not have a ./storage/energy in my config directory (or I am too stupid to see it).

That should be .storage/energy, not ./storage/energy.
Filenames that start with a dot . are hidden in GNU/Linux, use ls -a to list everything.

2 Likes

:hear_no_evil: it really helps to know your terminal…Thank you!

Sorry, but I have the same problem. I don’t see the hidden .storage / energy folder.

It is certainly also due to my abilities. Thanks for your help.

Here is the associated error message from the log:

Logger: homeassistant.components.websocket_api.http.connection
Source: components/energy/validate.py:300
Integration: Home Assistant WebSocket API (documentation, issues)
First occurred: 12:22:22 (2 occurrences)
Last logged: 13:13:47

[140336684923248] Error handling message: Unknown error
[140336484362752] Error handling message: Unknown error
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/components/websocket_api/decorators.py", line 26, in _handle_async_response
    await func(hass, connection, msg)
  File "/usr/src/homeassistant/homeassistant/components/energy/websocket_api.py", line 167, in ws_validate
    connection.send_result(msg["id"], (await async_validate(hass)).as_dict())
  File "/usr/src/homeassistant/homeassistant/components/energy/validate.py", line 300, in async_validate
    hass.data[DOMAIN]["cost_sensors"][flow["stat_energy_from"]],
KeyError: ''

Here is the solution to my stupid question. Sorry ^^

2 Likes

I renamed energy file.
When I started HA and configured the sensor, all history datas are still present…

I have the same issue… Can anyone help me? When I click on energy in my configuration, I get this error. How can I solve this problem?

Schermafbeelding 2021-10-23 om 16.04.50

This should allow you to delete your energy configuration and start over again.
See my other posts in this thread.

You should be able to just go to Configuration…Dashboards…Energy. Then just add/remove/edit sensors and configurations as needed.

7 Likes


Hello Guys,
I’ve got same kind of problem. A sensor name is too long and make disapear the trash bin for this input.

How can I delete it by hand?

Thanks :slight_smile:

This sensor is generated by the energy dashboard, what’s the reason you want to remove this ?

Edit: hmmm, your right, that is most likely a “bug”

Edit: i have reported below Bug:

1 Like

You should be able to manually edit the json file in .storage/energy. Don’t forget to stop Home Assistant first and make a backup of the file.

Or just delete it as I have described in my previous posts. You shouldn’t lose any actual data, only configuration of the energy dashboard. You can then set it up from scratch.

1 Like

Guys I’ve been able to delete it via the inspect function of the browser. But anyway it’s still a bug.

Thanks for your help :slight_smile: :grinning:

1 Like