ESPHome 2026.1.0-dev
Loading...
Searching...
No Matches
light_effect.h
Go to the documentation of this file.
1#pragma once
2
4
5namespace esphome::light {
6
7class LightState;
8
10 public:
11 explicit LightEffect(const char *name) : name_(name) {}
12
14 virtual void start() {}
15
16 virtual void start_internal() { this->start(); }
17
19 virtual void stop() {}
20
22 virtual void apply() = 0;
23
28 const char *get_name() const { return this->name_; }
29
31 virtual void init() {}
32
34 this->state_ = state;
35 this->init();
36 }
37
40 uint32_t get_index() const;
41
43 bool is_active() const;
44
47 LightState *get_light_state() const { return this->state_; }
48
49 protected:
50 LightState *state_{nullptr};
51 const char *name_;
52
55};
56
57} // namespace esphome::light
uint32_t get_index_in_parent_() const
Internal method to find this effect's index in the parent light's effect list.
LightEffect(const char *name)
virtual void init()
Internal method called by the LightState when this light effect is registered in it.
virtual void start()
Initialize this LightEffect. Will be called once after creation.
uint32_t get_index() const
Get the index of this effect in the parent light's effect list.
virtual void apply()=0
Apply this effect. Use the provided state for starting transitions, ...
LightState * get_light_state() const
Get a reference to the parent light state.
const char * get_name() const
Returns the name of this effect.
virtual void stop()
Called when this effect is about to be removed.
virtual void start_internal()
void init_internal(LightState *state)
bool is_active() const
Check if this effect is currently active.
This class represents the communication layer between the front-end MQTT layer and the hardware outpu...
Definition light_state.h:91
bool state
Definition fan.h:0