Confusing smart light switch entity naming

I am currently working on a custom integration for smart light switches. One switch can switch two lights. I’ve grouped those two lights in one device, as suggested by the development documentation. The app ecosystem of the manufacturer already offers the option to name a light and add it to a room.

Now the documentation requires new integrations to set has_entity_name to True. This causes the device to be named <Device name> <Entity name>. In most cases this makes perfect sense.

Now imagine the following situation: I have one light switch in the office (named “Light Switch”) controlling two lights (named “Main Light” and “Reading Light”). Logically I would expect them to be added to the room “Office” in Home Assistant and be named “Main light” and “Reading light”.

Unfortunately due to the requirements above, they are called “Light Switch Main Light” and “Light Switch Reading Light”. When setting has_entity_name to False, I am able to more clearly label the entities.

The entities should still be grouped by the same device, because the light switch offers more functionality like RGB LEDs to indicate a status. So there are entities concerning the light switch and entities concerning the switched light. Or should the light switch be one device and the switched light be separate one?

How should this case be handled, so that the naming does not get confusing for the user? Is there an exception for the has_entity_name rule? Are there existing integrations dealing with the same problem?

Are you sure you’re not overcomplicating this? Just name them whenever you want and set up an automation to control both lights with the same switch.

Well, would i.m.h.o. not name a device “light switch” as I have tons of those. I would never call a device switch if it has (dumb) lights already wired to it. So I’d call the device e.g. bedroom light, or if it is truly only buttons without direct association to lights, than indeed maybe bedroom switch.

The integration would not be able to come up with the right name for switch entities anyway, so I’d be perfectly happy with (switch) 1 and (switch) 2 for the entities. If they are truely just switches controlling lights that are smart too, I’d keep it that way because you never interact with them, other then to create automations. If there’s a dumb light attached to it I’d name it to the light, such as main or closet.

So as said before, don’t overthink it.

I think you misunderstood the setup. It is a physical light switch with two buttons and two corresponding outputs that power a dumb light each and switch is also controllable over wifi. That’s what I’m integrating into Home Assistant.

Now that I thought a bit longer about it, I’m pretty sure I need to have separate devices. Because you could also have the light switch in your living room, controlling a porch light. Then the status LED is tied to the light switch in the living room and the light device is on the porch.

Well yes I agree, simple setups are not the problem. But given the previously mentioned example, you have one light switch with two outputs in the living room, one controlling the living room light and one controlling the porch light. The switch itself has a status light. What would you name the light switch in this case? And in which room would you put it, if it is all one device?

1 Like

You name both lights for what they are, put each in their respective room, be it the same room or not. If there’s a led on the buttons you can control from ha, name it led or whatever.

If there is such a thing as a physical switch with multiple buttons, that is represented in HA, name it what you want and place that in whatever room it is in.

Why do you care so much about the switches themselves? HA operates lights, not switches. Switches are just a means to do so in the physical world.You only need them in HA to automate what happens when some one presses them.

Devices are just a way to represent a thing in the real world that may consist of multiple things you can control or monitor. Entities are the things you actually do stuff with in Ha. Also note that devices in HA and entities do not need to be in the same room.

That’s exactly the issue. I can:
a) Name each light for what it is and don’t group lights that are controlled from the same switch together. This might lack structure when having a lot of switches.
b) Group all lights belonging to the same switch in one device. This leads to the naming issues described
c) Group all lights belonging to the same switch in multiple linked devices. This is what you call overcomplicated.

I’m trying to understand what the best practices for such would be “in the HA spirit”.

The naming convention is only the default. You can group and rename as you like. the device grouping is only in the integrations pages. I have multiple fibaro switches exactly like you describe. You are still overthinking it.

Yes I know that the naming can be customized by the user. I am developing a new integration and would like to offer users a sensible default as well as a device topology that makes sense on the integration page.

The system I’m integrating has it’s own app where the user has already named all lights and rooms, so I’d like to use that as much as possible, while still adding additional information like serial number, manufacturer, model and RSSI. All those data points belong to the device (the light switch) and not the light, but I have to name the device, which is an issue for switches with multiple outputs.

Thanks for sharing your point of view, I’m curious what others think about the issue.