16 void play(Ts... x)
override {
45 void play(Ts... x)
override {
46 auto call = this->parent_->make_call();
47 call.set_color_mode(this->color_mode_.optional_value(x...));
48 call.set_state(this->
state_.optional_value(x...));
49 call.set_brightness(this->brightness_.optional_value(x...));
50 call.set_color_brightness(this->color_brightness_.optional_value(x...));
51 call.set_red(this->red_.optional_value(x...));
52 call.set_green(this->green_.optional_value(x...));
53 call.set_blue(this->blue_.optional_value(x...));
54 call.set_white(this->white_.optional_value(x...));
55 call.set_color_temperature(this->color_temperature_.optional_value(x...));
56 call.set_cold_white(this->cold_white_.optional_value(x...));
57 call.set_warm_white(this->warm_white_.optional_value(x...));
58 call.set_effect(this->effect_.optional_value(x...));
59 call.set_flash_length(this->flash_length_.optional_value(x...));
60 call.set_transition_length(this->transition_length_.optional_value(x...));
75 void
play(Ts... x)
override {
76 auto call = this->parent_->make_call();
77 float rel = this->relative_brightness_.value(x...);
79 this->parent_->remote_values.as_brightness(&cur);
80 float new_brightness =
clamp(cur + rel, 0.0f, 1.0f);
81 call.set_state(new_brightness != 0.0f);
82 call.set_brightness(new_brightness);
84 call.set_transition_length(this->transition_length_.optional_value(x...));
116 auto should_trigger = is_on && !this->last_on_;
119 this->last_on_ = is_on;
120 if (should_trigger) {
167 void play(Ts... x)
override {
169 int32_t range_from =
interpret_index(this->range_from_.value_or(x..., 0), out->size());
170 if (range_from < 0 || range_from >= out->size())
173 int32_t range_to =
interpret_index(this->range_to_.value_or(x..., out->size() - 1) + 1, out->size());
174 if (range_to < 0 || range_to >= out->size())
175 range_to = out->size();
177 uint8_t color_brightness =
178 to_uint8_scale(this->color_brightness_.value_or(x..., this->parent_->remote_values.get_color_brightness()));
179 auto range = out->range(range_from, range_to);
180 if (this->red_.has_value())
181 range.set_red(esp_scale8(to_uint8_compat(this->red_.value(x...),
"red"), color_brightness));
182 if (this->green_.has_value())
183 range.set_green(esp_scale8(to_uint8_compat(this->green_.value(x...),
"green"), color_brightness));
184 if (this->blue_.has_value())
185 range.set_blue(esp_scale8(to_uint8_compat(this->blue_.value(x...),
"blue"), color_brightness));
186 if (this->white_.has_value())
187 range.set_white(to_uint8_compat(this->white_.value(x...),
"white"));
188 out->schedule_show();
198 return static_cast<uint8_t
>(value);
200 return to_uint8_scale(value);
ToggleAction(LightState *state)
ColorMode
Color modes are a combination of color capabilities that can be used at the same time.
This class represents the communication layer between the front-end MQTT layer and the hardware outpu...
bool is_on() const
Get the binary true/false state of these light color values.
LightColorValues current_values
The current values of the light as outputted to the light.
void addressableset_warn_about_scale(const char *field)
void add_new_target_state_reached_callback(std::function< void()> &&send_callback)
The callback is called once the state of current_values and remote_values are equal (when the transit...
int32_t HOT interpret_index(int32_t index, int32_t size)
LightTurnOffTrigger(LightState *a_light)
LightCall & set_transition_length(optional< uint32_t > transition_length)
Set the transition length of this call in milliseconds.
constexpr const T & clamp(const T &v, const T &lo, const T &hi, Compare comp)
LightIsOffCondition(LightState *state)
AddressableSet(LightState *parent)
DimRelativeAction(LightState *parent)
Base class for all automation conditions.
TEMPLATABLE_VALUE(uint32_t, transition_length) void play(Ts... x) override
bool check(Ts... x) override
LightStateTrigger(LightState *a_light)
void add_new_remote_values_callback(std::function< void()> &&send_callback)
This lets front-end components subscribe to light change events.
bool check(Ts... x) override
LightControlAction(LightState *parent)
static uint8_t to_uint8_compat(float value, const char *field)
LightTurnOnTrigger(LightState *a_light)
LightColorValues remote_values
The remote color values reported to the frontend.
LightIsOnCondition(LightState *state)
virtual void play(Ts... x)=0