ESPHome 2025.12.0-dev
Loading...
Searching...
No Matches
esphome::light Namespace Reference

Data Structures

class  AddressableColorWipeEffect
 
struct  AddressableColorWipeEffectColor
 
class  AddressableFireworksEffect
 
class  AddressableFlickerEffect
 
class  AddressableLambdaLightEffect
 
class  AddressableLight
 
class  AddressableLightEffect
 
class  AddressableLightState
 Use a custom state class for addressable lights, to allow type system to discriminate between addressable and non-addressable lights. More...
 
class  AddressableLightTransformer
 
class  AddressableLightWrapper
 
class  AddressableRainbowLightEffect
 
class  AddressableRandomTwinkleEffect
 
class  AddressableScanEffect
 
class  AddressableSet
 
class  AddressableTwinkleEffect
 
class  AutomationLightEffect
 
class  ColorCapabilityHelper
 Helper class to allow bitwise operations on ColorCapability. More...
 
struct  ColorModeBitPolicy
 Bit mapping policy for ColorMode Uses lookup table for non-contiguous enum values. More...
 
class  ColorModeHelper
 Helper class to allow bitwise operations on ColorMode with ColorCapability. More...
 
class  DimRelativeAction
 
class  ESPColorCorrection
 
class  ESPColorSettable
 
class  ESPColorView
 
struct  ESPHSVColor
 
class  ESPRangeIterator
 
class  ESPRangeView
 A half-open range of LEDs, inclusive of the begin index and exclusive of the end index, using zero-based numbering. More...
 
class  FlickerLightEffect
 
class  LambdaLightEffect
 
class  LightCall
 This class represents a requested change in a light state. More...
 
class  LightColorValues
 This class represents the color state for a light object. More...
 
class  LightControlAction
 
class  LightEffect
 
class  LightFlashTransformer
 
class  LightIsOffCondition
 
class  LightIsOnCondition
 
class  LightJSONSchema
 
class  LightOutput
 Interface to write LightStates to hardware. More...
 
class  LightState
 This class represents the communication layer between the front-end MQTT layer and the hardware output layer. More...
 
struct  LightStateRTCState
 
class  LightStateTrigger
 
class  LightTraits
 This class is used to represent the capabilities of a light. More...
 
class  LightTransformer
 Base class for all light color transformers, such as transitions or flashes. More...
 
class  LightTransitionTransformer
 
class  LightTurnOffTrigger
 
class  LightTurnOnTrigger
 
class  PulseLightEffect
 Pulse effect. More...
 
class  RandomLightEffect
 Random effect. Sets random colors every 10 seconds and slowly transitions between them. More...
 
class  StrobeLightEffect
 
struct  StrobeLightEffectColor
 
class  ToggleAction
 

Typedefs

using color_mode_bitmask_t = uint16_t
 
using ColorModeMask = FiniteSetMask<ColorMode, ColorModeBitPolicy>
 

Enumerations

enum class  LimitMode { CLAMP , DO_NOTHING }
 
enum class  ColorCapability : uint8_t {
  ON_OFF = 1 << 0 , BRIGHTNESS = 1 << 1 , WHITE = 1 << 2 , COLOR_TEMPERATURE = 1 << 3 ,
  COLD_WARM_WHITE = 1 << 4 , RGB = 1 << 5
}
 Color capabilities are the various outputs that a light has and that can be independently controlled by the user. More...
 
enum class  ColorMode : uint8_t {
  UNKNOWN = 0 , ON_OFF = (uint8_t) ColorCapability::ON_OFF , BRIGHTNESS = (uint8_t) (ColorCapability::ON_OFF | ColorCapability::BRIGHTNESS) , WHITE = (uint8_t) (ColorCapability::ON_OFF | ColorCapability::BRIGHTNESS | ColorCapability::WHITE) ,
  COLOR_TEMPERATURE , COLD_WARM_WHITE , RGB = (uint8_t) (ColorCapability::ON_OFF | ColorCapability::BRIGHTNESS | ColorCapability::RGB) , RGB_WHITE ,
  RGB_COLOR_TEMPERATURE , RGB_COLD_WARM_WHITE
}
 Color modes are a combination of color capabilities that can be used at the same time. More...
 
enum  LightRestoreMode : uint8_t {
  LIGHT_RESTORE_DEFAULT_OFF , LIGHT_RESTORE_DEFAULT_ON , LIGHT_ALWAYS_OFF , LIGHT_ALWAYS_ON ,
  LIGHT_RESTORE_INVERTED_DEFAULT_OFF , LIGHT_RESTORE_INVERTED_DEFAULT_ON , LIGHT_RESTORE_AND_OFF , LIGHT_RESTORE_AND_ON
}
 

Functions

Color color_from_light_color_values (LightColorValues val)
 Convert the color information from a LightColorValues object to a Color object (does not apply brightness).
 
constexpr uint8_t subtract_scaled_difference (uint8_t a, uint8_t b, int32_t scale)
 
void addressableset_warn_about_scale (const char *field)
 
constexpr ColorCapabilityHelper operator& (ColorCapability lhs, ColorCapability rhs)
 
constexpr ColorCapabilityHelper operator& (ColorCapabilityHelper lhs, ColorCapability rhs)
 
constexpr ColorCapabilityHelper operator| (ColorCapability lhs, ColorCapability rhs)
 
constexpr ColorCapabilityHelper operator| (ColorCapabilityHelper lhs, ColorCapability rhs)
 
constexpr ColorModeHelper operator& (ColorMode lhs, ColorMode rhs)
 
constexpr ColorModeHelper operator& (ColorMode lhs, ColorCapability rhs)
 
constexpr ColorModeHelper operator& (ColorModeHelper lhs, ColorMode rhs)
 
constexpr ColorModeHelper operator| (ColorMode lhs, ColorMode rhs)
 
constexpr ColorModeHelper operator| (ColorMode lhs, ColorCapability rhs)
 
constexpr ColorModeHelper operator| (ColorModeHelper lhs, ColorMode rhs)
 
constexpr uint16_t compute_capability_bitmask (ColorCapability capability)
 Helper to compute capability bitmask at compile time.
 
int capability_to_index (ColorCapability capability)
 Helper function to convert a power-of-2 ColorCapability value to an array index for CAPABILITY_BITMASKS lookup.
 
bool has_capability (const ColorModeMask &mask, ColorCapability capability)
 Check if any mode in the bitmask has a specific capability Used for checking if a light supports a capability (e.g., BRIGHTNESS, RGB)
 
