Light and Switch entities

The reason lights and switches are separated has nothing to do with the states they support. There are lots of lights that only support off and on, then there are some that support tunable color temperature, others that support full RGB and yet others have additional effects, they’re still all lights. Obviously if you try to tell a plain white light to change to warm white or a tunable CCT light to change to green that’s not going to work but these less capable lights are still lights, we don’t have separate domains for all of these different kinds of lights despite their varying capabilities and a light plugged into a switch is also a light.

The reason for separating lights and switches is purely organizational. A switch can be a light, but a switch can also be any number of other things and there are many times when it makes sense to apply an action indiscriminately to lights, it is not uncommon to want to turn on or off all the lights in a room, but rare that you want to indiscriminately turn on or off all electrical devices in a room. The reason for separating them is not in question, only the difficulty of designating a switch as a light, or maybe you even want to designate a light as a switch, who knows. If I were designing things from scratch I don’t think I would use separate domains for lights and switches, I would just include a flag so that entities could be tagged as lights from an organizational standpoint and respond to light-specific commands but I’m not designing from scratch so this is moot.

Yes, technically it is not “hard” to add some lines to the configuration yaml to designate a switch as a light switch but that is IMHO a messy hack. It is not easily discoverable, and it results in an unnecessary duplicate entity that adds clutter. This is going outside and grabbing a rock to hold the door shut because nobody bothered to fit a latch connected to a doorknob like some of the other doors have. It could be argued that the house didn’t cost you anything so you can’t complain about the user experience or the need to get creative to find a solution, and “is it really that hard to just go outside and get a rock from the garden?” but that’s not really the point. Blaming the writers of a blueprint rather than acknowledging a flaw in the system is Apple telling users “You’re holding it wrong” when they complained of problems with the iPhone. This is especially silly when this is something I encountered in one of the two default blueprints that come with the system, one could reasonably expect those to be examples of well designed example and not “flawed” blueprints. All things have flaws, that doesn’t mean they lack value and doesn’t have to be taken as negative criticism, it is just room for improvement.

Anyway I’m a relatively new user and I started this thread to bring to light a significant pain point that I have encountered on numerous occasions so far and I believe that many other users are going to hit this same pain point. I did manage to stumble across a couple different workarounds but I’m also professionally a QA engineer/SDET with a background in EE, so not a full fledged software engineer but probably more on the technical side than the average person who says “this cloud stuff sucks” and comes here looking for an alternative. I think HA is very close to being viable for a large group of people who are less technical than engineers but not so non-technical that they need the Apple approach where everything is done for them Apple’s way and they are not allowed to tweak anything even if they want to.

If the argument for basic functionality is “you can just put xyz in the whatever.yaml, this is not a flaw, stop whining and learn to code or go buy Apple/Hue/WeMo/whatever” then it could be argued that there is no need to have a UI at all. The fact that the UI cannot yet do everything that it should be able to do does not speak badly of the UI or of the of the project as a whole, it is simply room for improvement. My argument here is that having a trivial, easily discoverable way of designating a switch as a light, ideally without creating a duplicate entity is a valuable improvement that would ease a significant pain point that almost all users are going to encounter sooner or later. Each of those users is going to have to do as I did and spend time searching for a workaround and/or adding noise to the forums asking how.

5 Likes

Home assistant is built off service calls. Service cals have different attributes. If you feed incorrect attributes to service calls, the system will error. This is the fundamental difference between lights and switches. There are service calls that can handle both lights and switches. The blueprint owner chose not to use that. The blueprint is flawed. Complaining to random people here instead of the blueprint owner is just going to result in people ignoring you.

Ehm… sorry I think there is no complaining going on here?

Just a fundamental discussion about the difference between a light. and a switch. domain and the attached “things” to it.

I dare to bet that 70-90% of all people that use home assistant have a “light” attached to a switch. Hence I think the OP (and me) have a fair point of the ask to “easily” change a switch into a light?!

All arguments:

  • there is a yaml way
  • It’s a fundamental service call thing
  • it’s a blueprint thing

I think those effectively are substitutes of the real ask and also in my opinion “problem” of the simple ask “why can’t I just easily in UI change a switch into a light…?”

1 Like

It’ll always create a new entity because the entire system is built around supported_features and domain. But someone just needs to add UI configuration for light switch integration and you’ll have your wish.

I’m not “complaining to random people”, I came to first understand how this is expected to work and the reasoning behind it, then I’m trying to provide useful feedback to help make the project better, essentially exactly what my employer pays me a substantial amount to do in my day job. If people want to blow it off as a random complaint and ignore me that’s fine, it is their loss. I will be disappointed if this is the attitude that the HA community holds but that is not something I can control and there are many other things I can spend my limited free time doing than trying to contribute here if what I’m trying to contribute is not welcome.

