Move from yaml to Switch as x helper

So I have several switches that I’ve converted to lights using the following yaml entries. How do I convert this to using the UI via Switch as X helper from 2022.4? I’m trying not to break my automations, so I would like to retain the same light entities. Thoughts?

- platform: switch
  name: BBQ Light
  entity_id: switch.bbq_light
- platform: switch
  name: BBQ String Lights
  entity_id: switch.bbq_string_lights
- platform: switch
  name: Cabana Light
  entity_id: switch.cabana_light

your home work

Delete the yaml. Restart. Create the helpers and use the same names so that the new entity ids match the deleted ones.

Well, I figured that would be the process, but it doesn’t seem to work in my case. When you delete the yaml entry and restart Home Assistant, the entity is still there but listed as ‘Unavailable’. Then when you create the light using Switch as X’ using the same name, the entity gets prepended with a 2.

I did a similar process for groups created in yaml and migrated to the UI, but instead of restarting HA, I reloaded the groups from developer options then recreated in the UI using the same name and it worked! I thought about doing the same thing for the switch platform, but didn’t see an option to reload that specific yaml, hence me creating this post.

Thoughts?

Just delete the restored entities and rename your _2 entities.

That’s the main issue. The reason why it creates it with a _2 is because the original light entity still exist even though it was removed from yaml. Renaming gives me this error…

Yes but you can fix that.

  1. delete the yaml
  2. restart
  3. delete restored entities from the entities list
  4. re-create helpers with the same entity id

But as you have already created the helpers jus do this:

  1. delete the restored entities ( the ones without _2 ) from the entities list.
  2. rename the new entity_ids by deleting the _2 bit.

That worked. Was trying to avoid the additional editing of removing entities that should have been removed by removing the yaml entries. Bug?

No not a bug. I’ve opened an issue about this before. There’s a reason for the yaml entries remaining as restored items after deletion. Probably something to do with how the backend tracks yaml entities.

Exactly! Which is why there needs to be an option here specifically for yaml based entities like light, sensor etc. Remember, it works for reloading group entities, just not light entities created in yaml.

Automations defined in yaml have to be deleted from the restored entities (if they have a unique id).

So it has nothing to do with having a reloading option.

I understand. But I’m not referring to automations here. This is simply group entities vs other entities. They should behave the same, no?

Feel free to open an issue but you will be told what I have already said.