Adding comments tags to automations, scripts, scene etc

I typically just rename blocks to be more descriptive. That way future me knows what current me is actually thinking. It’s not as good as a comment block, but it works for now.

1 Like

I put it all in the description block for paragraphs, otherwise you can add # or {# #} comments everywhere as long as you don’t save it in the ui editor, that strips all the things including spaces for efficiency in the storage when it parses the code to make sure it works then saves it in automaton.yaml

1 Like

I generally use the UI editor to create the automation, then move it to a my_automations.yaml file to tweak it and add comments. If future me really needs to use the UI for some reason, he can always copy and paste the code back to automations.yaml or right into the UI. Hasn’t happened yet.

Organising and annotating automations.

I do, but it’s not maintainable having a long name like “nodered flow X uses this value with event K that’s misaligned of N minutes”.

on next UI saving (that can happen, it’s easier changing via UI instead of doing SSH login to server and manually change automation), all the comments will be stripped out, so it’s a bit risky

Thanks, I guess I didn’t explain that well enough.

I have a second !include statement in my configuration.yaml which points to my_automations.yaml:

automation ui: !include automations.yaml
automation manual: !include my_automations.yaml

My “production” automations are in this second file, which HA can’t edit. It still loads and runs all the automations, but it can’t re-format them, erasing all the comments. No need to SSH in to edit, I use SMB.

I only use the UI to create new automations using logic I haven’t used before. Otherwise I just copy-and-paste from existing, working automations. Once I’ve got one working the way I like, it gets moved to the my_automations.yaml file. In a pinch, I can always move them back for more development work in the UI.

As I’ve said before, there are other ways to document your automations. This method was what was available when I started with automations, and it works for me. YMMV.

2 Likes

it’s the first time I see this smart use of include statement, very interesting, thanks!