How to delete Energy configuration and start again?

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

Hi guys, I’m trying to ask you about a problem I’ve been having with Hass for a few days, I haven’t found anything on the net that would solve the problem.
The energy dashboard no longer works, it doesn’t load the page, but above all if I go to the dashboard configuration it gives me an “unknown error” without being able to do anything.
I noticed that as soon as I start hass and go directly to the configuration for a fraction of a second it appears and then always displays the error.
I did the updates and restored the back even a few weeks ago but it does not solve the problem.
I’m very arrbiato because I think I’ve lost all the statistics right now that I’m installing the photovoltaic and I wanted to make comparisons on consumption with active photovoltaics.
Do you have any suggestions?
I’ve been going crazy for a week.
I also deleted the file in storage/energy, but sometimes the configuration page appeared to me but it can’t find the “energy” sensors to activate, despite the fact that in other dashboards it displays them regularly, it’s stratta si shelly em

One picture says a thousand words. Thank you!
After being stuck with Unknwon error for so long, now i can see it again :slight_smile: