17 void play(
const Ts &...
x)
override {
46 void play(const Ts &...
x)
override {
49 call.
set_state(this->state_.optional_value(
x...));
52 call.
set_red(this->red_.optional_value(
x...));
53 call.
set_green(this->green_.optional_value(
x...));
54 call.
set_blue(this->blue_.optional_value(
x...));
55 call.
set_white(this->white_.optional_value(
x...));
59 call.
set_effect(this->effect_.optional_value(
x...));
76 void
play(const Ts &...
x)
override {
78 float rel = this->relative_brightness_.value(
x...);
85 call.set_state(new_brightness != 0.0f);
86 call.set_brightness(new_brightness);
88 call.set_transition_length(this->transition_length_.optional_value(
x...));
134 auto should_trigger = is_on && !this->
last_on_;
138 if (should_trigger) {
189 void play(const Ts &...
x)
override {
191 int32_t range_from =
interpret_index(this->range_from_.value_or(
x..., 0), out->size());
192 if (range_from < 0 || range_from >= out->size())
195 int32_t range_to =
interpret_index(this->range_to_.value_or(
x..., out->size() - 1) + 1, out->size());
196 if (range_to < 0 || range_to >= out->size())
197 range_to = out->size();
199 uint8_t color_brightness =
200 to_uint8_scale(this->color_brightness_.value_or(
x..., this->parent_->remote_values.get_color_brightness()));
201 auto range = out->range(range_from, range_to);
202 if (this->red_.has_value())
204 if (this->green_.has_value())
206 if (this->blue_.has_value())
208 if (this->white_.has_value())
210 out->schedule_show();
220 return static_cast<uint8_t
>(value);
222 return to_uint8_scale(value);
virtual void play(const Ts &...x)=0
Base class for all automation conditions.
void trigger(const Ts &...x)
static uint8_t to_uint8_compat(float value, const char *field)
AddressableSet(LightState *parent)
TEMPLATABLE_VALUE(int32_t, range_from) TEMPLATABLE_VALUE(int32_t
TEMPLATABLE_VALUE(float, relative_brightness) TEMPLATABLE_VALUE(uint32_t
DimRelativeAction(LightState *parent)
void set_min_max_brightness(float min, float max)
void set_limit_mode(LimitMode limit_mode)
transition_length void play(const Ts &...x) override
LightCall & set_color_temperature(optional< float > color_temperature)
Set the color temperature of the light in mireds for CWWW or RGBWW lights.
LightCall & set_color_brightness(optional< float > brightness)
Set the color brightness of the light from 0.0 (no color) to 1.0 (fully on)
LightCall & set_effect(optional< std::string > effect)
Set the effect of the light by its name.
LightCall & set_white(optional< float > white)
Set the white value value of the light from 0.0 to 1.0 for RGBW[W] lights.
LightCall & set_green(optional< float > green)
Set the green RGB value of the light from 0.0 to 1.0.
LightCall & set_warm_white(optional< float > warm_white)
Set the warm white value of the light from 0.0 to 1.0.
LightCall & set_blue(optional< float > blue)
Set the blue RGB value of the light from 0.0 to 1.0.
LightCall & set_flash_length(optional< uint32_t > flash_length)
Start and set the flash length of this call in milliseconds.
LightCall & set_cold_white(optional< float > cold_white)
Set the cold white value of the light from 0.0 to 1.0.
LightCall & set_red(optional< float > red)
Set the red RGB value of the light from 0.0 to 1.0.
LightCall & set_brightness(optional< float > brightness)
Set the target brightness of the light from 0.0 (fully off) to 1.0 (fully on)
LightCall & set_state(optional< bool > state)
Set the binary ON/OFF state of the light.
LightCall & set_color_mode(optional< ColorMode > color_mode)
Set the color mode of the light.
LightCall & set_transition_length(optional< uint32_t > transition_length)
Set the transition length of this call in milliseconds.
bool is_on() const
Get the binary true/false state of these light color values.
void as_brightness(float *brightness) const
Convert these light color values to a brightness-only representation and write them to brightness.
state flash_length color_brightness green white cold_white effect void play(const Ts &...x) override
TEMPLATABLE_VALUE(ColorMode, color_mode) TEMPLATABLE_VALUE(bool
LightControlAction(LightState *parent)
bool check(const Ts &...x) override
LightIsOffCondition(LightState *state)
LightIsOnCondition(LightState *state)
bool check(const Ts &...x) override
Listener interface for light remote value changes.
This class represents the communication layer between the front-end MQTT layer and the hardware outpu...
void add_remote_values_listener(LightRemoteValuesListener *listener)
Add a listener for remote values changes.
LightColorValues remote_values
The remote color values reported to the frontend.
LightOutput * get_output() const
Get the light output associated with this object.
void add_target_state_reached_listener(LightTargetStateReachedListener *listener)
Add a listener for target state reached.
LightColorValues current_values
The current values of the light as outputted to the light.
void on_light_remote_values_update() override
LightStateTrigger(LightState *a_light)
Listener interface for light target state reached.
void on_light_target_state_reached() override
LightTurnOffTrigger(LightState *a_light)
LightTurnOnTrigger(LightState *a_light)
void on_light_remote_values_update() override
TEMPLATABLE_VALUE(uint32_t, transition_length) void play(const Ts &...x) override
ToggleAction(LightState *state)
void addressableset_warn_about_scale(const char *field)
ColorMode
Color modes are a combination of color capabilities that can be used at the same time.
int32_t HOT interpret_index(int32_t index, int32_t size)