ESPHome  2022.11.4
Public Member Functions | Protected Member Functions | Protected Attributes
esphome::light::LightCall Class Reference

This class represents a requested change in a light state. More...

#include <light_call.h>

Public Member Functions

 LightCall (LightState *parent)
 
LightCallset_state (optional< bool > state)
 Set the binary ON/OFF state of the light. More...
 
LightCallset_state (bool state)
 Set the binary ON/OFF state of the light. More...
 
LightCallset_transition_length (optional< uint32_t > transition_length)
 Set the transition length of this call in milliseconds. More...
 
LightCallset_transition_length (uint32_t transition_length)
 Set the transition length of this call in milliseconds. More...
 
LightCallset_transition_length_if_supported (uint32_t transition_length)
 Set the transition length property if the light supports transitions. More...
 
LightCallset_flash_length (optional< uint32_t > flash_length)
 Start and set the flash length of this call in milliseconds. More...
 
LightCallset_flash_length (uint32_t flash_length)
 Start and set the flash length of this call in milliseconds. More...
 
LightCallset_brightness (optional< float > brightness)
 Set the target brightness of the light from 0.0 (fully off) to 1.0 (fully on) More...
 
LightCallset_brightness (float brightness)
 Set the target brightness of the light from 0.0 (fully off) to 1.0 (fully on) More...
 
LightCallset_brightness_if_supported (float brightness)
 Set the brightness property if the light supports brightness. More...
 
LightCallset_color_mode (optional< ColorMode > color_mode)
 Set the color mode of the light. More...
 
LightCallset_color_mode (ColorMode color_mode)
 Set the color mode of the light. More...
 
LightCallset_color_mode_if_supported (ColorMode color_mode)
 Set the color mode of the light, if this mode is supported. More...
 
LightCallset_color_brightness (optional< float > brightness)
 Set the color brightness of the light from 0.0 (no color) to 1.0 (fully on) More...
 
LightCallset_color_brightness (float brightness)
 Set the color brightness of the light from 0.0 (no color) to 1.0 (fully on) More...
 
LightCallset_color_brightness_if_supported (float brightness)
 Set the color brightness property if the light supports RGBW. More...
 
LightCallset_red (optional< float > red)
 Set the red RGB value of the light from 0.0 to 1.0. More...
 
LightCallset_red (float red)
 Set the red RGB value of the light from 0.0 to 1.0. More...
 
LightCallset_red_if_supported (float red)
 Set the red property if the light supports RGB. More...
 
LightCallset_green (optional< float > green)
 Set the green RGB value of the light from 0.0 to 1.0. More...
 
LightCallset_green (float green)
 Set the green RGB value of the light from 0.0 to 1.0. More...
 
LightCallset_green_if_supported (float green)
 Set the green property if the light supports RGB. More...
 
LightCallset_blue (optional< float > blue)
 Set the blue RGB value of the light from 0.0 to 1.0. More...
 
LightCallset_blue (float blue)
 Set the blue RGB value of the light from 0.0 to 1.0. More...
 
LightCallset_blue_if_supported (float blue)
 Set the blue property if the light supports RGB. More...
 
LightCallset_white (optional< float > white)
 Set the white value value of the light from 0.0 to 1.0 for RGBW[W] lights. More...
 
LightCallset_white (float white)
 Set the white value value of the light from 0.0 to 1.0 for RGBW[W] lights. More...
 
LightCallset_white_if_supported (float white)
 Set the white property if the light supports RGB. More...
 
LightCallset_color_temperature (optional< float > color_temperature)
 Set the color temperature of the light in mireds for CWWW or RGBWW lights. More...
 
LightCallset_color_temperature (float color_temperature)
 Set the color temperature of the light in mireds for CWWW or RGBWW lights. More...
 
LightCallset_color_temperature_if_supported (float color_temperature)
 Set the color_temperature property if the light supports color temperature. More...
 
LightCallset_cold_white (optional< float > cold_white)
 Set the cold white value of the light from 0.0 to 1.0. More...
 
LightCallset_cold_white (float cold_white)
 Set the cold white value of the light from 0.0 to 1.0. More...
 
LightCallset_cold_white_if_supported (float cold_white)
 Set the cold white property if the light supports cold white output. More...
 
LightCallset_warm_white (optional< float > warm_white)
 Set the warm white value of the light from 0.0 to 1.0. More...
 
