18 void set_transition_length(V value)
19 requires(HasTransitionLength)
24 void play(
const Ts &...
x)
override {
26 float rel = this->relative_brightness_.value(
x...);
33 call.set_state(new_brightness != 0.0f);
34 call.set_brightness(new_brightness);
36 if constexpr (HasTransitionLength) {
69 void play(
const Ts &...)
override {
78 if constexpr (Forward) {
79 next = (current + 1) % total;
81 next = (current + total - 1) % total;
84 if constexpr (Forward) {
87 next = (current <= 1) ? static_cast<uint32_t>(
count) : current - 1;
111 auto should_trigger = is_on && !this->
last_on_;
115 if (should_trigger) {
166 void play(const Ts &...
x)
override {
169 if (range_from < 0 || range_from >=
out->size())
173 if (range_to < 0 || range_to >=
out->size())
174 range_to =
out->size();
176 uint8_t color_brightness =
177 to_uint8_scale(this->color_brightness_.value_or(
x..., this->parent_->remote_values.get_color_brightness()));
178 auto range =
out->range(range_from, range_to);
179 if (this->red_.has_value())
181 if (this->green_.has_value())
183 if (this->blue_.has_value())
185 if (this->white_.has_value())
187 out->schedule_show();
197 return static_cast<uint8_t
>(value);
199 return to_uint8_scale(value);
virtual void play(const Ts &...x)=0
Function-pointer-only templatable storage (4 bytes on 32-bit).
void trigger(const Ts &...x) ESPHOME_ALWAYS_INLINE
static uint8_t to_uint8_compat(float value, const char *field)
AddressableSet(LightState *parent)
TEMPLATABLE_VALUE(int32_t, range_from) TEMPLATABLE_VALUE(int32_t
void play(const Ts &...x) override
TEMPLATABLE_VALUE(float, relative_brightness) template< typename V > void set_transition_length(V value)
void set_limit_mode(LimitMode limit_mode)
std::conditional_t< HasTransitionLength, TemplatableFn< uint32_t, Ts... >, NoTransition > transition_length_
DimRelativeAction(LightState *parent)
void set_min_max_brightness(float min, float max)
LightCall & set_effect(optional< std::string > effect)
Set the effect of the light by its name.
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.
LightEffectCycleAction(LightState *parent)
void play(const Ts &...) override
void set_include_none(bool include_none)
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.
uint32_t get_current_effect_index() const
Get the currently active effect index (0 = no effect, 1+ = effect index).
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.
LightCall turn_on()
Make a light state call.
LightColorValues current_values
The current values of the light as outputted to the light.
size_t get_effect_count() const
Get the total number of effects available for this 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
std::vector< uint8_t > & out
void addressableset_warn_about_scale(const char *field)
int32_t HOT interpret_index(int32_t index, int32_t size)