GUI: stop butchering my YAML's readability

, ,

On the left: how I wrote it; on the right: GUI’s “rewrite”.
Do I need to explain more?

I know… not possible with current implementation blah blah → then maybe there are other ways/libs that parse/write YAML a bit more intelligently?

It’s annoying isnt it?

The sad truth is that the way the YAML processing works in Python (HA’s language) it does not preserve the formatting when serializing the config back to text.

1 Like

It’s not python doing it.

Theres multiple threads out here with people complaining about comments getting stripped that explains what’s happening.

In short you’re not saving yaml it’s stored as JSON and it simply doesn’t store the comments. Therefore everything is condensed down, stored as JSON and ‘represented’ as yaml when you want to edit it. If you want yaml formatting etc you have to swith to yaml mode. On yor dashboards so it’s jot stored in the dB.

3 Likes

That doesn’t happen to me.
Oh wait, I don’t put manually written descriptions in the UI.

Aside from the snark, because I know you were expecting something from somebody, did you try enclosing in " the regular double-quote character, any different? If you add the description using the gui (shishk-a-bob menu-rename-description), any changes? That one places your text into the same double-quote character.
Just trying to see if anything improves for you.

This is likely because you specified that the the carriage returns should be stripped by using >, use | instead.

Have a play with the demo here: https://yaml-multiline.info/

Though as Nathan mentioned, the conversion yaml → json → yaml may affect this.