Data template in automation - stops working due to \n after reboot

So - I tried to make the presence script form here work:

It is all grand and dandy until I reboot Home Assistant - then the animations stops working, and when I go into my animation.yaml I find the code being torn apart by \n’s all over the place.

Any ideas or input on how to perserve the code?

  • service: input_select.select_option
    data_template:
    entity_id: “{% if trigger.entity_id == ‘binary_sensor.besokande’ %}\n input_select.gast_status_dropdown\n
    {% elif trigger.entity_id == ‘input_select.runar_status_dropdown’ %}\n input_select.runar_status_dropdown\n
    {% elif trigger.entity_id == ‘input_select.lotta_status_dropdown’ %}\n input_select.lotta_status_dropdown\n
    {% else %}\n input_select.siri_status_dropdown \n{% endif %}\n”
    option: Borta

The \n markers are text file line endings used mu DOS & Windows.

Some Linux distributions have a dos2unix or dos2ux command that can convert the file to the Unix line endings needed by Python.

But why do they appear, and how do I ensure that I don’t get them back? I have edited my automations.yaml so everything works for now.

Edit: For a few hours. Then I get the \n lines and broken code in the data template again. Any clues?