LightCallset_warm_white (float warm_white)
 Set the warm white value of the light from 0.0 to 1.0. More...
 
LightCallset_warm_white_if_supported (float warm_white)
 Set the warm white property if the light supports cold white output. More...
 
LightCallset_effect (optional< std::string > effect)
 Set the effect of the light by its name. More...
 
LightCallset_effect (const std::string &effect)
 Set the effect of the light by its name. More...
 
LightCallset_effect (uint32_t effect_number)
 Set the effect of the light by its internal index number (only for internal use). More...
 
LightCallset_effect (optional< uint32_t > effect_number)
 
LightCallset_publish (bool publish)
 Set whether this light call should trigger a publish state. More...
 
LightCallset_save (bool save)
 Set whether this light call should trigger a save state to recover them at startup.. More...
 
LightCallset_rgb (float red, float green, float blue)
 Set the RGB color of the light by RGB values. More...
 
LightCallset_rgbw (float red, float green, float blue, float white)
 Set the RGBW color of the light by RGB values. More...
 
LightCallfrom_light_color_values (const LightColorValues &values)
 
void perform ()
 

Protected Member Functions

ColorMode get_active_color_mode_ ()
 Get the currently targeted, or active if none set, color mode. More...
 
LightColorValues validate_ ()
 Validate all properties and return the target light color values. More...
 
ColorMode compute_color_mode_ ()
 
std::set< ColorModeget_suitable_color_modes_ ()
 Get potential color modes for this light call. More...
 
void transform_parameters_ ()
 Some color modes also can be set using non-native parameters, transform those calls. More...
 
bool has_transition_ ()
 
bool has_flash_ ()
 
bool has_effect_ ()
 

Protected Attributes

LightStateparent_
 
optional< bool > state_
 
optional< uint32_t > transition_length_
 
optional< uint32_t > flash_length_
 
optional< ColorModecolor_mode_
 
optional< float > brightness_
 
optional< float > color_brightness_
 
optional< float > red_
 
optional< float > green_
 
optional< float > blue_
 
optional< float > white_
 
optional< float > color_temperature_
 
optional< float > cold_white_
 
optional< float > warm_white_
 
optional< uint32_t > effect_
 
bool publish_ {true}
 
bool save_ {true}
 

Detailed Description

This class represents a requested change in a light state.

Definition at line 14 of file light_call.h.

Constructor & Destructor Documentation

◆ LightCall()

esphome::light::LightCall::LightCall ( LightState parent)
inlineexplicit

Definition at line 16 of file light_call.h.

Member Function Documentation

◆ compute_color_mode_()

ColorMode esphome::light::LightCall::compute_color_mode_ ( )
protected

Definition at line 367 of file light_call.cpp.

◆ from_light_color_values()

LightCall & esphome::light::LightCall::from_light_color_values ( const LightColorValues values)

Definition at line 479 of file light_call.cpp.

◆ get_active_color_mode_()

ColorMode esphome::light::LightCall::get_active_color_mode_ ( )
protected

Get the currently targeted, or active if none set, color mode.

Definition at line 493 of file light_call.cpp.

◆ get_suitable_color_modes_()

std::set< ColorMode > esphome::light::LightCall::get_suitable_color_modes_ ( )
protected

Get potential color modes for this light call.

Definition at line 413 of file light_call.cpp.

◆ has_effect_()

bool esphome::light::LightCall::has_effect_ ( )
inlineprotected

Definition at line 175 of file light_call.h.

◆ has_flash_()

bool esphome::light::LightCall::has_flash_ ( )
inlineprotected

Definition at line 174 of file light_call.h.

◆ has_transition_()

bool esphome::light::LightCall::has_transition_ ( )
inlineprotected

Definition at line 173 of file light_call.h.

◆ perform()

void esphome::light::LightCall::perform ( )

Definition at line 30 of file light_call.cpp.

◆ set_blue() [1/2]

LightCall & esphome::light::LightCall::set_blue ( optional< float >  blue)

Set the blue RGB value of the light from 0.0 to 1.0.

Note that this only controls the color of the light, not its brightness.

Definition at line 616 of file light_call.cpp.

◆ set_blue() [2/2]

LightCall & esphome::light::LightCall::set_blue ( float  blue)

Set the blue RGB value of the light from 0.0 to 1.0.

Note that this only controls the color of the light, not its brightness.

