12 inline static float random_cubic_float() {
23 const uint32_t now =
millis();
29 call.set_brightness_if_supported(out);
33 call.set_publish(
false);
66 const uint32_t now =
millis();
83 call.set_color_temperature(min +
random_float() * (max - min));
95 call.set_transition_length_if_supported(this->transition_length_);
96 call.set_publish(
true);
109 uint32_t transition_length_{};
118 void start()
override { this->initial_run_ =
true; }
120 const uint32_t now =
millis();
121 if (now - this->last_run_ >= this->
update_interval_ || this->initial_run_) {
122 this->last_run_ = now;
123 this->f_(this->initial_run_);
124 this->initial_run_ =
false;
129 std::function<void(bool initial_run)>
f_;
131 uint32_t last_run_{0};
138 void stop()
override { this->trig_->stop_action(); }
140 if (!this->trig_->is_action_running()) {
141 this->trig_->trigger();
160 const uint32_t now =
millis();
161 if (now - this->last_switch_ < this->colors_[this->at_color_].duration)
165 this->at_color_ = (this->at_color_ + 1) % this->colors_.size();
166 auto color = this->colors_[this->at_color_].color;
171 if (!color.is_on()) {
180 this->last_switch_ = now;
183 void set_colors(
const std::vector<StrobeLightEffectColor> &colors) { this->colors_ = colors; }
187 uint32_t last_switch_{0};
199 const float alpha = this->alpha_;
200 const float beta = 1.0f - alpha;
203 (random_cubic_float() * this->intensity_));
204 out.
set_red(remote.
get_red() * beta + current.
get_red() * alpha + (random_cubic_float() * this->intensity_));
209 (random_cubic_float() * this->intensity_));
211 (random_cubic_float() * this->intensity_));
LightCall & set_save(bool save)
Set whether this light call should trigger a save state to recover them at startup..
float get_warm_white() const
Get the warm white property of these light color values. In range 0.0 to 1.0.
LightCall & set_publish(bool publish)
Set whether this light call should trigger a publish state.
LightCall & set_red(optional< float > red)
Set the red RGB value of the light from 0.0 to 1.0.
LightColorValues current_values
The current values of the light as outputted to the light.
void set_warm_white(float warm_white)
Set the warm white property of these light color values. In range 0.0 to 1.0.
LightCall turn_on()
Make a light state call.
void set_transition_on_length(uint32_t transition_length)
float get_cold_white() const
Get the cold white property of these light color values. In range 0.0 to 1.0.
void set_min_max_brightness(float min, float max)
void set_green(float green)
Set the green property of these light color values. In range 0.0 to 1.0.
float get_min_mireds() const
void set_state(float state)
Set the state of these light color values. In range from 0.0 (off) to 1.0 (on)
float get_red() const
Get the red property of these light color values. In range 0.0 to 1.0.
Color temperature can be controlled.
FlickerLightEffect(const std::string &name)
AutomationLightEffect(const std::string &name)
uint32_t IRAM_ATTR HOT millis()
void set_colors(const std::vector< StrobeLightEffectColor > &colors)
void set_red(float red)
Set the red property of these light color values. In range 0.0 to 1.0.
float get_blue() const
Get the blue property of these light color values. In range 0.0 to 1.0.
LambdaLightEffect(const std::string &name, std::function< void(bool initial_run)> f, uint32_t update_interval)
LightCall & from_light_color_values(const LightColorValues &values)
uint32_t transition_length
This class represents the color state for a light object.
uint32_t last_color_change_
Brightness of cold and warm white output can be controlled.
float get_white() const
Get the white property of these light color values. In range 0.0 to 1.0.
void set_alpha(float alpha)
void set_transition_off_length(uint32_t transition_length)
LightCall & set_transition_length_if_supported(uint32_t transition_length)
Set the transition length property if the light supports transitions.
StrobeLightEffect(const std::string &name)
Random effect. Sets random colors every 10 seconds and slowly transitions between them...
ColorMode get_color_mode() const
Get the color mode of these light color values.
LightCall & set_state(optional< bool > state)
Set the binary ON/OFF state of the light.
void set_intensity(float intensity)
std::function< void(bool initial_run)> f_
uint32_t update_interval_
RandomLightEffect(const std::string &name)
void set_white(float white)
Set the white property of these light color values. In range 0.0 to 1.0.
uint32_t transition_on_length_
std::vector< StrobeLightEffectColor > colors_
uint32_t update_interval_
void set_update_interval(uint32_t update_interval)
void set_brightness(float brightness)
Set the brightness property of these light color values. In range 0.0 to 1.0.
void set_blue(float blue)
Set the blue property of these light color values. In range 0.0 to 1.0.
LightCall & set_green(optional< float > green)
Set the green RGB value of the light from 0.0 to 1.0.
void set_cold_white(float cold_white)
Set the cold white property of these light color values. In range 0.0 to 1.0.
Implementation of SPI Controller mode.
Color can be controlled using RGB format (includes a brightness control for the color).
float get_max_mireds() const
LightColorValues remote_values
The remote color values reported to the frontend.
uint32_t transition_off_length_
LightCall & set_brightness(optional< float > brightness)
Set the target brightness of the light from 0.0 (fully off) to 1.0 (fully on)
PulseLightEffect(const std::string &name)
void set_update_interval(uint32_t update_interval)
LightCall & set_blue(optional< float > blue)
Set the blue RGB value of the light from 0.0 to 1.0.
Trigger * get_trig() const
float random_float()
Return a random float between 0 and 1.
float get_green() const
Get the green property of these light color values. In range 0.0 to 1.0.
float get_brightness() const
Get the brightness property of these light color values. In range 0.0 to 1.0.
void set_transition_length(uint32_t transition_length)