Automations.yaml being rewritten on upload

Sometime recently it seems that HASS has taken to rewriting my automations.yaml file (and maybe others) straight after I upload it… My file is generated by ansible, and the “diff” shown on upload is now full of changes, rather than just showing the changes I made. This makes the system pretty unusable for me…

I have seen individual automations get rewritten if I use the editor in the front-end, which I tried once or twice as a quick fix. I have no interest in using the UI editor, even in yaml mode, as most of the automations are generated.

Is there some way to prevent this from happening?

I’ve backed out to 2024.5.5, but that is the same. What version do I need to use to fix this issue? Hopefully I can back out to it while I take another look at alternatives to HASS? Too many things are now “new and improved” and moving away from being primarily controlled by yaml config. A great shame :frowning:

1 Like

Give the automation editor its own file to mess with and put yours in another. See: Automation inquiry - #2 by tom_l

I used to do that originally, but things like traces only worked for the main automations file, so I had to merge everything into a single file. Maybe that’s no longer the case and I can return to using the files in a directory like I used to…

Thanks for the suggestion, I will reconfigure and test.

Ah. I was not aware of that. It is probably still the case.

What sort of things is HA changing, even when you do not enter the automation editor?

It seems to be the ordering of the automations, still keeping my formatting of everything.

Interestingly I’ve generated and uploaded the single file of automations under a different name, but not yet told HA to use it. That file has been re-ordered too. So, unless it’s rewriting all yaml files that appear in the directory, something very odd is going on. Unless ansible or it’s diff is playing up, but I run that 100’s of times per day, and nothing else is misbehaving.

I need to look for a pattern in the changes etc.

And will still look at using the split files, as that’s the way I have them stored anyway, the ansible just merges them by including each in a template file.

I’m now very confused :frowning:

Weird. That does not happen for me when I edit the automations.yaml file directly (my preferred way to create automations), or when I use the UI automation list to look at automation traces.

And it looks like an inexplicable ansible issue… I generated the file to /tmp and a second run gives different results!

That’s more worrying for me, but again odd that it’s not happing elsewhere. There was an OS update to Rocky 8.10 a couple of weeks ago, so newer versions of things may have “improved” ansible in some way.

I’m glad that it’s not HA though.

Must still investigate if the split config works with traces etc, as it would be nice to get that part sane again.

But as it’s gone 2am here, probably something for later.

Thanks for your thoughts etc…

And for anyone who runs into the same issue, it seems that ansible templating (python / jinja2, like HA) using the difference function now changes the resulting list order each time it’s run, which it did not do before. So make to handle this somehow. For me, sorting the results works great.

None of my automations are in the automation.yaml, and the trace works every time.
I have 158 automations.

The automation.yaml file is parsed and re-written every time you make a change to it.

Both of these facts also apply for scripts that are stored in scripts,yaml.

158 automations, impressive!!

Screenshot_20240616_212346

1 Like

Rookie numbers :rofl:

2 Likes

Obviously I need to play catch up. I have as many or more device types, but only 81 automations. :roll_eyes:

It’s not how many you have but what you do with them. Theoretically you could put all your automations in one. It would be a nightmare to debug though.

LOL… I only have 269 automations :slight_smile: Many can be combined, but are indeed kept separate for debugging and control. At the moment all in one file because of previous issues, but this mornings task is to put the source files back as individual files in HA if indeed tracing etc now works on them.

I never make changes from the UI, partly because of that. I only change my source, then push from ansible.