Ignoring invalid YAML section and start HA anyways

I am a heavy Home Assistant user and use it for almost everything in my house and sometime it happens that I restart HA by pulling it from the plug, which skips the YAML validation check at shutdown, which then at startup leads to a dead HA, if something in the YAML is invalid.

This has happened to me multiple times now and sometimes I wait almost half an hour before realising it got stuck and that I must check the logs via SSH.

It would be more than nice to include a feature that HA skip the entire YAML section that is invalid and proceeds to start anyways, and possibly display a message on successful startup that something was invalid and was not loaded.

Another nice thing would be starting the 8123 server before anything else, so it can stream any logs directly to the broser while starting, letting the user know what is happening and if it got stuck. I was thinking something like a normal loading screen without much information, but if something fails, it would display a exclamation and display the error(s).
(Because staring at a “connection refused” screen for 10 minutes+ doesn’t let you know much)

This would be very nice :slight_smile:

Very bad idea, you are begging for system corruption.

Why not just use the config check tool before pulling the plug if you insist on restarting that way. I am pretty confident in my ability to create a correct config file yet I check the config before every restart, even if I only change 1 line. Its quick and avoids the issue you are describing.

Edit:

Sometimes what you describe can happen. Othertimes due to the incorrect YAML it is making a huge chunk of the config file unreadable by the system to to a configuration error. An errant quote or incorrect indent can really change how the config file is read. This isn’t as simple as skipping a few lines of config.

Yes, I know it’s not the right thing to do, but sometimes it happens. Sometimes we have power outtages too and such, which then lead to the same problem.

Why are you leaving your configs in an invalid state? Shouldn’t you edit them, and validate before it shuts down?

If your config is up and running and is valid, a power outage isn’t going to change that. It
should recover to the same previous valid config.

It also does, but the main focus here is that HA should start up anyways, because the only thing we see is “Connection refused” for an eternity and we never know if it’s going to start up or not.

How do you propose it ignores your invalid yaml (which it needs to start up) and continues to start with invalid config?

You have a log file too.

Just the section which failed, not the whole file.

But in the browser not, I never know if it’s going to start up or not. Connecting to SSH everytime to see is not that practical…

Tjat’s just now how it works. The configuration is loaded as a whole, and if there’s something invalid in there, everything is invalid.

That’s actually a personal choice of yours. You should validate your config whenever you make a change. If you start something and want to continue some other time, leave the yaml commented out until you’re done.

1 Like

No, I mean in general. You’ll never know when HA is going to start up.

??

I know that my HA starts up correctly every time…

1 Like

In conclusion, this thread is a terrible idea and the OP needs to change his operating practices.

/narration

*next…

2 Likes

I’ve listed two distinct ideas.

I think I should do another thread just with the last one, because it appears to give confusion.

The problem is, that starting HA anyways is problematic if the yaml is invalid, because that’s where required information is. The next best thing would be to have some sort of default-fallback configuration. But depending on the type of setup that could actually be a huge security problem.
Another idea would be to always save a backup of the last known valid configuration and replace that on every successful start. Then in case something goes wrong there would be a valid configuration to fall back to. But that’s really a separate topic.

1 Like

I use frontail. Using a browser, I can monitor Home Assistant’s log file during startup.

The log is streamed to port 9001. You view the log by simply pointing the browser to http://YourServerName:9001

3 Likes

Believe me ha is now much better than it used to at starting with config errors.