The blueprint I mention as an example is one of only two default blueprints that are included with Home Assistant so if they are flawed then whoever is in charge probably ought to fix that and choose default examples that are not flawed, because the included blueprints are going to be the first blueprints that every user encounters, they should be the gold standard of how a blueprint is supposed to be written.

That is still beside the point, there are many, many people who run into this issue regarding lights and switches and you seem to be blowing off this problem as nothing, skirting around the issue and circling back to blueprints which are just one of many paths to encounter the issue. Maybe you can explain how a light that ONLY supports on/off as many lights do is fundamentally different from a switch controlling a light. What if you send a color change command to a white-only light that doesn’t support it? Is that different than sending that command to a switch that also doesn’t support it?

If you want to shoot the messenger that’s your decision, but just recognize that you are blowing off an issue that a very large number of people struggle with, judging by what I saw when I was looking for solutions for myself. If you type “home assistant switch” into google this is literally the very first suggestion that comes up.

3 Likes

Sorry, I took your initial post as complaining. That’s how I personally interpreted it. If that’s not your intent, then I appologize.

As for the topic at hand, what your asking to change is a foundation of the software and cannot be easily changed. Not to mention, 95% of the hardware that we interface with segregates devices in the exact same manner. Just to name a few off the top of my head:

  • alexa
  • google home
  • zwave
  • zigbee
  • homekit
  • smarthings
    … etc…

In order to interface with these hardwares and softwares, we would have to translate their switches into lights and then back when exposing HA to them.

This is why the homeassistant.turn_on service was created. It handles ALL on/off devices. So when creating an automation, thats what you should use when dealing with on/off devices that are in separate domains. homeassistant.turn_on and switch.turn_on are almost identical, so they can be used interchangeably. light.turn_on is completely different because it can except other values.

That’s what supported features is for. You’ll notice as you cruise through your entity list that all entities that come from hardware have a supported_features attribute. This attribute lets home assistant know how to handle the device. Each domain has a different supported_features. Light and switches have differing supported features. If we tried to expose a switch and a light to Alexa and they both have the same supported features, Alexa would not be happy because it wouldn’t know how to assign the device without the user hard configuring it. And that’s just a basic example. It get’s much more complicated when these switches and lights offer other attributes that don’t overlap.

Yes, because you cannot send switch.turn_on with any other attributes. Light.turn_on will elegantly ignore other attributes that are not supported where switch.turn_on will not. Again, that’s all handled by supported_features and supported_features are not the same between lights and switches.


This is just scratching the surface. Supported_features drives pretty much every aspect of home assistant: how entities are exposed to other software, the look and feel of entities in the interface, how the history is stored, how they are used in other integrations, etc.

So, you’re welcome to keep discussing this to lengths end but the likely hood of this changing is extremely low. Your best option is to learn the service calls and use them appropriately. And remember, the design choice was not chosen to make it confusing. It’s just how it is in the device world. A dimming light is functionally different than a toggling switch.

You’re welcome to bring up this discussion on github and formally communicate with the people who create the software.


Blueprints are a month old. The included blueprints are to show you the power of blueprints and to help you learn how to create a blueprint (because tutorials don’t exist for them yet). In time, these blueprints will be expanded on.

1 Like

I wanted to understand why this works the way it does and the rationale behind that decision, I think that has been sufficiently explained at this point. I’m not asking for a major overhaul of the architecture, I know that isn’t feasible and I’m not accusing the person who designed the architecture of being incompetent. All I’m asking for is a better/easier/more discoverable way of designating a switch as a light and I was hoping to start a discussion where people more knowledgeable about the inner workings can contribute ideas. There is clearly something lacking here, that isn’t a complaint, it’s just some constructive criticism. I don’t expect somebody to drop everything and fix it right now just for me, I just would like it to be on the radar as something that could be improved to save people a lot of frustration. I know from experience that being involved in a project for a long time it’s easy to just get used to problems to the point that you don’t even notice them anymore or perceive them as problems. For years I drove a car that had some bad bushings in the suspension and I didn’t even notice how bad it had become until my friend drove it and exclaimed that there was something seriously wrong. After I replaced the bushings I was amazed at how much better it felt, I’d been putting up with it for long enough that I didn’t even notice anymore and the same thing happens with software projects. A simple “This switch is controlling a light” or some such checkbox in the device/entity editing modal that does what adding the lightswitch block to the configuration.yaml does would do. Maybe there is a better way of doing this, I’ll leave that to the experienced developers.

