How to clean up the ESPHome folder?

My ESPHome folder seems to be a bit of a mess.
What files and folders in my ESPHome folder are required?

I have lots of duplicates and even what appear to be some ole files for devices that don’t exist.

I have been using ESP to some extent pretty much since it was released so I am guessing my question is as a result of things changing because I have never manually added or removed anything from it.

I suppose the question boils down to:

What does a fresh ESPHome installation look like (with some devices, obviously).

Yes, this came to my attention lastly as well when I was browsing through. It’s a mess…

Have a look here, it explains how to do it

1 Like

This is untested but should work:

  • Copy the entire config/esphome/ folder. Copy it somewhere safe. You can always paste it back if something goes wrong.
  • Delete the whole contents of the config/esphome/ folder.
  • From the copied folder paste back only the <device>.yaml files for the devices you actually have. Don’t worry about its associated sub folder. Just the yaml files.

The next time you go to update a device it will take a little longer as the dependencies download and it creates a clean build.

There are also a bunch of (temporary?) files in .storage but I don’t know enough about them to give you any advice.

EDIT: This is exactly what the video above says to do.

4 Likes

Thanks everyone.

The only thing I do is to delete stuff from the espome/.,esphome/build folder…as this is part of my backup
From what I see, whatever I delete is re-added as soon as I update the device via esphome so (imo) no risk

Doesn’t the “Clean Build Files” menu option on each device take care of this cleanup?

admitting to not know of this, I just kept my old base yaml way too long (only rpompted by db backup) and just deleting those does not deleted the build.

It does not remove the old data left behind when the folder layout changed. It only recompiles in the new location.

Thank you so much!!! I read your post in probably 15 seconds, and understood exactly what I need to do. That is so much better than sitting through a video!

This is especially timely for me. I recently stopped updating devices from the ESPHome add-on, and switched to running the ESPHome command line on my laptop. The laptop has more disk, memory and processor resources and doesn’t impact HA when compiling and uploading. This is critically important for those of us who are still running HA on a RPi with an SD card as it was originally advertised. Fewer writes will prolong the life of the SD card.

I know this is about /config/esphome folder but the addon itself grows in a lot in size if you have lots of devices and update/change them regularly. One example is .pioenvs folder wich is not normally accesible. At some point, because of this (with tinylibre addon installed as well), a complete ha backup restore takes ages (2+ hours). So i need to regularly delete and install these addons wich is not that great… One alarming message when compiling was “Found ~5GB of unnecesarry files please run x command” (was testing bt proxies on esp32c3 with bsec libraries and radar too, bsec never worked), where x i cant find as the time of writing and i’m sure it wont work anyway because I get “zsh command not found” and i dont know what zsh is.
One thing i tried is installing esphome manually on the host computer/different computer and copy all the yaml files and it works fine but then i don’t need the addon anymore and i like it being usefull (other than ha reading esphome api passwords when registering device).
Update: a ha backup does not store those folders so the restore process takes so much time because of other (unknown) reasons.

How to this now since it moved to /data? I can’t see the content it in other addons like VS code. I guess permission issue.

Where is the Home Assistant Supervisor /data directory located? - ESPHome - Home Assistant Community (home-assistant.io)

best discussion about this is here, although no solution

Update: i have posted answer there

So on the supervised install the ESP device yaml files are in:

/usr/share/hassio/homeassistant/esphome

There are a ton of file in:

/usr/share/hassio/addons/data/5c53de3b_esphome

For me it takes up over 7G of space. Is it correct that I could delete everything under

/usr/share/hassio/addons/data/5c53de3b_esphome

with out causing any issue to the system? Then the next time I compile my devices because of an ESP update release, all the files in this addon directory would be regenerated? So basically I’m asking for verification that everything in the esphome addon directory is non-essential and gets recreated if needed.

I have posted answer for the HA OS here Where is the Home Assistant Supervisor /data directory located? - #40 by evlo