WTH isn't "YAML configuration reloading" automatically detecting changes?

I think a substantial improvement could be made to the “YAML configuration reloading” screen/mechanism.

As stated in the UI: “Some parts of Home Assistant can reload without requiring a restart. Clicking one of the options below will unload their current YAML configuration and load the new one.”. It’s quite a struggle for many users to find/understand the correct “part” that they need to reload to apply their yaml changes. Additionally some parts of the yaml configuration require a full restart, but it’s not directly clear/visible that that is the case.

It would be great if HA could automatically detect changes in the yaml configuration, and would suggest to the user which part they need to reload or that they need to perform a full restart to apply the pending yaml configuration changes.

[update: Added two visual examples, to clarify this WTH.]

Example 1: A user makes a yaml modification for “input booleans” and then goes to the “/developer-tools/yaml” screen. A new label “changes detected” is now visible.

Example 2: A user makes a yaml modification in the config that requires a full restart, and then goes to the “/developer-tools/yaml” screen. A new label “changes detected” is now visible.

Very good idea!

The answer to this is pretty simple: It can be super problematic.
What if you needed to edit multiple YAML files to make your references complete (e.g., when using packages or another split mechanism?) When would it reload? When you are half way done?

Oh, note: you could write automation to do this if you like. E.g., set up a sensor to trigger the change of automations.yaml, which calls the reload service.

Yeah, I wouldn’t like this. I press CTRL+S by habit when editing any text file, even if it’s partially finished. No thank you. That would just be constant errors throughout the configuration process.

Maybe I wasn’t completely clear. My proposed solution was not an auto-reload at any moment.

Just showing/suggesting to the user which part they need to reload (in case a specific yaml reload is available, e.g. input booleans, input buttons, etc.). In case the YAML configuration changes requires a full reboot to apply, showing/suggesting to the user that they need to perform a full restart.

For example, if I update an integration in HACS, it shows a suggestion to perform a full restart.

That’s not a yaml change. That’s added python libraries. It requires a restart no matter what to load the python files. Also, that’s HACS, a custom integration.

@petro it’s just a screenshot of a notification/suggestion…

That’s the only notification that tells the user a restart is needed. Literally. And it’s only provided by HACS when new python libraries are installed.

I know that, but what do you mean by this? My WTH is about the /developer-tools/yaml screen, and not in any way related to HACS.

Dude, you literally posted a screenshot of HACS after telling me that your intention was to not auto reload yaml files. So you’re refuting automatic YAML reloads which is tied to the developer tools by saying “I meant the HACS restart”. At the same time you’re refuting “HACS reload by stating you meant the developer tools.” So which is it?

Auto reloading yaml requires you to scan for all changes. Even if this doesn’t auto restart, but checks the config, it’ll still cause all sorts of errors in your logs. At best you’ll get a flashy button saying it saw changes, otherwise the WTH will not be appetizing to anyone who plans out their changes with frequent saving.

Auto restarting after HACS install is out of scope for the WTH.

Auto scanning is technically always problematic. Even for just a notice tag. I wouldn’t do that.

But a single button, something like Reload YAML changes could replace all the individual reload buttons we have now. Upon pressing it, the system would explicitly reparse the YAML, compare to the previously active one. It would then proceed to only reload the parts that actually changed.

1 Like

I’m interpreting what davyha said about hacs to simply be an UI example. It could have been completely different software, totally unrelated to HA.

I can understand this wth. If Home Assistant can’t suggest specific integration reloading or restarting dependent on the changes (because of reasons), then what would still be quite nice is if it could work a bit like the *nix diff tool. Show a copy of the config as it was last loaded, then show a copy of the current config (that was externally edited and saved by the user), highlighting the differences, diff-style. It should be easy and safe to detect if a file in the config tree has changed and highlight those changes, without doing any other validation at that point, right?

Also, what HeyImAlex said :slight_smile:

I just updated the first post with two visual examples, I hope this will explain my WTH better.

That would be a change that I can get behind. It’ll still be quite the challenge because of packages and includes. HA would basically have to silently reload the yaml in order to find what section they are in before actually performing the reload.

Yeah it would need a silent preparsing stage. Not sure if the YAML loader architecture in HA supports this out of the box. If not, it could be a pretty time consuming change and would probably not be worth it.

It does not. The information would have to be spooled/cached on startup/individual reloading. The built in yaml loader doesn’t even do packages, that’s an HA only thing. So that whole section of code would need to be handled separately as well.

What if instead of it being automatic -
when you press the check config button, THAT is when it would check the validity of the config, and then after that it would perform this step, to figure out what can be reloaded dynamically and what requires a full restart?

This WTH has now become obsolete with the recent addition of the “All YAML configuration” button and the prominent “Quick reload” functionality (reloading all YAML configurations) :slight_smile: