ESPHome 2025.12.0-dev
Loading...
Searching...
No Matches
esphome::light::LightEffect Class Referenceabstract

#include <light_effect.h>

Inheritance diagram for esphome::light::LightEffect:
esphome::light::AddressableLightEffect esphome::light::AutomationLightEffect esphome::light::FlickerLightEffect esphome::light::LambdaLightEffect esphome::light::PulseLightEffect esphome::light::RandomLightEffect esphome::light::StrobeLightEffect esphome::adalight::AdalightLightEffect esphome::e131::E131AddressableLightEffect esphome::light::AddressableColorWipeEffect esphome::light::AddressableFireworksEffect esphome::light::AddressableFlickerEffect esphome::light::AddressableLambdaLightEffect esphome::light::AddressableRainbowLightEffect esphome::light::AddressableRandomTwinkleEffect esphome::light::AddressableScanEffect esphome::light::AddressableTwinkleEffect esphome::wled::WLEDLightEffect

Public Member Functions

 LightEffect (const char *name)
 
virtual void start ()
 Initialize this LightEffect. Will be called once after creation.
 
virtual void start_internal ()
 
virtual void stop ()
 Called when this effect is about to be removed.
 
virtual void apply ()=0
 Apply this effect. Use the provided state for starting transitions, ...
 
const char * get_name () const
 Returns the name of this effect.
 
virtual void init ()
 Internal method called by the LightState when this light effect is registered in it.
 
void init_internal (LightState *state)
 
uint32_t get_index () const
 Get the index of this effect in the parent light's effect list.
 
bool is_active () const
 Check if this effect is currently active.
 
LightStateget_light_state () const
 Get a reference to the parent light state.
 

Protected Member Functions

uint32_t get_index_in_parent_ () const
 Internal method to find this effect's index in the parent light's effect list.
 

Protected Attributes

LightStatestate_ {nullptr}
 
const char * name_
 

Detailed Description

Definition at line 10 of file light_effect.h.

Constructor & Destructor Documentation

◆ LightEffect()

esphome::light::LightEffect::LightEffect ( const char * name)
inlineexplicit

Definition at line 12 of file light_effect.h.

Member Function Documentation

◆ apply()

virtual void esphome::light::LightEffect::apply ( )
pure virtual

◆ get_index()

uint32_t esphome::light::LightEffect::get_index ( ) const

Get the index of this effect in the parent light's effect list.

Returns 0 if not found or not initialized.

Definition at line 7 of file light_effect.cpp.

◆ get_index_in_parent_()

uint32_t esphome::light::LightEffect::get_index_in_parent_ ( ) const
protected

Internal method to find this effect's index in the parent light's effect list.

Definition at line 21 of file light_effect.cpp.

◆ get_light_state()

LightState * esphome::light::LightEffect::get_light_state ( ) const
inline

Get a reference to the parent light state.

Returns nullptr if not initialized.

Definition at line 48 of file light_effect.h.

◆ get_name()

const char * esphome::light::LightEffect::get_name ( ) const
inline

Returns the name of this effect.

The returned pointer is valid for the lifetime of the program and must not be freed.

Definition at line 29 of file light_effect.h.

◆ init()

virtual void esphome::light::LightEffect::init ( )
inlinevirtual

Internal method called by the LightState when this light effect is registered in it.

Definition at line 32 of file light_effect.h.

◆ init_internal()

void esphome::light::LightEffect::init_internal ( LightState * state)
inline

Definition at line 34 of file light_effect.h.

◆ is_active()

bool esphome::light::LightEffect::is_active ( ) const

Check if this effect is currently active.

Definition at line 14 of file light_effect.cpp.

◆ start()

virtual void esphome::light::LightEffect::start ( )
inlinevirtual

◆ start_internal()

virtual void esphome::light::LightEffect::start_internal ( )
inlinevirtual

Reimplemented in esphome::light::AddressableLightEffect.

Definition at line 17 of file light_effect.h.

◆ stop()

virtual void esphome::light::LightEffect::stop ( )
inlinevirtual

Field Documentation

◆ name_

const char* esphome::light::LightEffect::name_
protected

Definition at line 52 of file light_effect.h.

◆ state_

LightState* esphome::light::LightEffect::state_ {nullptr}
protected

Definition at line 51 of file light_effect.h.


The documentation for this class was generated from the following files: