Adding "id:" to an automation makes it vanish - bug?

Hi,

I was trying to turn on an automation from another automation - which I have managed to do now, this question is not about that.

But I - erroneously - thought I had to edit the Yaml to add an ID. Then the weird thing happens: if you add an “id: X” line to your automation, it vanishes.

Steps: go to settings - automations & scenes, click + Create automation and immediately click Save (stay with New automation for the name, if you like). You now have an empty automation called “New automation”.
Click the arrow to see it in your list of automations.
Click the new automation to edit it and click the ⋮ three dots menu to Edit in Yaml. Your automation will look like this:

alias: New automation
description: ""
triggers: []
conditions: []
actions: []
mode: single

Add a line that just says: id: something. Click Save. Home Assistant replies Automation is unavailable. Removing the id: line doesn’t help, the automation is gone. Trying further: even typing id: something, then removing that line, then clicking Save would delete the automation.

This is a bug, isn’t it? And yes, I know now that I don’t need to add an ID to my automation - that’s not what this is about.

Stop trying to add id: manually. The editor does it for you.

@nickrout Thanks, but my question is about the automation vanishing, sorry for not making that clear enough. So let me restate: I’m asking about the automations vanishing when I (erroniously) add an id: tag. That shouldn’t happen, should it?

Yes, I believe so that it is the normal behaviour. When there are two id:'s, the automations.yaml file essentially becomes corrupted. Home Assistant won’t be able to reload it and will stop at the automation with the duplicate keys.

Editing the automation via the UI won’t fix the issue because the database and the file will become out of sync. If you remove the id: you mistakenly added, HA will generate a new one, resulting in a lost of the pointer (id) to the original automation section.

Probably what shouldn’t be is for HA to allow you to save it with the id: tag, but as itself, it is a valid, existing tag for automation, just not meant to be used in the UI editor

Hi Valentijn Sessink,

I’m sure you will find it in the logs under ‘broken automation because someone is making up their own keys’, or something related.

Adding an extra id: corrupts the file. That’s why I told you to stop it.

Yeah, that’s an even better way to describe the problem: the editor lets you do this. I’ll file a bug.

@nickrout Thank you for your persistent message. Your answer was crystal clear from the beginning. Just to restate the obvious: I’ve already stopped adding ID’s - that’s why I specifically wrote “erroneously”.

The editor let’s you write absolutely anything into it…
I bet you can write this. Is that also a ‘bug’?


Lorem:
  - ipsum
  - dolor
  - sit
  - amet
  - consectetur
  - adipiscing
  - elit
  - sed
  - do
  - eiusmod
  - tempor
  - incididunt
  - ut
  - labore
  - et
  - dolore
  - magna
  - aliqua
  - Ut
  - enim
  - ad
  - minim
  - veniam
  - quis
  - nostrud
  - exercitation
  - ullamco
  - laboris
  - nisi
  - ut
  - aliquip
  - ex
  - ea
  - commodo
  - consequat
  - Duis
  - aute
  - irure
  - dolor
  - in
  - reprehenderit
  - in
  - voluptate
  - velit
  - esse
  - cillum
  - dolore
  - eu
  - fugiat
  - nulla
  - pariatur

Ipsum:
  - Excepteur
  - sint
  - occaecat
  - cupidatat
  - non
  - proident
  - sunt
  - in
  - culpa
  - qui
  - officia
  - deserunt
  - mollit
  - animid
  - id
  - est
  - laborum

Dolore:
  - Sed
  - do
  - eiusmod
  - tempor
  - incididunt
  - ut
  - labore
  - et
  - dolore
  - magna
  - aliqua
  - Ut
  - enim
  - ad
  - minim
  - veniam
  - quis
  - nostrud
  - exercitation
  - ullamco
  - laboris
  - nisi
  - ut
  - aliquip
  - ex
  - ea
  - commodo
  - consequat

I filed issue #22395 in Github