Definition at line 620 of file light_call.cpp.

◆ set_blue_if_supported()

LightCall & esphome::light::LightCall::set_blue_if_supported ( float  blue)

Set the blue property if the light supports RGB.

Definition at line 526 of file light_call.cpp.

◆ set_brightness() [1/2]

LightCall & esphome::light::LightCall::set_brightness ( optional< float >  brightness)

Set the target brightness of the light from 0.0 (fully off) to 1.0 (fully on)

Definition at line 576 of file light_call.cpp.

◆ set_brightness() [2/2]

LightCall & esphome::light::LightCall::set_brightness ( float  brightness)

Set the target brightness of the light from 0.0 (fully off) to 1.0 (fully on)

Definition at line 580 of file light_call.cpp.

◆ set_brightness_if_supported()

LightCall & esphome::light::LightCall::set_brightness_if_supported ( float  brightness)

Set the brightness property if the light supports brightness.

Definition at line 501 of file light_call.cpp.

◆ set_cold_white() [1/2]

LightCall & esphome::light::LightCall::set_cold_white ( optional< float >  cold_white)

Set the cold white value of the light from 0.0 to 1.0.

Definition at line 640 of file light_call.cpp.

◆ set_cold_white() [2/2]

LightCall & esphome::light::LightCall::set_cold_white ( float  cold_white)

Set the cold white value of the light from 0.0 to 1.0.

Definition at line 644 of file light_call.cpp.

◆ set_cold_white_if_supported()

LightCall & esphome::light::LightCall::set_cold_white_if_supported ( float  cold_white)

Set the cold white property if the light supports cold white output.

Definition at line 542 of file light_call.cpp.

◆ set_color_brightness() [1/2]

LightCall & esphome::light::LightCall::set_color_brightness ( optional< float >  brightness)

Set the color brightness of the light from 0.0 (no color) to 1.0 (fully on)

Definition at line 592 of file light_call.cpp.

◆ set_color_brightness() [2/2]

LightCall & esphome::light::LightCall::set_color_brightness ( float  brightness)

Set the color brightness of the light from 0.0 (no color) to 1.0 (fully on)

Definition at line 596 of file light_call.cpp.

◆ set_color_brightness_if_supported()

LightCall & esphome::light::LightCall::set_color_brightness_if_supported ( float  brightness)

Set the color brightness property if the light supports RGBW.

Definition at line 511 of file light_call.cpp.

◆ set_color_mode() [1/2]

LightCall & esphome::light::LightCall::set_color_mode ( optional< ColorMode color_mode)

Set the color mode of the light.

Definition at line 584 of file light_call.cpp.

◆ set_color_mode() [2/2]

LightCall & esphome::light::LightCall::set_color_mode ( ColorMode  color_mode)

Set the color mode of the light.

Definition at line 588 of file light_call.cpp.

◆ set_color_mode_if_supported()

LightCall & esphome::light::LightCall::set_color_mode_if_supported ( ColorMode  color_mode)

Set the color mode of the light, if this mode is supported.

Definition at line 506 of file light_call.cpp.

◆ set_color_temperature() [1/2]

LightCall & esphome::light::LightCall::set_color_temperature ( optional< float >  color_temperature)

Set the color temperature of the light in mireds for CWWW or RGBWW lights.

Definition at line 632 of file light_call.cpp.

◆ set_color_temperature() [2/2]

LightCall & esphome::light::LightCall::set_color_temperature ( float  color_temperature)

Set the color temperature of the light in mireds for CWWW or RGBWW lights.

Definition at line 636 of file light_call.cpp.

◆ set_color_temperature_if_supported()

LightCall & esphome::light::LightCall::set_color_temperature_if_supported ( float  color_temperature)

Set the color_temperature property if the light supports color temperature.

Definition at line 536 of file light_call.cpp.

◆ set_effect() [1/4]

LightCall & esphome::light::LightCall::set_effect ( optional< std::string >  effect)

Set the effect of the light by its name.

Definition at line 656 of file light_call.cpp.

◆ set_effect() [2/4]

LightCall & esphome::light::LightCall::set_effect ( const std::string &  effect)

Set the effect of the light by its name.

Definition at line 458 of file light_call.cpp.

◆ set_effect() [3/4]

LightCall & esphome::light::LightCall::set_effect ( uint32_t  effect_number)

Set the effect of the light by its internal index number (only for internal use).

