Switch as Light - from yaml (Change device type - switch_as_x)

Shortly:
I want to do this (change from switch to light) :

But in yaml !

I found on WebArchive from a coupple of years ago (https://web.archive.org/web/20211207144015mp_/https://www.home-assistant.io/integrations/light.switch ) that there was something like:

light:
  - platform: switch
    name: Christmas Tree Lights
    entity_id: switch.christmas_tree_lights

I think this still works but … now … questions:

  1. Is this (old?) yaml code still ok to use?
  2. Any other better (actual/officially supported) solution ? (e.g.: template light ??)
  3. Any solution to set the entity I want? (in the small (old?) yaml variant the entity is set by HA with the same name as the switch, and using the “name” as a FriendlyName only
1 Like

It does still work, as I just tested it. However, I’m not sure how long it will continue to work.

Please vote here: