My ESPHome Installation must be corrupted. How can I fix without loosing the nodes?

I have a problem with compiling for one node. Turns out there is a mix of ESPHome version files that causes a problem with include statements for ‘esphal.h’ vs. ‘hal.h’.

The addon shows to be version 2021.11.04, but the version files for the nodes show 2021.10.3.

Also the node shows on the ESPhome page. I can edit and install the yaml file (as long as I remove the sensor that causes the offending include statement). But the node does not show in the list on the integration card for ESPHome.

I believe the ESPHome addon installation is corrupt.

Can I repair the installation?
If I uninstall and re-install the ESPHome addon, will I be able to connect (through WiFi) to the nodes again?

version in file

You can save your YAML files, at the very least you can manually recreate your nodes and at best it will just work :frowning:

Install the SAMBA add-on, start it and browse to the config share.

Your YAML files are in the config\esphome directory, copy them to your pc.

Uninstall ESPhome addon and reinstall.

I would then stop ESPhome, copy the YAML files back across and restart ESPhome.

At best - all your nodes should be back.

At worst you have saved the YAML files and can manually recreate.

Someone has probably already done this so they may have a definitive answer.

If this was already added at one point to your esphome install, inside the esphome folder and/or .storage folder there maybe additional files related to this node.

Some will have random names and you will have to use a text editor to open the files. If there are any config files relating to this one node move them out of the esphome/storage folder.

Thank you for your help.

Yes I already copied all my yaml files. Also made a full back-up just in case.

But, I do not think simply re-using the yaml files will connect to the existing devices? Some of these devices are hard to get to because of the location, I rely on the wifi connection.

There must be a way to force a re-install of ESPHome without loosing the nodes?

Thank you for the suggestion.

The problem is that the file that has the bad include is auto generated by ESPHome. Essentially all nodes have a problem, but only the one node uses hal.h and therefore gets into trouble with the compile. I must somehow repair the whole ESPHome install without loosing the nodes.

I installed ESPHome from the beta channel. Which worked, but it did not solve the problem.

So I lost hope that this will solve itself with updates. It looks like ESPHome is doing a partial update and leaving the offending file as they are.

I’m getting hopeless. I absolutely do not want to rebuild every ESPhome node in my setup, rather abandon HA all together.

Ok hang in there we should be able to get this sorted. It’s those files that I spoke of. You said you have all the yaml sketches saved already, I also want you to write down the ip address of each node.

First go to integrations and remove all the esphome nodes. Then go to the supervisor and uninstall the add on. Now go to .storage remove all files that refer to esphome. You can cut or rename each file to .old.

The esphome folder itself rename to esphome.old. Once that is done go to the supervisor page and on the system tab choose reboot host.

Once everything reboots, heads up this one takes a little longer than the standard server restart. Go to the addon store add esphome. Then go to the intgration page and if the nodes aren’t auto found, use the add button choose esphome and start adding the ip addresses.

Everything should be working at this point. You can then go an add the sketches to esphome and copy over their yaml files. These are only needed to modify the nodes.

Thank you!

Nice task for a rainy Sunday.

Scary, but I guess I can always restore a full backup and be back where I am now? I have no experience never used a backup yet.

Small problem:
The offending node called ‘water’ does not show up in the list on the ESPHome card. So I cannot remove it from there. What do I do?
I do not find a .storage folder anywhere in the homeassistant directory (I use samba to access). Where do I look?

That’s exactly what it does.
You can safely delete EVERYTHING else in the /config/esphome folder as long as you keep those YAML files. They are the only thing that matters, everything else will be recreated when you instruct ESPHome to build the firmware again.

Also you can safely remove the esphome addon without needing to do anything else, when you remove an addon, you only remove the docker image (and container) and it’s own data directory. No addon will remove anything from the /config/ directory - this is also the reason why backing up NodeRed or restoring it, will catch people out, because it’s only the Config Data that you are backing up - the flows themselves are actually stored in /config/ which doesn’t get backed up when you are only backing up NodeRed.

Are you on windows, you have to go into windows folder options to show hidden/system files.

The offending node called ‘water’ does not show up in the list on the ESPHome card.

That’s fine renaming the files and folders will take care of that.

Backup restores are pretty straight forward and painless.

Got it. Thank you.

Thank you!

OK. That’s interesting. But I do not see anything in the yaml file that refers to the actual node. How does it link to a node, is the MAC address stored somewhere or?

And how do I restore a yaml file? Do I create a node with the same name and then copy paste the yaml file content?

The NAME of the node, is how it knows. The node connects to WiFi and gives the router it’s “hostname”, so it could for example lightswitch1 and then the DNS domain is added to the end, for home users this is usually .home or .local. You can test this yourself by opening a command window and typing ping followed by the device name eg:

ping lightswitch1.local

and if you have done it right, the device will respond to the ping (and you should also see the IP address that the router returned for the device), and you know it is alive.

Here is me pinging the Livingroom Thermostat just using the ssh addon:

Now you can see that when I try to connect to the device with ESPHome:

That is all it is doing, asking the router for the IP address for the devicename followed by .local, although in my case it’s asking for a different domain, because I specified that in the YAML file itself.

Well, we did have that rainy Sunday, so I followed your guideline and it has worked. All is well. Thank you!

There where a lot more files in the esphome directory, that has all been cleaned up.