Definition at line 661 of file light_call.cpp.

◆ set_effect() [4/4]

LightCall & esphome::light::LightCall::set_effect ( optional< uint32_t >  effect_number)

Definition at line 665 of file light_call.cpp.

◆ set_flash_length() [1/2]

LightCall & esphome::light::LightCall::set_flash_length ( optional< uint32_t >  flash_length)

Start and set the flash length of this call in milliseconds.

Definition at line 568 of file light_call.cpp.

◆ set_flash_length() [2/2]

LightCall & esphome::light::LightCall::set_flash_length ( uint32_t  flash_length)

Start and set the flash length of this call in milliseconds.

Definition at line 572 of file light_call.cpp.

◆ set_green() [1/2]

LightCall & esphome::light::LightCall::set_green ( optional< float >  green)

Set the green RGB value of the light from 0.0 to 1.0.

Note that this only controls the color of the light, not its brightness.

Definition at line 608 of file light_call.cpp.

◆ set_green() [2/2]

LightCall & esphome::light::LightCall::set_green ( float  green)

Set the green RGB value of the light from 0.0 to 1.0.

Note that this only controls the color of the light, not its brightness.

Definition at line 612 of file light_call.cpp.

◆ set_green_if_supported()

LightCall & esphome::light::LightCall::set_green_if_supported ( float  green)

Set the green property if the light supports RGB.

Definition at line 521 of file light_call.cpp.

◆ set_publish()

LightCall & esphome::light::LightCall::set_publish ( bool  publish)

Set whether this light call should trigger a publish state.

Definition at line 669 of file light_call.cpp.

◆ set_red() [1/2]

LightCall & esphome::light::LightCall::set_red ( optional< float >  red)

Set the red RGB value of the light from 0.0 to 1.0.

Note that this only controls the color of the light, not its brightness.

Definition at line 600 of file light_call.cpp.

◆ set_red() [2/2]

LightCall & esphome::light::LightCall::set_red ( float  red)

Set the red RGB value of the light from 0.0 to 1.0.

Note that this only controls the color of the light, not its brightness.

Definition at line 604 of file light_call.cpp.

◆ set_red_if_supported()

LightCall & esphome::light::LightCall::set_red_if_supported ( float  red)

Set the red property if the light supports RGB.

Definition at line 516 of file light_call.cpp.

◆ set_rgb()

LightCall & esphome::light::LightCall::set_rgb ( float  red,
float  green,
float  blue 
)

Set the RGB color of the light by RGB values.

Please note that this only changes the color of the light, not the brightness.

Parameters
redThe red color value from 0.0 to 1.0.
greenThe green color value from 0.0 to 1.0.
blueThe blue color value from 0.0 to 1.0.
Returns
The light call for chaining setters.

Definition at line 677 of file light_call.cpp.

◆ set_rgbw()

LightCall & esphome::light::LightCall::set_rgbw ( float  red,
float  green,
float  blue,
float  white 
)

Set the RGBW color of the light by RGB values.

Please note that this only changes the color of the light, not the brightness.

Parameters
redThe red color value from 0.0 to 1.0.
greenThe green color value from 0.0 to 1.0.
blueThe blue color value from 0.0 to 1.0.
whiteThe white color value from 0.0 to 1.0.
Returns
The light call for chaining setters.

Definition at line 683 of file light_call.cpp.

◆ set_save()

LightCall & esphome::light::LightCall::set_save ( bool  save)

Set whether this light call should trigger a save state to recover them at startup..

Definition at line 673 of file light_call.cpp.

◆ set_state() [1/2]

LightCall & esphome::light::LightCall::set_state ( optional< bool >  state)

Set the binary ON/OFF state of the light.

Definition at line 552 of file light_call.cpp.

◆ set_state() [2/2]

LightCall & esphome::light::LightCall::set_state ( bool  state)

Set the binary ON/OFF state of the light.

Definition at line 556 of file light_call.cpp.

◆ set_transition_length() [1/2]

LightCall & esphome::light::LightCall::set_transition_length ( optional< uint32_t >  transition_length)

Set the transition length of this call in milliseconds.

This argument is ignored for starting flashes and effects.

Defaults to the default transition length defined in the light configuration.

Definition at line 560 of file light_call.cpp.

◆ set_transition_length() [2/2]

LightCall & esphome::light::LightCall::set_transition_length ( uint32_t  transition_length)

