ESPHome 2025.11.4
Loading...
Searching...
No Matches
light_effect.h
Go to the documentation of this file.
1#pragma once
2
4
5namespace esphome {
6namespace light {
7
8class LightState;
9
11 public:
12 explicit LightEffect(const char *name) : name_(name) {}
13
15 virtual void start() {}
16
17 virtual void start_internal() { this->start(); }
18
20 virtual void stop() {}
21
23 virtual void apply() = 0;
24
29 const char *get_name() const { return this->name_; }
30
32 virtual void init() {}
33
35 this->state_ = state;
36 this->init();
37 }
38
41 uint32_t get_index() const;
42
44 bool is_active() const;
45
48 LightState *get_light_state() const { return this->state_; }
49
50 protected:
51 LightState *state_{nullptr};
52 const char *name_;
53
56};
57
58} // namespace light
59} // namespace esphome
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:69
bool state
Definition fan.h:0
Providing packet encoding functions for exchanging data with a remote host.
Definition a01nyub.cpp:7