hueplusplus
1.0.0
|
Class for Hue Light fixtures. More...
#include <hueplusplus/Light.h>
Public Member Functions | |
General information | |
virtual std::string | getLuminaireUId () const |
Const function that returns the luminaireuniqueid of the light. More... | |
virtual ColorType | getColorType () const |
Const function that returns the color type of the light. More... | |
ColorGamut | getColorGamut () const |
Get gamut space of possible light colors. More... | |
Light state | |
virtual bool | on (uint8_t transition=4) |
Function that turns the light on. More... | |
virtual bool | off (uint8_t transition=4) |
Function that turns the light off. More... | |
virtual bool | isOn () |
Function to check whether a light is on or off. More... | |
virtual bool | isOn () const |
Const function to check whether a light is on or off. More... | |
virtual bool | hasBrightnessControl () const |
Const function to check whether this light has brightness control. More... | |
virtual bool | hasTemperatureControl () const |
Const function to check whether this light has color temperature control. More... | |
virtual bool | hasColorControl () const |
Connst function to check whether this light has full color control. More... | |
virtual bool | setBrightness (unsigned int bri, uint8_t transition=4) |
Function that sets the brightness of this light. More... | |
virtual unsigned int | getBrightness () const |
Const function that returns the brightness of this light. More... | |
virtual unsigned int | getBrightness () |
Function that returns the brightness of this light. More... | |
virtual bool | setColorTemperature (unsigned int mired, uint8_t transition=4) |
Function that sets the color temperature of this light in mired. More... | |
virtual unsigned int | getColorTemperature () const |
Const function that returns the current color temperature of the light. More... | |
virtual unsigned int | getColorTemperature () |
Function that returns the current color temperature of the light. More... | |
virtual bool | setColorHue (uint16_t hue, uint8_t transition=4) |
Function to set the color of this light with specified hue. More... | |
virtual bool | setColorSaturation (uint8_t sat, uint8_t transition=4) |
Function to set the color of this light with specified saturation. More... | |
virtual bool | setColorHueSaturation (const HueSaturation &hueSat, uint8_t transition=4) |
Function to set the color of this light with specified hue and saturation. More... | |
virtual HueSaturation | getColorHueSaturation () const |
Const function that returns the current color of the light as hue and saturation. More... | |
virtual HueSaturation | getColorHueSaturation () |
Function that returns the current color of the light as hue and saturation. More... | |
virtual bool | setColorXY (const XYBrightness &xy, uint8_t transition=4) |
Function to set the color of this light in CIE with specified x y. More... | |
virtual XYBrightness | getColorXY () const |
Const function that returns the current color of the light as xy. More... | |
virtual XYBrightness | getColorXY () |
Function that returns the current color of the light as xy. More... | |
virtual bool | setColorRGB (const RGB &rgb, uint8_t transition=4) |
Function to set the color of this light with red green and blue values. More... | |
virtual bool | alert () |
Function that lets the light perform one breath cycle. More... | |
virtual bool | alertTemperature (unsigned int mired) |
Function that lets the light perform one breath cycle in specified color temperature. More... | |
virtual bool | alertHueSaturation (const HueSaturation &hueSat) |
Function that lets the light perform one breath cycle in specified color. More... | |
virtual bool | alertXY (const XYBrightness &xy) |
Function that lets the light perform one breath cycle in specified color. More... | |
virtual bool | setColorLoop (bool on) |
Function to turn colorloop effect on/off. More... | |
virtual StateTransaction | transaction () |
Create a transaction for this light. More... | |
Public Member Functions inherited from hueplusplus::BaseDevice | |
virtual | ~BaseDevice ()=default |
Virtual destructor. More... | |
virtual int | getId () const |
Const function that returns the id of this device. More... | |
virtual std::string | getType () const |
Const function that returns the device type. More... | |
virtual std::string | getName () |
Function that returns the name of the device. More... | |
virtual std::string | getName () const |
Const function that returns the name of the device. More... | |
virtual std::string | getModelId () const |
Const function that returns the modelid of the device. More... | |
virtual std::string | getUId () const |
Const function that returns the uniqueid of the device. More... | |
virtual std::string | getManufacturername () const |
Const function that returns the manufacturername of the device. More... | |
virtual std::string | getProductname () const |
Const function that returns the productname of the device. More... | |
virtual std::string | getSwVersion () |
Function that returns the software version of the device. More... | |
virtual std::string | getSwVersion () const |
Const function that returns the software version of the device. More... | |
virtual bool | setName (const std::string &name) |
Function that sets the name of the device. More... | |
virtual void | refresh (bool force=false) |
Refreshes internal cached state. More... | |
virtual void | setRefreshDuration (std::chrono::steady_clock::duration refreshDuration) |
Sets custom refresh interval for this device. More... | |
Protected Member Functions | |
Light (int id, const HueCommandAPI &commands) | |
Protected ctor that is used by LightFactory. More... | |
Light (int id, const std::shared_ptr< APICache > &baseCache) | |
Protected ctor that is used by LightFactory. More... | |
Light (int id, const HueCommandAPI &commands, std::shared_ptr< const BrightnessStrategy > brightnessStrategy, std::shared_ptr< const ColorTemperatureStrategy > colorTempStrategy, std::shared_ptr< const ColorHueStrategy > colorHueStrategy, std::chrono::steady_clock::duration refreshDuration, const nlohmann::json ¤tState) | |
Protected ctor that is used by LightFactory, also sets strategies. More... | |
virtual void | setBrightnessStrategy (std::shared_ptr< const BrightnessStrategy > strat) |
Protected function that sets the brightness strategy. More... | |
virtual void | setColorTemperatureStrategy (std::shared_ptr< const ColorTemperatureStrategy > strat) |
Protected function that sets the colorTemperature strategy. More... | |
virtual void | setColorHueStrategy (std::shared_ptr< const ColorHueStrategy > strat) |
Protected function that sets the colorHue strategy. More... | |
Protected Member Functions inherited from hueplusplus::BaseDevice | |
BaseDevice (int id, const std::shared_ptr< APICache > &baseCache) | |
Protected ctor that is used by subclasses, construct with shared cache. More... | |
BaseDevice (int id, const HueCommandAPI &commands, const std::string &path, std::chrono::steady_clock::duration refreshDuration, const nlohmann::json ¤tState) | |
Protected ctor that is used by subclasses. More... | |
virtual nlohmann::json | sendPutRequest (const std::string &subPath, const nlohmann::json &request, FileInfo fileInfo) |
Utility function to send a put request to the device. More... | |
Protected Attributes | |
ColorType | colorType |
holds the ColorType of the light More... | |
std::shared_ptr< const BrightnessStrategy > | brightnessStrategy |
holds a reference to the strategy that handles brightness commands More... | |
std::shared_ptr< const ColorTemperatureStrategy > | colorTemperatureStrategy |
holds a reference to the strategy that handles colortemperature commands More... | |
std::shared_ptr< const ColorHueStrategy > | colorHueStrategy |
holds a reference to the strategy that handles all color commands More... | |
Protected Attributes inherited from hueplusplus::BaseDevice | |
int | id |
holds the id of the device More... | |
APICache | state |
holds the current state of the device More... | |
Friends | |
class | LightFactory |
class | SimpleBrightnessStrategy |
class | SimpleColorHueStrategy |
class | ExtendedColorHueStrategy |
class | SimpleColorTemperatureStrategy |
class | ExtendedColorTemperatureStrategy |
Class for Hue Light fixtures.
Provides methods to query and control lights.
|
protected |
Protected ctor that is used by LightFactory.
id | Integer that specifies the id of this light |
commands | HueCommandAPI for communication with the bridge |
leaves strategies unset
|
protected |
Protected ctor that is used by LightFactory.
id | Integer that specifies the id of this light |
baseCache | Cache of the light list (must not be null). |
leaves strategies unset
|
protected |
Protected ctor that is used by LightFactory, also sets strategies.
id | Integer that specifies the id of this light |
commands | HueCommandAPI for communication with the bridge |
brightnessStrategy | Strategy for brightness. May be nullptr. |
colorTempStrategy | Strategy for color temperature. May be nullptr. |
colorHueStrategy | Strategy for color hue/saturation. May be nullptr. |
refreshDuration | Time between refreshing the cached state. Can be 0 to always refresh, or steady_clock::duration::max() to never refresh. |
currentState | The current light state, may be null. |
std::system_error | when system or socket operations fail |
HueException | when response contained no body |
HueAPIResponseException | when response contains an error |
nlohmann::json::parse_error | when response could not be parsed |
|
virtual |
Function that lets the light perform one breath cycle.
Can be used for locating a light.
std::system_error | when system or socket operations fail |
HueException | when response contained no body |
HueAPIResponseException | when response contains an error |
nlohmann::json::parse_error | when response could not be parsed |
|
inlinevirtual |
Function that lets the light perform one breath cycle in specified color.
hueSat | Color in hue and saturation |
std::system_error | when system or socket operations fail |
HueException | when response contained no body |
HueAPIResponseException | when response contains an error |
nlohmann::json::parse_error | when response could not be parsed |
|
inlinevirtual |
Function that lets the light perform one breath cycle in specified color temperature.
mired | Color temperature in mired |
std::system_error | when system or socket operations fail |
HueException | when response contained no body |
HueAPIResponseException | when response contains an error |
nlohmann::json::parse_error | when response could not be parsed |
|
inlinevirtual |
Function that lets the light perform one breath cycle in specified color.
xy | The x,y coordinates in CIE and brightness |
std::system_error | when system or socket operations fail |
HueException | when response contained no body |
HueAPIResponseException | when response contains an error |
nlohmann::json::parse_error | when response could not be parsed |
|
inlinevirtual |
Const function that returns the brightness of this light.
|
inlinevirtual |
Function that returns the brightness of this light.
std::system_error | when system or socket operations fail |
HueException | when response contained no body |
HueAPIResponseException | when response contains an error |
nlohmann::json::parse_error | when response could not be parsed |
ColorGamut hueplusplus::Light::getColorGamut | ( | ) | const |
Get gamut space of possible light colors.
|
inlinevirtual |
Const function that returns the current color of the light as hue and saturation.
std::system_error | when system or socket operations fail |
HueException | when response contained no body |
HueAPIResponseException | when response contains an error |
nlohmann::json::parse_error | when response could not be parsed |
|
inlinevirtual |
Function that returns the current color of the light as hue and saturation.
std::system_error | when system or socket operations fail |
HueException | when response contained no body |
HueAPIResponseException | when response contains an error |
nlohmann::json::parse_error | when response could not be parsed |
|
inlinevirtual |
Const function that returns the current color temperature of the light.
|
inlinevirtual |
Function that returns the current color temperature of the light.
std::system_error | when system or socket operations fail |
HueException | when response contained no body |
HueAPIResponseException | when response contains an error |
nlohmann::json::parse_error | when response could not be parsed |
|
virtual |
Const function that returns the color type of the light.
|
inlinevirtual |
Const function that returns the current color of the light as xy.
|
inlinevirtual |
Function that returns the current color of the light as xy.
std::system_error | when system or socket operations fail |
HueException | when response contained no body |
HueAPIResponseException | when response contains an error |
nlohmann::json::parse_error | when response could not be parsed |
|
virtual |
Const function that returns the luminaireuniqueid of the light.
|
inlinevirtual |
Const function to check whether this light has brightness control.
|
inlinevirtual |
Connst function to check whether this light has full color control.
|
inlinevirtual |
Const function to check whether this light has color temperature control.
|
virtual |
Function to check whether a light is on or off.
std::system_error | when system or socket operations fail |
HueException | when response contained no body |
HueAPIResponseException | when response contains an error |
nlohmann::json::parse_error | when response could not be parsed |
|
virtual |
Const function to check whether a light is on or off.
|
virtual |
Function that turns the light off.
transition | Optional parameter to set the transition from current state to new, standard is 4 = 400ms |
std::system_error | when system or socket operations fail |
HueException | when response contained no body |
HueAPIResponseException | when response contains an error |
nlohmann::json::parse_error | when response could not be parsed |
|
virtual |
Function that turns the light on.
transition | Optional parameter to set the transition from current state to new, standard is 4 = 400ms |
std::system_error | when system or socket operations fail |
HueException | when response contained no body |
HueAPIResponseException | when response contains an error |
nlohmann::json::parse_error | when response could not be parsed |
|
inlinevirtual |
Function that sets the brightness of this light.
bri | Unsigned int that specifies the brightness |
transition | Optional parameter to set the transition from current state to new, standard is 4 = 400ms |
std::system_error | when system or socket operations fail |
HueException | when response contained no body |
HueAPIResponseException | when response contains an error |
nlohmann::json::parse_error | when response could not be parsed |
|
inlineprotectedvirtual |
Protected function that sets the brightness strategy.
The strategy defines how specific commands that deal with brightness control are executed
strat | a strategy of type BrightnessStrategy |
|
inlinevirtual |
Function to set the color of this light with specified hue.
hue | uint16_t that specifies the hue |
transition | Optional parameter to set the transition from current state to new, standard is 4 = 400ms |
std::system_error | when system or socket operations fail |
HueException | when response contained no body |
HueAPIResponseException | when response contains an error |
nlohmann::json::parse_error | when response could not be parsed |
|
inlinevirtual |
Function to set the color of this light with specified hue and saturation.
hueSat | Color in hue and satuation. |
transition | Optional parameter to set the transition from current state to new, standard is 4 = 400ms. |
std::system_error | when system or socket operations fail |
HueException | when response contained no body |
HueAPIResponseException | when response contains an error |
nlohmann::json::parse_error | when response could not be parsed |
|
inlineprotectedvirtual |
Protected function that sets the colorHue strategy.
The strategy defines how specific commands that deal with color control are executed
strat | a strategy of type ColorHueStrategy |
|
inlinevirtual |
Function to turn colorloop effect on/off.
Notice this function will only be performed light has a reference to a specific ColorHueStrategy. The colorloop effect will loop through all colors on current hue and saturation levels. Notice that none of the setter functions check whether this feature is enabled and the colorloop can only be disabled with this function or by simply calling off() and then on(), so you could alternatively call off() and then use any of the setter functions.
on | bool that enables this feature when true and disables it when false |
std::system_error | when system or socket operations fail |
HueException | when response contained no body |
HueAPIResponseException | when response contains an error |
nlohmann::json::parse_error | when response could not be parsed |
|
inlinevirtual |
Function to set the color of this light with red green and blue values.
rgb | RGB color that will be mapped to the available color space |
transition | Optional parameter to set the transition from current state to new, standard is 4 = 400ms |
std::system_error | when system or socket operations fail |
HueException | when response contained no body |
HueAPIResponseException | when response contains an error |
nlohmann::json::parse_error | when response could not be parsed |
|
inlinevirtual |
Function to set the color of this light with specified saturation.
sat | uint8_t that specifies the saturation |
transition | Optional parameter to set the transition from current state to new, standard is 4 = 400ms |
std::system_error | when system or socket operations fail |
HueException | when response contained no body |
HueAPIResponseException | when response contains an error |
nlohmann::json::parse_error | when response could not be parsed |
|
inlinevirtual |
Function that sets the color temperature of this light in mired.
mired | Unsigned int that specifies the color temperature in Mired |
transition | Optional parameter to set the transition from current state to new, standard is 4 = 400ms |
std::system_error | when system or socket operations fail |
HueException | when response contained no body |
HueAPIResponseException | when response contains an error |
nlohmann::json::parse_error | when response could not be parsed |
|
inlineprotectedvirtual |
Protected function that sets the colorTemperature strategy.
The strategy defines how specific commands that deal with colortemperature control are executed
strat | a strategy of type ColorTemperatureStrategy |
|
inlinevirtual |
Function to set the color of this light in CIE with specified x y.
xy | The color in XY and brightness |
transition | Optional parameter to set the transition from current state to new, standard is 4 = 400ms |
std::system_error | when system or socket operations fail |
HueException | when response contained no body |
HueAPIResponseException | when response contains an error |
nlohmann::json::parse_error | when response could not be parsed |
|
virtual |
Create a transaction for this light.
The transaction can be used to change more than one value in one request. Only use the functions supported by the current light type.
Example usage:
|
friend |
|
friend |
|
friend |
|
friend |
|
friend |
|
friend |
|
protected |
holds a reference to the strategy that handles brightness commands
|
protected |
holds a reference to the strategy that handles all color commands
|
protected |
holds a reference to the strategy that handles colortemperature commands