Set the transition length of this call in milliseconds.

This argument is ignored for starting flashes and effects.

Defaults to the default transition length defined in the light configuration.

Definition at line 564 of file light_call.cpp.

◆ set_transition_length_if_supported()

LightCall & esphome::light::LightCall::set_transition_length_if_supported ( uint32_t  transition_length)

Set the transition length property if the light supports transitions.

Definition at line 496 of file light_call.cpp.

◆ set_warm_white() [1/2]

LightCall & esphome::light::LightCall::set_warm_white ( optional< float >  warm_white)

Set the warm white value of the light from 0.0 to 1.0.

Definition at line 648 of file light_call.cpp.

◆ set_warm_white() [2/2]

LightCall & esphome::light::LightCall::set_warm_white ( float  warm_white)

Set the warm white value of the light from 0.0 to 1.0.

Definition at line 652 of file light_call.cpp.

◆ set_warm_white_if_supported()

LightCall & esphome::light::LightCall::set_warm_white_if_supported ( float  warm_white)

Set the warm white property if the light supports cold white output.

Definition at line 547 of file light_call.cpp.

◆ set_white() [1/2]

LightCall & esphome::light::LightCall::set_white ( optional< float >  white)

Set the white value value of the light from 0.0 to 1.0 for RGBW[W] lights.

Definition at line 624 of file light_call.cpp.

◆ set_white() [2/2]

LightCall & esphome::light::LightCall::set_white ( float  white)

Set the white value value of the light from 0.0 to 1.0 for RGBW[W] lights.

Definition at line 628 of file light_call.cpp.

◆ set_white_if_supported()

LightCall & esphome::light::LightCall::set_white_if_supported ( float  white)

Set the white property if the light supports RGB.

Definition at line 531 of file light_call.cpp.

◆ transform_parameters_()

void esphome::light::LightCall::transform_parameters_ ( )
protected

Some color modes also can be set using non-native parameters, transform those calls.

Definition at line 336 of file light_call.cpp.

◆ validate_()

LightColorValues esphome::light::LightCall::validate_ ( )
protected

Validate all properties and return the target light color values.

Definition at line 132 of file light_call.cpp.

Field Documentation

◆ blue_

optional<float> esphome::light::LightCall::blue_
protected

Definition at line 186 of file light_call.h.

◆ brightness_

optional<float> esphome::light::LightCall::brightness_
protected

Definition at line 182 of file light_call.h.

◆ cold_white_

optional<float> esphome::light::LightCall::cold_white_
protected

Definition at line 189 of file light_call.h.

◆ color_brightness_

optional<float> esphome::light::LightCall::color_brightness_
protected

Definition at line 183 of file light_call.h.

◆ color_mode_

optional<ColorMode> esphome::light::LightCall::color_mode_
protected

Definition at line 181 of file light_call.h.

◆ color_temperature_

optional<float> esphome::light::LightCall::color_temperature_
protected

Definition at line 188 of file light_call.h.

◆ effect_

optional<uint32_t> esphome::light::LightCall::effect_
protected

Definition at line 191 of file light_call.h.

◆ flash_length_

optional<uint32_t> esphome::light::LightCall::flash_length_
protected

Definition at line 180 of file light_call.h.

◆ green_

optional<float> esphome::light::LightCall::green_
protected

Definition at line 185 of file light_call.h.

◆ parent_

LightState* esphome::light::LightCall::parent_
protected

Definition at line 177 of file light_call.h.

◆ publish_

bool esphome::light::LightCall::publish_ {true}
protected

Definition at line 192 of file light_call.h.

◆ red_

optional<float> esphome::light::LightCall::red_
protected

Definition at line 184 of file light_call.h.

◆ save_

bool esphome::light::LightCall::save_ {true}
protected

Definition at line 193 of file light_call.h.

◆ state_

optional<bool> esphome::light::LightCall::state_
protected

Definition at line 178 of file light_call.h.

◆ transition_length_

optional<uint32_t> esphome::light::LightCall::transition_length_
protected

Definition at line 179 of file light_call.h.

◆ warm_white_

optional<float> esphome::light::LightCall::warm_white_
protected

Definition at line 190 of file light_call.h.

◆ white_

optional<float> esphome::light::LightCall::white_
protected

Definition at line 187 of file light_call.h.


The documentation for this class was generated from the following files: