ESPHome 2025.12.3
Loading...
Searching...
No Matches
light_effect.cpp
Go to the documentation of this file.
1#include "light_effect.h"
2#include "light_state.h"
3
4namespace esphome::light {
5
7 if (this->state_ == nullptr) {
8 return 0;
9 }
10 return this->get_index_in_parent_();
11}
12
14 if (this->state_ == nullptr) {
15 return false;
16 }
17 return this->get_index() != 0 && this->state_->get_current_effect_index() == this->get_index();
18}
19
21 if (this->state_ == nullptr) {
22 return 0;
23 }
24
25 const auto &effects = this->state_->get_effects();
26 for (size_t i = 0; i < effects.size(); i++) {
27 if (effects[i] == this) {
28 return i + 1; // Effects are 1-indexed in the API
29 }
30 }
31 return 0; // Not found
32}
33
34} // 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.
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.
uint32_t get_current_effect_index() const
Get the currently active effect index (0 = no effect, 1+ = effect index).
const FixedVector< LightEffect * > & get_effects() const
Get all effects for this light state.