YAML formatting when using blueprints GUI

I’ve always used Visual Studio Code plugin to edit and create my automations. My formatting looks like this:

    - service: frontend.set_theme
      data:
        name: >
          {% if states.sun.sun.state == "above_horizon" %}
            kibibit
          {% else %}
            kibibit-dark-cardsrk
          {% endif %}

Last night I decided to try out the new blueprints feature and used the GUI to configure a few blueprints. Unpon returning to my automations.yaml file I see formatting changes I dont like, now the above example looks like:

  - service: frontend.set_theme
    data:
      name: "{% if states.sun.sun.state == \"above_horizon\" %}\n  kibibit\n{% else\
        \ %}\n  kibibit-dark-cards\n{% endif %}\n"

Am I doing something wrong?

How can I use blueprints and keep my formatting in place?

If you want to format your own code, then write it yourself.

If you want to use the gui, use the gui - it doesn’t matter what a mangled mess it makes behind the scenes as you’re not looking at it.

1 Like

Moral of the story is pick hand editing or GUI but don’t mix if want to keep your formatting?

1 Like

Afraid so.

As a sort of workaround I wanted to post this to help others.

What you can do is to save away your existing (custom) formatted automations.yaml file in a folder called “automations”, then in your configuration.yaml so something like:

#used for the testing of the GUI editors and blueprints
automation: !include automations.yaml

#regular yaml automations go here (custom formatted)
automation yaml: !include_dir_merge_list automations/

This way your automations.yaml can be used to GUI type stuff and maintain its own formatting while preserving your hard work.

Thx @anon43302295 for help

Also described in the documentation (includes an example for separating manually created automations from the ones created via the Automation Editor):

# My own handmade automations
automation manual: !include_dir_merge_list automations/

# Automations I create in the UI
automation ui: !include automations.yaml
1 Like