Adding Automation destroy yaml code

Hi guys,

if I add an automation via the lovelace interface it’s reformating other automation in an unfunctionable manner.
An automation changing the color on state like this:

      color_name: >
                  {% set color_map = {"0":"black",
                                      "1":"yellow",
                                      "2":"darkgreen",
                                      "3":"yellow",
                                      "4":"darkorange",
                                      "5":"aqua",
                                      "7":"red",
                                      "16":"darkred",
                                      "17":"darkblue",
                                      "98":"hotpink",
                                      "99":"orange"} %}
                  {{color_map[states("sensor.lieschen_status_raw")] }}

is changed to this:

      color_name: "{% set color_map = {\"0\":\"black\",\n                    \"1\"\
        :\"yellow\",\n                    \"2\":\"darkgreen\",\n                 \
        \   \"3\":\"yellow\",\n                    \"4\":\"deeppink\",\n         \
        \           \"5\":\"aqua\",\n                    \"7\":\"red\",\n        \
        \            \"16\":\"darkred\",\n                    \"17\":\"darkblue\"\
        ,\n                    \"98\":\"hotpink\",\n                    \"99\":\"\
        orange\"} %}\n{{color_map[states(\"sensor.lieschen_status_raw\")] }}\n"

This makes the automation not working anymore. Any ideas why this happen and how to avoid this?

Yep. The automation editor does not support lists well at all. For advanced automations like this you should use YAML rather than the UI editor.

1 Like