Add device_class for light domain

There are devices classes for a lot of domains, but nothing for lights.

In my case, I’ve got a need to class my lights by type for catching them on my automation for example.

It could be :

  • lightbulb : a light bulb or a led strip
  • lightgroup : a group of lightbulb (celling spots)
  • ambiance : entertainment light like ambilight
  • notification : a led used to notify

Then, i’m my notification I can do some stuff like :
=> Turn off all lightbulbs on my living room (but not my led or my ambilight)
=> Blink the living room notification light when something append

You can do this with custom attributes for any entity. They can be used just like any other attribute, such as the device class. I happen to do something similar with some of my light entities.

homeassistant:
  customize:
    light.dining_room_rgb_light:
      type: bulb
      rgb_light: master
    light.bathroom_vanity_light_rgb_bulb_1:
      type: bulb
      rgb_light: slave
    light.bathroom_vanity_light_rgb_bulb_2:
      type: bulb
      rgb_light: slave

And here is an example of a template where I make use of some of those attributes.

{{ states.light
  |selectattr('attributes.type','in',['dimmer','switch','bulb'])
  |rejectattr('attributes.rgb_light','eq','control')
  |rejectattr('attributes.rgb_light','eq','slave')
  |map(attribute='entity_id')|list }}
3 Likes

Is it possible to use this template in automation or script ? Or only in lovelace ?

recently connected all lights (~85 devices) to home assistant, found out that for every switch panel there is backlight which is too bright at night within bedrooms, for now I used customzation to define them as backlight and apply automation on all backlight of bedrooms on presense detection.
same as switch, binary sensor and sensors are “well-respected” with device class, light domain should have it too (IMHO).

potential device classes (on top of the written in the OP):
spot
led strip
projector
wall light
ceiling light
backlight - for switch panels