Keep in mind that I’m new here too, I have no idea how long a given feature has been around or what state it’s in, I can only go by my impressions as a new user and the parts of the process that I’ve stumbled over and I think that sort of new user experience is valuable, I certainly want to hear about it with my own projects that I put out there.

6 Likes

Hi!
As a new HA user I totally agree on this. There should be a simple way in the UI to change an entity from one type to the other.
I’m struggling with a four channel switch relay device, that is shown as four light entities in HA.
An easy way to change this would be a large improvement. The same way a switch could easily be changed to a basic on/of light.

4 Likes

Would using NodeRED for automations be a useful alternative to this ‘problem’ ?

No? You’ll just use mode red to turn on your switches instead of home assistant. Node red isn’t a magic problem solver because it looks pretty.

I guess my question was, would using NodeRed as an alternative make the fact that something being a ‘switch’ or a ‘light’ doesn’t really matter. At least when compared to hardcoded blueprints. Was just a thought.

What brought me here was I am in the process of migrating my ZigBee integration from SmartThings->HA to using a Tasmota/Sonoff bridge natively in HA. SmartThings/HA would see my smart plugs as ‘switches’ but when adding the same device in the native ZigbBee integration they are showing up as ‘lights’ (???) which seemed very strange to me. Anyway if I’m using NodeRed it just becomes an ‘object’ and the domain doesn’t really matter.

No, you’ll still have to use the correct service to turn on them both in 1 service call: homeasssistant.turn_on

maybe too simple, but why not simply add a Google Home to the home, and give these entities an appropriate alias.

    entity_config:

      switch.master_bed_outlet:
        name: Master bed
        aliases:
          - Bedlicht
          - Nightlight
          - Nachtlamp
        room: Master bedroom

      switch.desk_light:
        name: Desk
        aliases:
          - Study
        room: Office

Simply say “Ok google, turn off the Desk (light)”

and be done with it…

Well, sorry to blow this thread, but I’ve got a switch for my fan and it is listed in the light domain.
Would be great if I can put it into another domain and don’t bother anymore when my light automations are trying to send temperature and brightness values to it anymore. :slight_smile:
(I really need to get it out of the light domain for good)

No clue what you’re trying to say here. If your fan is showing up as a light, then you’d need to make a template fan using the light and properly set up each fan service.

As I said before in this thread, there’s no magical converter. HA isn’t going to know that a light needs to be a fan and it won’t know how to control the fan if you ‘just changed the domain’. You have to convert it into a fan (or other domain) in a way that home assistant knows how to use it. If all you care about is turn on/ turn off then use homeassistant.turn_on service instead of light.turn_on or switch.turn_on.

It’s simple going from a light to a switch, any other domain → domain combo is not simple and you need to set it up by hand.

Unfortunately, I’ve got light routines checking which light is on and send some commands to them. And it will be annoying excluding every new switch by hand because it somehow lands in the light domain. A switch should be a switch. :upside_down_face:

Then you should take it up with the integration because the integration is making it a light. Or you should fix your “light routines” and have them only adjust lights that matter. You cannot change the setup of a entity. And the setup determines the domain the device falls into. This will never change because this is the backbone of how home assistant works (As well as just about every other home automation software).

Okay, I will dig deeper into this. Thanks

I have read this whole thread and I still don’t get it. I’ve been using Hass for several years and this has been bugging me since day 1 but there has been constant improvement over the years so I’ve thought, soon there will be a solution for this. When the name change was introduced I could easily move a switch and change the name in a matter of seconds.

Please help me understand best practices here. I really like that areas and kinds of devices can be sorted out to easily turn off all lights in one room for example. Do you really mean that the best way to do this is by having to manually write in yaml? I have lots of switches connected to light so it would be a lot of work. No matter what’s happening “under the hood” I think a GUI toggle to show switch as light would be a massive UX improvement.

Unless I’ve completely misunderstood?

Another way might be to create duplicate areas one for all lights and one for everything else in that room.

How do you set these lights up?

Thank you.

1 Like

FWIW, I agree with those calling for a simpler way to change a switch to a light (and vice versa) as it also has implications downstream from HA.

I am migrating to HA from another platform and have a mixture of Zigbee and Z-wave modules. My Fibaro Dimmer 2 modules (I have a lot of them) show up as a light. Great, no issue here, exactly what I want. My Fibaro Double Switch 2 modules (I also have a lot of these) show up as a switch even though most are connected to lights. This has all the effects previously mentioned for HA but also how they appear in Homekit. Not a big issue as I can change the icon. I also have some Sonoff zigbee modules which are cheap and work really well. However, HA sees them as a light. This is a problem for those I am using as switches as you cannot change how they are displayed in HomeKit. 2 for instance are connected to fans and Homekit won’t allow me to change the icon.

2 Likes