Use a ZHA device as light switch

Hi, I am replacing my IKEA Tradfri gateway by a ConBee2 stick, using ZHA.
My problem:
I‘d like to create a Light Switch entity. Power switches connected to the IKEA gateway behave like expected but those controlled by ZHA became never available (the entity ID is listed in the entity GUI list but the entity is not available)

Does anyone use a Light Switch entity together with a ZHA connected device?
Could this be some kind of bug?

If you need more information about my installation just tell me what you need to know

Not entirely sure what your looking for.

The light switch creates a “light” entity from a switch. I use it for creating “light” out of some aqara switches. By doing this I can use the switches in the GUI as lights, and they will turn off by a light.off command.

Here is a example.

- platform: switch
  name: Garage Loftlys
  entity_id: switch.lumi_lumi_plug_maeu01_1512823c_on_off

This one creates a entity called “light.garage_loftlys”, which behaves like a “bulp”.

Thanks for your quick response!

I know how Light Switch entities work, I already use them. My problem is that the Light Switch can not find switch entities provided by the ZHA integration. Switches connected through the IKEA Tradfri integration are no problem.

I can give you an example of my configuration.yaml this evening.

You have to listen to zha_events

Examples:

It’s better if you post what you have and not just expect us to understand/guess what you have.

We only know you have something IKEA but not what, if you tell us what then it will be easier to help.
I’m not sure I understand why you need a light template.
What is the entity you are trying to control with this IKEA device?

OK, I think I have to start at the beginning, here are some information about my system:

  • Raspberry PI 4
  • Home Assistant OS 7.0
  • core-2021.12.7

I have 2 IKEA Tradfri wireless control outlets.
The first one is connected to the original IKEA Tradfri gateway, so I am using the IKEA Tradfri integration.
The second one is directly connected to my Home Assistant system, using a ConBee II USB stick controlled by the ZHA integration.

Both wireless control outlets are used to turn simple lamps on and off. I’d like to create a Light Group to control this two lamps together with other smart lights (e.g. this). To do so, I need to create Light Switch entities for both wireless control outlets to simulate the light behaviour.

This is from my configuration.ymal:

light:
  # switch.sw001 is provided by the IKEA gateway/integration
  - platform: switch
    name: ls001
    entity_id: switch.sw001
  # switch.sw002 is provided by the ZHA integration
  - platform: switch
    name: ls002
    entity_id: switch.sw002

  # group light switch 1 and 2 together
  - platform: group
    name: room001
    entities:
      - light.ls001
      - light.ls002
    # - ...

light.ls001 works correctly but light.ls002 is not available although switch.sw002 also works.

Before I bought the ConBee II stick, switch.sw002 was also connected to the IKEA gateway. In that setup light.ls002 worked correctly, too.

I hope that explains my problem a little better.

@francisp: I already use those blue prints to control my Tradfri remote controls and know about zha_events. I have looked through the posts you are referring to, but I am not sure how to use this for a Light Switch.

Ok… so why do you need the light switch?
I really don’t see the need for this.
I have lights connected to wall switches and, sure they are called switch.light_something.
But that isn’t an issue for me.
The entities are just in the background and rarely something I think about.
The few times I need to find an entity I just type the name of the entity in developer tools and the “prefix” isn’t needed.

In my opinion, creating these light switches is just causing more problems because you will get more entities that will make it more confusing.
But perhaps that is just me.

I have this precise setup working with Aqara plugs. I do not have any IKEA, might be the problem. You mention it work before, maybe there is still some old entity reference to the switch.sw002. Have you tried to delete the device and create again with a new name?

Hi Hellis81. I actually like the light switch. I use it for the plugs to create light entities. Especially the “light.off” and “light.on” for a “area” is easy to use afterwards. Further Lovelave cards will show the right icon without needing specific code.
However, it has a lot to do with the usecase, which will be different for all of us.

That‘s my use case, too!
And it was good to know that it works for you, so I‘ve tried to remove all and reconfigured it from the scratch.
Now it works! I think there is some kind of cache creating entities from the configuration.yaml or anything.
However it works now, thank you for your time!