ESPHome 2025.9.0
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 {
5namespace light {
6
8 if (this->state_ == nullptr) {
9 return 0;
10 }
11 return this->get_index_in_parent_();
12}
13
15 if (this->state_ == nullptr) {
16 return false;
17 }
18 return this->get_index() != 0 && this->state_->get_current_effect_index() == this->get_index();
19}
20
22 if (this->state_ == nullptr) {
23 return 0;
24 }
25
26 const auto &effects = this->state_->get_effects();
27 for (size_t i = 0; i < effects.size(); i++) {
28 if (effects[i] == this) {
29 return i + 1; // Effects are 1-indexed in the API
30 }
31 }
32 return 0; // Not found
33}
34
35} // namespace light
36} // namespace esphome
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.
const std::vector< LightEffect * > & get_effects() const
Get all effects for this light state.
uint32_t get_current_effect_index() const
Get the currently active effect index (0 = no effect, 1+ = effect index).
Providing packet encoding functions for exchanging data with a remote host.
Definition a01nyub.cpp:7