I mistakenly deleted contents of configuration.yaml using Studio Code Server. I have not restarted HaOS yet and run a check and got the following errors:
➜ / ha core check
⣷ Processing...
⣾ Processing...
⣻ Processing...
⡿ Processing...
Processing... Done.
Error: Testing configuration at /config
INFO:homeassistant.helpers.storage:Migrating core.device_registry storage from 1.8 to 1.9
INFO:homeassistant.helpers.storage:Migrating core.entity_registry storage from 1.15 to 1.16
Fatal error while loading config: 'NoneType' object has no attribute 'items'
Failed config
General Errors:
- 'NoneType' object has no attribute 'items'
Successful config (partial)
What have I done and how can I fix this?
Anyway to restore? Studio code server keeps reversions history?
If you have an unencrypted backup, unzip it and copy over the configuration.yaml file from there. Do not restart until your system passes a config check
And start a backup before you do any serious adding of stuff.
All the backups made using automatic are encrypted. Backups made manual, which is the system that was available previously, you control that.
The entire first hour explains backup very well… Jump link:
The operative configuration is obviously in RAM, but not in the format of configuration.yaml. A typical configuration spans many .yaml files, !include statements, and a combination of formatted (and commented) YAML and Jinja code, some of which is consumed not by HA itself but by third-party integrations. Plus some configuration can be done either in YAML or in the UI, and is encoded differently depending on where.
A user-friendly tool to somehow glean all of that from a running instance and put it into a format that can be read at startup is a tall order, but that’s what you’d need in order to recreate the file you inadvertently deleted. Reinstalling HaOS, especially when you haven’t done that much to customize your system, is honestly a really small effort by comparison. And you can avoid ever needing to do it again by setting up backups.
Yes, because of all the HA files, you went and deleted the most important one.
No, they are in the file you deleted. Everything still works because it grabs those instructions at boot.
I gave you a copy of my file to work with. Just save it as configuration.yaml and copy it to your install. Run configuration check, fix issues if found, done.
Stop with all rebuilding from running configs nonsense.
Not as funny as not having ever made a backup, then nuking the most crucial file, yet here we are
Just a figure of speech. At this point what have you got to lose by creating a blank file called configuration.yaml. I think everbody is very interested to see what happens when you try to reboot.
Vscode has feature for file history, if you deleted part of the file’s contents and not the entire file. So theoretically you would find the deleted content there
So how is people going to work with the file if is protected?
Although not. As frequently as before, but sometimes you need to do something in there or look something up.
There are many way to protect the files.
1- Keep revisions
2- Create backups as system default
3- Add a notification at top of the file that warns
4- Don’t make the system so complicated that finding info to rebuild the system configuration would be hard
5- Have a running config that is easily downloadable (Cisco routers for example…)
6- Use files but upload settings to DB or vice versa for backup
…
And there are many more ways that programmers can think of to make this work. It will happen eventually. It will be a matter of time.