int32_t HOT interpret_index (int32_t index, int32_t size)
 
 IMPLEMENT_LIGHT_CALL_SETTER (state, bool, FLAG_HAS_STATE) IMPLEMENT_LIGHT_CALL_SETTER(transition_length
 
FLAG_HAS_TRANSITION IMPLEMENT_LIGHT_CALL_SETTER (flash_length, uint32_t, FLAG_HAS_FLASH) IMPLEMENT_LIGHT_CALL_SETTER(brightness
 
FLAG_HAS_TRANSITION FLAG_HAS_BRIGHTNESS IMPLEMENT_LIGHT_CALL_SETTER (color_mode, ColorMode, FLAG_HAS_COLOR_MODE) IMPLEMENT_LIGHT_CALL_SETTER(color_brightness
 
FLAG_HAS_TRANSITION FLAG_HAS_BRIGHTNESS FLAG_HAS_COLOR_BRIGHTNESS IMPLEMENT_LIGHT_CALL_SETTER (red, float, FLAG_HAS_RED) IMPLEMENT_LIGHT_CALL_SETTER(green
 
FLAG_HAS_TRANSITION FLAG_HAS_BRIGHTNESS FLAG_HAS_COLOR_BRIGHTNESS FLAG_HAS_GREEN IMPLEMENT_LIGHT_CALL_SETTER (blue, float, FLAG_HAS_BLUE) IMPLEMENT_LIGHT_CALL_SETTER(white
 
FLAG_HAS_TRANSITION FLAG_HAS_BRIGHTNESS FLAG_HAS_COLOR_BRIGHTNESS FLAG_HAS_GREEN FLAG_HAS_WHITE IMPLEMENT_LIGHT_CALL_SETTER (color_temperature, float, FLAG_HAS_COLOR_TEMPERATURE) IMPLEMENT_LIGHT_CALL_SETTER(cold_white
 
FLAG_HAS_TRANSITION FLAG_HAS_BRIGHTNESS FLAG_HAS_COLOR_BRIGHTNESS FLAG_HAS_GREEN FLAG_HAS_WHITE FLAG_HAS_COLD_WHITE IMPLEMENT_LIGHT_CALL_SETTER (warm_white, float, FLAG_HAS_WARM_WHITE) LightCall &LightCall
 

Variables

constexpr ColorMode COLOR_MODE_LOOKUP []
 
constexpr int COLOR_CAPABILITY_COUNT = 6
 
constexpr uint16_t CAPABILITY_BITMASKS []
 Compile-time lookup table mapping ColorCapability to bitmask This array is computed at compile time using constexpr.
 
 uint32_t
 
FLAG_HAS_TRANSITION float
 

Typedef Documentation

◆ color_mode_bitmask_t

Definition at line 109 of file color_mode.h.

◆ ColorModeMask

Enumeration Type Documentation

◆ ColorCapability

enum class esphome::light::ColorCapability : uint8_t
strong

Color capabilities are the various outputs that a light has and that can be independently controlled by the user.

Enumerator
ON_OFF 

Light can be turned on/off.

BRIGHTNESS 

Master brightness of the light can be controlled.

WHITE 

Brightness of white channel can be controlled separately from other channels.

COLOR_TEMPERATURE 

Color temperature can be controlled.

COLD_WARM_WHITE 

Brightness of cold and warm white output can be controlled.

RGB 

Color can be controlled using RGB format (includes a brightness control for the color).

Definition at line 10 of file color_mode.h.

◆ ColorMode

enum class esphome::light::ColorMode : uint8_t
strong

Color modes are a combination of color capabilities that can be used at the same time.

Enumerator
UNKNOWN 

No color mode configured (cannot be a supported mode, only active when light is off).

ON_OFF 

Only on/off control.

BRIGHTNESS 

Dimmable light.

WHITE 

White output only (use only if the light also has another color mode such as RGB).

COLOR_TEMPERATURE 

Controllable color temperature output.

COLD_WARM_WHITE 

Cold and warm white output with individually controllable brightness.

RGB 

RGB color output.

RGB_WHITE 

RGB color output and a separate white output.

RGB_COLOR_TEMPERATURE 

RGB color output and a separate white output with controllable color temperature.

RGB_COLD_WARM_WHITE 

RGB color output, and separate cold and warm white outputs.

Definition at line 50 of file color_mode.h.

◆ LightRestoreMode

Enumerator
LIGHT_RESTORE_DEFAULT_OFF 
LIGHT_RESTORE_DEFAULT_ON 
LIGHT_ALWAYS_OFF 
LIGHT_ALWAYS_ON 
LIGHT_RESTORE_INVERTED_DEFAULT_OFF 
LIGHT_RESTORE_INVERTED_DEFAULT_ON 
LIGHT_RESTORE_AND_OFF 
LIGHT_RESTORE_AND_ON 

Definition at line 23 of file light_state.h.

◆ LimitMode

enum class esphome::light::LimitMode
strong
Enumerator
CLAMP 
DO_NOTHING 

Definition at line 10 of file automation.h.

Function Documentation

◆ addressableset_warn_about_scale()

void esphome::light::addressableset_warn_about_scale ( const char * field)

Definition at line 9 of file automation.cpp.

◆ capability_to_index()

int esphome::light::capability_to_index ( ColorCapability capability)
inline

Helper function to convert a power-of-2 ColorCapability value to an array index for CAPABILITY_BITMASKS lookup.

This function maps ColorCapability values (1, 2, 4, 8, 16, 32) to array indices (0, 1, 2, 3, 4, 5). Used to index into the CAPABILITY_BITMASKS lookup table.

Parameters
capabilityA ColorCapability enum value (must be a power of 2).
Returns
The corresponding array index (0-based).

Definition at line 190 of file color_mode.h.

◆ color_from_light_color_values()

Color esphome::light::color_from_light_color_values ( LightColorValues val)

Convert the color information from a LightColorValues object to a Color object (does not apply brightness).

Definition at line 30 of file addressable_light.cpp.

◆ compute_capability_bitmask()

uint16_t esphome::light::compute_capability_bitmask ( ColorCapability capability)
constexpr

Helper to compute capability bitmask at compile time.

Definition at line 154 of file color_mode.h.

◆ has_capability()

bool esphome::light::has_capability ( const ColorModeMask & mask,
ColorCapability capability )
inline

Check if any mode in the bitmask has a specific capability Used for checking if a light supports a capability (e.g., BRIGHTNESS, RGB)

Definition at line 208 of file color_mode.h.

◆ IMPLEMENT_LIGHT_CALL_SETTER() [1/7]

FLAG_HAS_TRANSITION FLAG_HAS_BRIGHTNESS FLAG_HAS_COLOR_BRIGHTNESS FLAG_HAS_GREEN esphome::light::IMPLEMENT_LIGHT_CALL_SETTER ( blue ,
float ,
FLAG_HAS_BLUE  )

◆ IMPLEMENT_LIGHT_CALL_SETTER() [2/7]

FLAG_HAS_TRANSITION FLAG_HAS_BRIGHTNESS esphome::light::IMPLEMENT_LIGHT_CALL_SETTER ( color_mode ,
ColorMode ,
FLAG_HAS_COLOR_MODE  )

◆ IMPLEMENT_LIGHT_CALL_SETTER() [3/7]

FLAG_HAS_TRANSITION FLAG_HAS_BRIGHTNESS FLAG_HAS_COLOR_BRIGHTNESS FLAG_HAS_GREEN FLAG_HAS_WHITE esphome::light::IMPLEMENT_LIGHT_CALL_SETTER ( color_temperature ,
float ,
FLAG_HAS_COLOR_TEMPERATURE  )

◆ IMPLEMENT_LIGHT_CALL_SETTER() [4/7]

FLAG_HAS_TRANSITION esphome::light::IMPLEMENT_LIGHT_CALL_SETTER ( flash_length ,
uint32_t ,
FLAG_HAS_FLASH  )

◆ IMPLEMENT_LIGHT_CALL_SETTER() [5/7]

FLAG_HAS_TRANSITION FLAG_HAS_BRIGHTNESS FLAG_HAS_COLOR_BRIGHTNESS esphome::light::IMPLEMENT_LIGHT_CALL_SETTER ( red ,
float ,
FLAG_HAS_RED  )

◆ IMPLEMENT_LIGHT_CALL_SETTER() [6/7]

esphome::light::IMPLEMENT_LIGHT_CALL_SETTER ( state ,
bool ,
FLAG_HAS_STATE  )

◆ IMPLEMENT_LIGHT_CALL_SETTER() [7/7]

FLAG_HAS_TRANSITION FLAG_HAS_BRIGHTNESS FLAG_HAS_COLOR_BRIGHTNESS FLAG_HAS_GREEN FLAG_HAS_WHITE FLAG_HAS_COLD_WHITE esphome::light::IMPLEMENT_LIGHT_CALL_SETTER ( warm_white ,
float ,
FLAG_HAS_WARM_WHITE  ) &

Definition at line 612 of file light_call.cpp.

◆ interpret_index()

int32_t esphome::light::interpret_index ( int32_t index,
int32_t size )

Definition at line 7 of file esp_range_view.cpp.

◆ operator&() [1/5]

ColorCapabilityHelper esphome::light::operator& ( ColorCapability lhs,
ColorCapability rhs )
constexpr

Definition at line 36 of file color_mode.h.

◆ operator&() [2/5]

ColorCapabilityHelper esphome::light::operator& ( ColorCapabilityHelper lhs,
ColorCapability rhs )
constexpr

Definition at line 39 of file color_mode.h.

◆ operator&() [3/5]

ColorModeHelper esphome::light::operator& ( ColorMode lhs,
ColorCapability rhs )
constexpr

Definition at line 92 of file color_mode.h.

◆ operator&() [4/5]

ColorModeHelper esphome::light::operator& ( ColorMode lhs,
ColorMode rhs )
constexpr

Definition at line 89 of file color_mode.h.

◆ operator&() [5/5]

ColorModeHelper esphome::light::operator& ( ColorModeHelper lhs,
ColorMode rhs )
constexpr

Definition at line 95 of file color_mode.h.

◆ operator|() [1/5]

ColorCapabilityHelper esphome::light::operator| ( ColorCapability lhs,
ColorCapability rhs )
constexpr

Definition at line 42 of file color_mode.h.

◆ operator|() [2/5]

ColorCapabilityHelper esphome::light::operator| ( ColorCapabilityHelper lhs,
ColorCapability rhs )
constexpr

Definition at line 45 of file color_mode.h.

◆ operator|() [3/5]

ColorModeHelper esphome::light::operator| ( ColorMode lhs,
ColorCapability rhs )
constexpr

Definition at line 101 of file color_mode.h.

◆ operator|() [4/5]

ColorModeHelper esphome::light::operator| ( ColorMode lhs,
ColorMode rhs )
constexpr

Definition at line 98 of file color_mode.h.

◆ operator|() [5/5]

ColorModeHelper esphome::light::operator| ( ColorModeHelper lhs,
ColorMode rhs )
constexpr

Definition at line 104 of file color_mode.h.

◆ subtract_scaled_difference()

uint8_t esphome::light::subtract_scaled_difference ( uint8_t a,
uint8_t b,
int32_t scale )
inlineconstexpr

Definition at line 64 of file addressable_light.cpp.

Variable Documentation

◆ CAPABILITY_BITMASKS

uint16_t esphome::light::CAPABILITY_BITMASKS[]
constexpr
Initial value:
= {
compute_capability_bitmask(ColorCapability::ON_OFF),
compute_capability_bitmask(ColorCapability::BRIGHTNESS),
compute_capability_bitmask(ColorCapability::WHITE),
compute_capability_bitmask(ColorCapability::COLOR_TEMPERATURE),
compute_capability_bitmask(ColorCapability::COLD_WARM_WHITE),
compute_capability_bitmask(ColorCapability::RGB),
}
constexpr uint16_t compute_capability_bitmask(ColorCapability capability)
Helper to compute capability bitmask at compile time.
Definition color_mode.h:154

Compile-time lookup table mapping ColorCapability to bitmask This array is computed at compile time using constexpr.

Definition at line 171 of file color_mode.h.

◆ COLOR_CAPABILITY_COUNT

int esphome::light::COLOR_CAPABILITY_COUNT = 6
constexpr

Definition at line 151 of file color_mode.h.

◆ COLOR_MODE_LOOKUP

ColorMode esphome::light::COLOR_MODE_LOOKUP[]
constexpr
Initial value:
= {
ColorMode::UNKNOWN,
ColorMode::ON_OFF,
ColorMode::BRIGHTNESS,
ColorMode::WHITE,
ColorMode::COLOR_TEMPERATURE,
ColorMode::COLD_WARM_WHITE,
ColorMode::RGB,
ColorMode::RGB_WHITE,
ColorMode::RGB_COLOR_TEMPERATURE,
ColorMode::RGB_COLD_WARM_WHITE,
}

Definition at line 113 of file color_mode.h.

◆ float

FLAG_HAS_TRANSITION FLAG_HAS_BRIGHTNESS FLAG_HAS_COLOR_BRIGHTNESS FLAG_HAS_GREEN FLAG_HAS_WHITE esphome::light::float

Definition at line 603 of file light_call.cpp.

◆ uint32_t

esphome::light::uint32_t

Definition at line 601 of file light_call.cpp.