Home Assistant Unofficial Reference 2024.12.1
homeassistant.components.light Namespace Reference

Namespaces

 device_action
 
 device_condition
 
 device_trigger
 
 intent
 
 reproduce_state
 
 significant_change
 

Classes

class  ColorMode
 
class  LightEntity
 
class  LightEntityDescription
 
class  LightEntityFeature
 
class  Profile
 
class  Profiles
 

Functions

None _coerce_none (str value)
 
bool async_setup (HomeAssistant hass, ConfigType config)
 
bool async_setup_entry (HomeAssistant hass, ConfigEntry entry)
 
bool async_unload_entry (HomeAssistant hass, ConfigEntry entry)
 
bool brightness_supported (Iterable[ColorMode|str]|None color_modes)
 
bool color_supported (Iterable[ColorMode|str]|None color_modes)
 
bool color_temp_supported (Iterable[ColorMode|str]|None color_modes)
 
set[ColorModefilter_supported_color_modes (Iterable[ColorMode] color_modes)
 
dict[str, Any] filter_turn_off_params (LightEntity light, dict[str, Any] params)
 
dict[str, Any] filter_turn_on_params (LightEntity light, dict[str, Any] params)
 
set[str]|None get_supported_color_modes (HomeAssistant hass, str entity_id)
 
bool is_on (HomeAssistant hass, str entity_id)
 
None preprocess_turn_on_alternatives (HomeAssistant hass, dict[str, Any] params)
 
set[ColorMode|str] valid_supported_color_modes (Iterable[ColorMode|str] color_modes)
 

Variables

 _LOGGER = logging.getLogger(__name__)
 
string ATTR_BRIGHTNESS = "brightness"
 
string ATTR_BRIGHTNESS_PCT = "brightness_pct"
 
string ATTR_BRIGHTNESS_STEP = "brightness_step"
 
string ATTR_BRIGHTNESS_STEP_PCT = "brightness_step_pct"
 
string ATTR_COLOR_MODE = "color_mode"
 
string ATTR_COLOR_NAME = "color_name"
 
string ATTR_COLOR_TEMP = "color_temp"
 
string ATTR_COLOR_TEMP_KELVIN = "color_temp_kelvin"
 
string ATTR_EFFECT = "effect"
 
string ATTR_EFFECT_LIST = "effect_list"
 
string ATTR_FLASH = "flash"
 
string ATTR_HS_COLOR = "hs_color"
 
string ATTR_KELVIN = "kelvin"
 
string ATTR_MAX_COLOR_TEMP_KELVIN = "max_color_temp_kelvin"
 
string ATTR_MAX_MIREDS = "max_mireds"
 
string ATTR_MIN_COLOR_TEMP_KELVIN = "min_color_temp_kelvin"
 
string ATTR_MIN_MIREDS = "min_mireds"
 
string ATTR_PROFILE = "profile"
 
string ATTR_RGB_COLOR = "rgb_color"
 
string ATTR_RGBW_COLOR = "rgbw_color"
 
string ATTR_RGBWW_COLOR = "rgbww_color"
 
string ATTR_SUPPORTED_COLOR_MODES = "supported_color_modes"
 
string ATTR_TRANSITION = "transition"
 
string ATTR_WHITE = "white"
 
string ATTR_XY_COLOR = "xy_color"
 
dictionary CACHED_PROPERTIES_WITH_ATTR_
 
string COLOR_GROUP = "Color descriptors"
 
string COLOR_MODE_BRIGHTNESS = "brightness"
 
string COLOR_MODE_COLOR_TEMP = "color_temp"
 
string COLOR_MODE_HS = "hs"
 
string COLOR_MODE_ONOFF = "onoff"
 
string COLOR_MODE_RGB = "rgb"
 
string COLOR_MODE_RGBW = "rgbw"
 
string COLOR_MODE_RGBWW = "rgbww"
 
string COLOR_MODE_UNKNOWN = "unknown"
 
string COLOR_MODE_WHITE = "white"
 
string COLOR_MODE_XY = "xy"
 
dictionary COLOR_MODES_BRIGHTNESS = VALID_COLOR_MODES - {ColorMode.ONOFF}
 
dictionary COLOR_MODES_COLOR
 
string DOMAIN = "light"
 
string EFFECT_COLORLOOP = "colorloop"
 
string EFFECT_OFF = "off"
 
string EFFECT_RANDOM = "random"
 
string EFFECT_WHITE = "white"
 
string ENTITY_ID_FORMAT = DOMAIN + ".{}"
 
string FLASH_LONG = "long"
 
string FLASH_SHORT = "short"
 
string LIGHT_PROFILES_FILE = "light_profiles.csv"
 
 PLATFORM_SCHEMA = cv.PLATFORM_SCHEMA
 
 PLATFORM_SCHEMA_BASE = cv.PLATFORM_SCHEMA_BASE
 
 SCAN_INTERVAL = timedelta(seconds=30)
 
int SUPPORT_BRIGHTNESS = 1
 
int SUPPORT_COLOR = 16
 
int SUPPORT_COLOR_TEMP = 2
 
int SUPPORT_EFFECT = 4
 
int SUPPORT_FLASH = 8
 
int SUPPORT_TRANSITION = 32
 
 VALID_BRIGHTNESS = vol.All(vol.Coerce(int), vol.Clamp(min=0, max=255))
 
 VALID_BRIGHTNESS_PCT = vol.All(vol.Coerce(float), vol.Range(min=0, max=100))
 
 VALID_BRIGHTNESS_STEP = vol.All(vol.Coerce(int), vol.Clamp(min=-255, max=255))
 
 VALID_BRIGHTNESS_STEP_PCT = vol.All(vol.Coerce(float), vol.Clamp(min=-100, max=100))
 
dictionary VALID_COLOR_MODES
 
 VALID_FLASH = vol.In([FLASH_SHORT, FLASH_LONG])
 
 VALID_TRANSITION = vol.All(vol.Coerce(float), vol.Clamp(min=0, max=6553))
 
 VolDictType
 

Detailed Description

Provides functionality to interact with lights.

Function Documentation

◆ _coerce_none()

None homeassistant.components.light._coerce_none ( str  value)
private
Coerce an empty string as None.

Definition at line 683 of file __init__.py.

◆ async_setup()

bool homeassistant.components.light.async_setup ( HomeAssistant  hass,
ConfigType  config 
)
Expose light control via state machine and services.

Definition at line 396 of file __init__.py.

◆ async_setup_entry()

bool homeassistant.components.light.async_setup_entry ( HomeAssistant  hass,
ConfigEntry  entry 
)
Set up a config entry.

Definition at line 673 of file __init__.py.

◆ async_unload_entry()

bool homeassistant.components.light.async_unload_entry ( HomeAssistant  hass,
ConfigEntry  entry 
)
Unload a config entry.

Definition at line 678 of file __init__.py.

◆ brightness_supported()

bool homeassistant.components.light.brightness_supported ( Iterable[ColorMode | str] | None  color_modes)
Test if brightness is supported.

Definition at line 155 of file __init__.py.

◆ color_supported()

bool homeassistant.components.light.color_supported ( Iterable[ColorMode | str] | None  color_modes)
Test if color is supported.

Definition at line 162 of file __init__.py.

◆ color_temp_supported()

bool homeassistant.components.light.color_temp_supported ( Iterable[ColorMode | str] | None  color_modes)
Test if color temperature is supported.

Definition at line 169 of file __init__.py.

◆ filter_supported_color_modes()

set[ColorMode] homeassistant.components.light.filter_supported_color_modes ( Iterable[ColorMode color_modes)
Filter the given color modes.

Definition at line 122 of file __init__.py.

◆ filter_turn_off_params()

dict[str, Any] homeassistant.components.light.filter_turn_off_params ( LightEntity  light,
dict[str, Any]   params 
)
Filter out params not used in turn off or not supported by the light.

Definition at line 344 of file __init__.py.

◆ filter_turn_on_params()

dict[str, Any] homeassistant.components.light.filter_turn_on_params ( LightEntity  light,
dict[str, Any]  params 
)
Filter out params not supported by the light.

Definition at line 361 of file __init__.py.

◆ get_supported_color_modes()

set[str] | None homeassistant.components.light.get_supported_color_modes ( HomeAssistant  hass,
str  entity_id 
)
Get supported color modes for a light entity.

First try the statemachine, then entity registry.
This is the equivalent of entity helper get_supported_features.

Definition at line 176 of file __init__.py.

◆ is_on()

bool homeassistant.components.light.is_on ( HomeAssistant  hass,
str  entity_id 
)
Return if the lights are on based on the statemachine.

Definition at line 298 of file __init__.py.

◆ preprocess_turn_on_alternatives()

None homeassistant.components.light.preprocess_turn_on_alternatives ( HomeAssistant  hass,
dict[str, Any]   params 
)
Process extra data for turn light on request.

Async friendly.

Definition at line 303 of file __init__.py.

◆ valid_supported_color_modes()

set[ColorMode | str] homeassistant.components.light.valid_supported_color_modes ( Iterable[ColorMode | str]  color_modes)
Validate the given color modes.

Definition at line 139 of file __init__.py.

Variable Documentation

◆ _LOGGER

homeassistant.components.light._LOGGER = logging.getLogger(__name__)
private

Definition at line 294 of file __init__.py.

◆ ATTR_BRIGHTNESS

string homeassistant.components.light.ATTR_BRIGHTNESS = "brightness"

Definition at line 214 of file __init__.py.

◆ ATTR_BRIGHTNESS_PCT

string homeassistant.components.light.ATTR_BRIGHTNESS_PCT = "brightness_pct"

Definition at line 215 of file __init__.py.

◆ ATTR_BRIGHTNESS_STEP

string homeassistant.components.light.ATTR_BRIGHTNESS_STEP = "brightness_step"

Definition at line 216 of file __init__.py.

◆ ATTR_BRIGHTNESS_STEP_PCT

string homeassistant.components.light.ATTR_BRIGHTNESS_STEP_PCT = "brightness_step_pct"

Definition at line 217 of file __init__.py.

◆ ATTR_COLOR_MODE

string homeassistant.components.light.ATTR_COLOR_MODE = "color_mode"

Definition at line 62 of file __init__.py.

◆ ATTR_COLOR_NAME

string homeassistant.components.light.ATTR_COLOR_NAME = "color_name"

Definition at line 210 of file __init__.py.

◆ ATTR_COLOR_TEMP

string homeassistant.components.light.ATTR_COLOR_TEMP = "color_temp"

Definition at line 203 of file __init__.py.

◆ ATTR_COLOR_TEMP_KELVIN

string homeassistant.components.light.ATTR_COLOR_TEMP_KELVIN = "color_temp_kelvin"

Definition at line 207 of file __init__.py.

◆ ATTR_EFFECT

string homeassistant.components.light.ATTR_EFFECT = "effect"

Definition at line 231 of file __init__.py.

◆ ATTR_EFFECT_LIST

string homeassistant.components.light.ATTR_EFFECT_LIST = "effect_list"

Definition at line 228 of file __init__.py.

◆ ATTR_FLASH

string homeassistant.components.light.ATTR_FLASH = "flash"

Definition at line 223 of file __init__.py.

◆ ATTR_HS_COLOR

string homeassistant.components.light.ATTR_HS_COLOR = "hs_color"

Definition at line 202 of file __init__.py.

◆ ATTR_KELVIN

string homeassistant.components.light.ATTR_KELVIN = "kelvin"

Definition at line 204 of file __init__.py.

◆ ATTR_MAX_COLOR_TEMP_KELVIN

string homeassistant.components.light.ATTR_MAX_COLOR_TEMP_KELVIN = "max_color_temp_kelvin"

Definition at line 209 of file __init__.py.

◆ ATTR_MAX_MIREDS

string homeassistant.components.light.ATTR_MAX_MIREDS = "max_mireds"

Definition at line 206 of file __init__.py.

◆ ATTR_MIN_COLOR_TEMP_KELVIN

string homeassistant.components.light.ATTR_MIN_COLOR_TEMP_KELVIN = "min_color_temp_kelvin"

Definition at line 208 of file __init__.py.

◆ ATTR_MIN_MIREDS

string homeassistant.components.light.ATTR_MIN_MIREDS = "min_mireds"

Definition at line 205 of file __init__.py.

◆ ATTR_PROFILE

string homeassistant.components.light.ATTR_PROFILE = "profile"

Definition at line 220 of file __init__.py.

◆ ATTR_RGB_COLOR

string homeassistant.components.light.ATTR_RGB_COLOR = "rgb_color"

Definition at line 198 of file __init__.py.

◆ ATTR_RGBW_COLOR

string homeassistant.components.light.ATTR_RGBW_COLOR = "rgbw_color"

Definition at line 199 of file __init__.py.

◆ ATTR_RGBWW_COLOR

string homeassistant.components.light.ATTR_RGBWW_COLOR = "rgbww_color"

Definition at line 200 of file __init__.py.

◆ ATTR_SUPPORTED_COLOR_MODES

string homeassistant.components.light.ATTR_SUPPORTED_COLOR_MODES = "supported_color_modes"

Definition at line 64 of file __init__.py.

◆ ATTR_TRANSITION

string homeassistant.components.light.ATTR_TRANSITION = "transition"

Definition at line 195 of file __init__.py.

◆ ATTR_WHITE

string homeassistant.components.light.ATTR_WHITE = "white"

Definition at line 211 of file __init__.py.

◆ ATTR_XY_COLOR

string homeassistant.components.light.ATTR_XY_COLOR = "xy_color"

Definition at line 201 of file __init__.py.

◆ CACHED_PROPERTIES_WITH_ATTR_

dictionary homeassistant.components.light.CACHED_PROPERTIES_WITH_ATTR_
Initial value:
1 = {
2  "brightness",
3  "color_mode",
4  "hs_color",
5  "xy_color",
6  "rgb_color",
7  "rgbw_color",
8  "rgbww_color",
9  "color_temp",
10  "min_mireds",
11  "max_mireds",
12  "effect_list",
13  "effect",
14  "supported_color_modes",
15  "supported_features",
16 }

Definition at line 838 of file __init__.py.

◆ COLOR_GROUP

string homeassistant.components.light.COLOR_GROUP = "Color descriptors"

Definition at line 237 of file __init__.py.

◆ COLOR_MODE_BRIGHTNESS

string homeassistant.components.light.COLOR_MODE_BRIGHTNESS = "brightness"

Definition at line 90 of file __init__.py.

◆ COLOR_MODE_COLOR_TEMP

string homeassistant.components.light.COLOR_MODE_COLOR_TEMP = "color_temp"

Definition at line 91 of file __init__.py.

◆ COLOR_MODE_HS

string homeassistant.components.light.COLOR_MODE_HS = "hs"

Definition at line 92 of file __init__.py.

◆ COLOR_MODE_ONOFF

string homeassistant.components.light.COLOR_MODE_ONOFF = "onoff"

Definition at line 89 of file __init__.py.

◆ COLOR_MODE_RGB

string homeassistant.components.light.COLOR_MODE_RGB = "rgb"

Definition at line 94 of file __init__.py.

◆ COLOR_MODE_RGBW

string homeassistant.components.light.COLOR_MODE_RGBW = "rgbw"

Definition at line 95 of file __init__.py.

◆ COLOR_MODE_RGBWW

string homeassistant.components.light.COLOR_MODE_RGBWW = "rgbww"

Definition at line 96 of file __init__.py.

◆ COLOR_MODE_UNKNOWN

string homeassistant.components.light.COLOR_MODE_UNKNOWN = "unknown"

Definition at line 88 of file __init__.py.

◆ COLOR_MODE_WHITE

string homeassistant.components.light.COLOR_MODE_WHITE = "white"

Definition at line 97 of file __init__.py.

◆ COLOR_MODE_XY

string homeassistant.components.light.COLOR_MODE_XY = "xy"

Definition at line 93 of file __init__.py.

◆ COLOR_MODES_BRIGHTNESS

dictionary homeassistant.components.light.COLOR_MODES_BRIGHTNESS = VALID_COLOR_MODES - {ColorMode.ONOFF}

Definition at line 110 of file __init__.py.

◆ COLOR_MODES_COLOR

dictionary homeassistant.components.light.COLOR_MODES_COLOR
Initial value:
1 = {
2  ColorMode.HS,
3  ColorMode.RGB,
4  ColorMode.RGBW,
5  ColorMode.RGBWW,
6  ColorMode.XY,
7 }

Definition at line 111 of file __init__.py.

◆ DOMAIN

string homeassistant.components.light.DOMAIN = "light"

Definition at line 34 of file __init__.py.

◆ EFFECT_COLORLOOP

string homeassistant.components.light.EFFECT_COLORLOOP = "colorloop"

Definition at line 232 of file __init__.py.

◆ EFFECT_OFF

string homeassistant.components.light.EFFECT_OFF = "off"

Definition at line 233 of file __init__.py.

◆ EFFECT_RANDOM

string homeassistant.components.light.EFFECT_RANDOM = "random"

Definition at line 234 of file __init__.py.

◆ EFFECT_WHITE

string homeassistant.components.light.EFFECT_WHITE = "white"

Definition at line 235 of file __init__.py.

◆ ENTITY_ID_FORMAT

string homeassistant.components.light.ENTITY_ID_FORMAT = DOMAIN + ".{}"

Definition at line 36 of file __init__.py.

◆ FLASH_LONG

string homeassistant.components.light.FLASH_LONG = "long"

Definition at line 225 of file __init__.py.

◆ FLASH_SHORT

string homeassistant.components.light.FLASH_SHORT = "short"

Definition at line 224 of file __init__.py.

◆ LIGHT_PROFILES_FILE

string homeassistant.components.light.LIGHT_PROFILES_FILE = "light_profiles.csv"

Definition at line 239 of file __init__.py.

◆ PLATFORM_SCHEMA

homeassistant.components.light.PLATFORM_SCHEMA = cv.PLATFORM_SCHEMA

Definition at line 37 of file __init__.py.

◆ PLATFORM_SCHEMA_BASE

homeassistant.components.light.PLATFORM_SCHEMA_BASE = cv.PLATFORM_SCHEMA_BASE

Definition at line 38 of file __init__.py.

◆ SCAN_INTERVAL

homeassistant.components.light.SCAN_INTERVAL = timedelta(seconds=30)

Definition at line 39 of file __init__.py.

◆ SUPPORT_BRIGHTNESS

int homeassistant.components.light.SUPPORT_BRIGHTNESS = 1

Definition at line 54 of file __init__.py.

◆ SUPPORT_COLOR

int homeassistant.components.light.SUPPORT_COLOR = 16

Definition at line 58 of file __init__.py.

◆ SUPPORT_COLOR_TEMP

int homeassistant.components.light.SUPPORT_COLOR_TEMP = 2

Definition at line 55 of file __init__.py.

◆ SUPPORT_EFFECT

int homeassistant.components.light.SUPPORT_EFFECT = 4

Definition at line 56 of file __init__.py.

◆ SUPPORT_FLASH

int homeassistant.components.light.SUPPORT_FLASH = 8

Definition at line 57 of file __init__.py.

◆ SUPPORT_TRANSITION

int homeassistant.components.light.SUPPORT_TRANSITION = 32

Definition at line 59 of file __init__.py.

◆ VALID_BRIGHTNESS

homeassistant.components.light.VALID_BRIGHTNESS = vol.All(vol.Coerce(int), vol.Clamp(min=0, max=255))

Definition at line 243 of file __init__.py.

◆ VALID_BRIGHTNESS_PCT

homeassistant.components.light.VALID_BRIGHTNESS_PCT = vol.All(vol.Coerce(float), vol.Range(min=0, max=100))

Definition at line 244 of file __init__.py.

◆ VALID_BRIGHTNESS_STEP

homeassistant.components.light.VALID_BRIGHTNESS_STEP = vol.All(vol.Coerce(int), vol.Clamp(min=-255, max=255))

Definition at line 245 of file __init__.py.

◆ VALID_BRIGHTNESS_STEP_PCT

homeassistant.components.light.VALID_BRIGHTNESS_STEP_PCT = vol.All(vol.Coerce(float), vol.Clamp(min=-100, max=100))

Definition at line 246 of file __init__.py.

◆ VALID_COLOR_MODES

dictionary homeassistant.components.light.VALID_COLOR_MODES
Initial value:
1 = {
2  ColorMode.ONOFF,
3  ColorMode.BRIGHTNESS,
4  ColorMode.COLOR_TEMP,
5  ColorMode.HS,
6  ColorMode.XY,
7  ColorMode.RGB,
8  ColorMode.RGBW,
9  ColorMode.RGBWW,
10  ColorMode.WHITE,
11 }

Definition at line 99 of file __init__.py.

◆ VALID_FLASH

homeassistant.components.light.VALID_FLASH = vol.In([FLASH_SHORT, FLASH_LONG])

Definition at line 247 of file __init__.py.

◆ VALID_TRANSITION

homeassistant.components.light.VALID_TRANSITION = vol.All(vol.Coerce(float), vol.Clamp(min=0, max=6553))

Definition at line 242 of file __init__.py.

◆ VolDictType

homeassistant.components.light.VolDictType

Definition at line 249 of file __init__.py.