FauxmoESP v2.0.0
Loading...
Searching...
No Matches
LightState Struct Reference

Detailed Description

This class represents the state of a light.

Definition at line 16 of file LightState.h.

#include <LightState.h>

Public Member Functions

 LightState ()
 Creates a new light state with default values.
 
 LightState (bool state, uint8_t brightness=254, uint16_t hue=41462, uint8_t saturation=77, const XYPoint &xy=XYPoint(), uint16_t colorTemperature=155, AlertEffect alertEffect=ALERT_EFFECT_NONE, LightEffect dynamicLightEffect=LIGHT_EFFECT_NONE, ColorMode colorMode=COLOR_MODE_CT, bool isLightReachable=true)
 Creates a new light state with the given values.
 
String toJson () const
 Returns the current state of the light as a JSON string.
 
String getColorModeString () const
 Return the current color mode as a string.
 
String getDynamicLightEffectString () const
 Return the current dynamic light effect as a string.
 
String getAlertEffectString () const
 Return the current alert effect as a string.
 
bool operator== (const LightState &other) const
 
bool operator!= (const LightState &other) const
 

Public Attributes

bool isOn
 On/Off state of the light.
 
uint8_t brightness
 Brightness of the light.
 
uint16_t hue
 Hue of the light.
 
uint8_t saturation
 Saturation of the light.
 
XYPoint xy
 The x and y coordinates of a color in CIE color space.
 
uint16_t colorTemperature
 The Mired Color temperature of the light.
 
AlertEffect alertEffect
 The alert effect, which is a temporary change to the bulb's state.
 
LightEffect dynamicLightEffect
 The dynamic effect of the light, can either be "none" or "colorloop".
 
ColorMode colorMode
 Indicates the color mode in which the light is working, this is the last command type it received.
 
bool isLightReachable
 Indicates if a light can be reached by the bridge.
 
String mode = "homeautomation"
 

Constructor & Destructor Documentation

◆ LightState() [1/2]

LightState::LightState ( )

Creates a new light state with default values.

Note
Default sets isLightReachable to false. This means no functions will be able to change the state of the light until isLightReachable is set to true.

Definition at line 10 of file LightState.cpp.

◆ LightState() [2/2]

LightState::LightState ( bool  state,
uint8_t  brightness = 254,
uint16_t  hue = 41462,
uint8_t  saturation = 77,
const XYPoint xy = XYPoint(),
uint16_t  colorTemperature = 155,
AlertEffect  alertEffect = ALERT_EFFECT_NONE,
LightEffect  dynamicLightEffect = LIGHT_EFFECT_NONE,
ColorMode  colorMode = COLOR_MODE_CT,
bool  isLightReachable = true 
)
explicit

Creates a new light state with the given values.

Parameters
stateThe on/off state of the light.
brightnessThe current brightness of the light.
hueThe current hue of the light.
saturationThe current saturation of the light.
xyThe current xy color of the light.
colorTemperatureThe current color temperature of the light.
alertEffectThe current alert effect of the light.
dynamicLightEffectThe current dynamic light effect of the light.
colorModeThe current color mode of the light.
isLightReachableThe current reachability of the light.

Definition at line 15 of file LightState.cpp.

Member Function Documentation

◆ getAlertEffectString()

String LightState::getAlertEffectString ( ) const

Return the current alert effect as a string.

Returns
The current alert effect as a string.

Definition at line 72 of file LightState.cpp.

◆ getColorModeString()

String LightState::getColorModeString ( ) const

Return the current color mode as a string.

Returns
The current color mode as a string.

Definition at line 62 of file LightState.cpp.

◆ getDynamicLightEffectString()

String LightState::getDynamicLightEffectString ( ) const

Return the current dynamic light effect as a string.

Returns
The current dynamic light effect as a string.

Definition at line 67 of file LightState.cpp.

◆ operator!=()

bool LightState::operator!= ( const LightState other) const

Definition at line 85 of file LightState.cpp.

◆ operator==()

bool LightState::operator== ( const LightState other) const

Definition at line 77 of file LightState.cpp.

◆ toJson()

String LightState::toJson ( ) const

Returns the current state of the light as a JSON string.

Definition at line 28 of file LightState.cpp.

Member Data Documentation

◆ alertEffect

AlertEffect LightState::alertEffect

The alert effect, which is a temporary change to the bulb's state.

This can take one of the following values: "none" – The light is not performing an alert effect. "select" – The light is performing one breathe cycle. "lselect" – The light is performing breathe cycles for 15 seconds or until an "alert": "none" command is received.

Note that this contains the last alert sent to the light and not its current state. i.e. After the breathe cycle has finished the bridge does not reset the alert to “none“.

json key: alert

Definition at line 111 of file LightState.h.

◆ brightness

uint8_t LightState::brightness

Brightness of the light.

This is a scale from the minimum brightness the light is capable of, 1, to the maximum capable brightness, 254.

json key: bri

Definition at line 59 of file LightState.h.

◆ colorMode

ColorMode LightState::colorMode

Indicates the color mode in which the light is working, this is the last command type it received.

Values are

  • "hs" for Hue and Saturation
  • "xy" for XY
  • "ct" for Color Temperature This parameter is only present when the light supports at least one of the values.

json key: colormode

Definition at line 132 of file LightState.h.

◆ colorTemperature

uint16_t LightState::colorTemperature

The Mired Color temperature of the light.

2012 connected lights are capable of 153 (6500K) to 500 (2000K).

json key: ct

Definition at line 98 of file LightState.h.

◆ dynamicLightEffect

LightEffect LightState::dynamicLightEffect

The dynamic effect of the light, can either be "none" or "colorloop".

If set to colorloop, the light will cycle through all hues using the current brightness and saturation settings.

json key: effect

Definition at line 119 of file LightState.h.

◆ hue

uint16_t LightState::hue

Hue of the light.

This is a wrapping value between 0 and 65535. Note, that hue/sat values are hardware dependent which means that programming two devices with the same value does not garantuee that they will be the same color. Programming 0 and 65535 would mean that the light will resemble the color red, 21845 for green and 43690 for blue.

json key: hue

Definition at line 71 of file LightState.h.

◆ isLightReachable

bool LightState::isLightReachable

Indicates if a light can be reached by the bridge.

json key: reachable

Definition at line 139 of file LightState.h.

◆ isOn

bool LightState::isOn

On/Off state of the light.

On=true, Off=false

json key: on

Definition at line 50 of file LightState.h.

◆ mode

String LightState::mode = "homeautomation"

Definition at line 141 of file LightState.h.

◆ saturation

uint8_t LightState::saturation

Saturation of the light.

254 is the most saturated (colored) and 0 is the least saturated (white).

json key: sat

Definition at line 79 of file LightState.h.

◆ xy

XYPoint LightState::xy

The x and y coordinates of a color in CIE color space.

The first entry is the x coordinate and the second entry is the y coordinate. Both x and y are between 0 and 1. Using CIE xy, the colors can be the same on all lamps if the coordinates are within every lamps gamuts (example: “xy”:[0.409,0.5179] is the same color on all lamps). If not, the lamp will calculate it’s closest color and use that. The CIE xy color is absolute, independent from the hardware.

json key: xy

Definition at line 90 of file LightState.h.


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