Base Class
All light entities inherit fromLightEntity, which extends ToggleEntity. The class is defined in homeassistant.components.light.
Color Modes
Lights must declare which color modes they support. This is the most important configuration:ONOFF- Simple on/offBRIGHTNESS- Brightness control onlyCOLOR_TEMP- Color temperature (white spectrum)HS- Hue/SaturationRGB- RGB colorRGBW- RGB + White channelRGBWW- RGB + Warm White + Cool WhiteWHITE- White channel brightnessXY- CIE 1931 color space
Required Properties
supported_color_modes
Set of color modes the light supports.color_mode
The current active color mode.Required Methods
turn_on
Turn the light on with optional parameters.turn_off
Turn the light off.Optional Properties
brightness
Current brightness (0-255). Required for brightness-capable lights.rgb_color
Current RGB color as tuple (r, g, b) where each value is 0-255.hs_color
Current hue/saturation as tuple (hue, saturation) where hue is 0-360 and saturation is 0-100.color_temp_kelvin
Current color temperature in Kelvin.min_color_temp_kelvin / max_color_temp_kelvin
Temperature range for color temperature lights.effect_list
List of available effects.effect
Current effect.supported_features
Additional features beyond color modes.EFFECT- Supports effectsFLASH- Supports flashingTRANSITION- Supports transition time
Example Implementations
Simple Dimmable Light
RGB Color Light
Color Temperature Light
Light with Effects
Turn On Parameters
Theturn_on method can receive these parameters:
ATTR_BRIGHTNESS- Brightness (0-255)ATTR_BRIGHTNESS_PCT- Brightness percentage (0-100)ATTR_BRIGHTNESS_STEP- Relative brightness step (-255 to 255)ATTR_BRIGHTNESS_STEP_PCT- Relative brightness step percentage (-100 to 100)ATTR_RGB_COLOR- RGB color tuple (r, g, b)ATTR_RGBW_COLOR- RGBW color tuple (r, g, b, w)ATTR_RGBWW_COLOR- RGBWW color tuple (r, g, b, cw, ww)ATTR_HS_COLOR- Hue/Saturation tuple (hue, saturation)ATTR_XY_COLOR- XY color tuple (x, y)ATTR_COLOR_TEMP_KELVIN- Color temperature in KelvinATTR_WHITE- White level (0-255)ATTR_EFFECT- Effect nameATTR_FLASH- Flash (“short” or “long”)ATTR_TRANSITION- Transition time in seconds
Important Notes
- Always set
supported_color_modes- it’s required - Set
color_modeto the current active mode when the light is on - Home Assistant automatically converts between color representations
- Only implement the properties for your supported color modes
- Use
async_write_ha_state()to update Home Assistant after state changes - The light platform handles color conversions automatically
Color Mode Combinations
Valid combinations of color modes:- Single mode:
{ColorMode.RGB} - Multiple modes:
{ColorMode.RGB, ColorMode.COLOR_TEMP} - The
ONOFFandBRIGHTNESSmodes are automatically filtered if other modes exist