Loading...
Searching...
No Matches
hueplusplus::Scene Class Reference

Scene stored in the bridge. More...

`#include <hueplusplus/Scene.h>`

## Public Types

enum class | Type { lightScene , groupScene }
| Type of the scen. More...

## Public Member Functions

| Scene (const std::string &id, const std::shared_ptr< APICache > &baseCache)
| Creates scene with shared cache.
| Scene (const std::string &id, const HueCommandAPI &commands, std::chrono::steady_clock::duration refreshDuration, const nlohmann::json &currentState)
| Construct existing Scene.
void | refresh (bool force=false)
| Refreshes internal cached state.
void | setRefreshDuration (std::chrono::steady_clock::duration refreshDuration)
| Sets custom refresh interval for this group.
std::string | getId () const
| Get scene identifier.
std::string | getName () const
| Get scene name.
void | setName (const std::string &name)
| Set scene name.
Type | getType () const
| Get scene type.
int | getGroupId () const
| Get group id for a GroupScene.
std::vector< int > | getLightIds () const
| Get light ids.
void | setLightIds (const std::vector< int > &ids)
| Set light ids for LightScene.
std::string | getOwner () const
| Get user that created or last changed the scene.
bool | getRecycle () const
| Get whether the scene can be automatically deleted.
bool | isLocked () const
| Get whether scene is locked by a rule or schedule.
std::string | getAppdata () const
| Get app specific data.
int | getAppdataVersion () const
| Get version of app specific data.
void | setAppdata (const std::string &data, int version)
| Set app specific data.
std::string | getPicture () const
| Get picture, reserved for future use.
time::AbsoluteTime | getLastUpdated () const
| Get time the scene was created/updated.
int | getVersion () const
| Get version of the scene.
std::map< int, LightState > | getLightStates () const
| Get stored states of the lights.
void | setLightStates (const std::map< int, LightState > &states)
| Set light states.
void | storeCurrentLightState ()
| Store current light state of every light in the scene.
void | storeCurrentLightState (int transition)
| Store current light state and update transition time.
void | recall ()
| Recall scene, putting every light in the stored state.

## Detailed Description

Scene stored in the bridge.

Scenes bundle the state of multiple lights so it can be recalled later.

## Member Enumeration Documentation

## Type

enum class hueplusplus::Scene::Type

strong

Type of the scen.

Enumerator
lightScene | The scene affects specific lights.
groupScene | The scene affects all light of a specific group.

## Constructor & Destructor Documentation

## Scene() [1/2]

hueplusplus::Scene::Scene | ( | const std::string & | id,
|  | const std::shared_ptr< APICache > & | baseCache )

Creates scene with shared cache.

Parameters

  id | Scene id in the bridge
  baseCache | Cache of the scene list.

## Scene() [2/2]

hueplusplus::Scene::Scene | ( | const std::string & | id,
|  | const HueCommandAPI & | commands,
|  | std::chrono::steady_clock::duration | refreshDuration,
|  | const nlohmann::json & | currentState )

Construct existing Scene.

Parameters

  id | Scene id
  commands | HueCommandAPI for requests
  refreshDuration | Time between refreshing the cached state
  currentState | The current state, may be null.

## Member Function Documentation

## getAppdata()

std::string hueplusplus::Scene::getAppdata | ( |  | ) | const

Get app specific data.

## getAppdataVersion()

int hueplusplus::Scene::getAppdataVersion | ( |  | ) | const

Get version of app specific data.

## getGroupId()

int hueplusplus::Scene::getGroupId | ( |  | ) | const

Get group id for a GroupScene.

Returns
  Group id or 0 if the scene is a LightScene.

## getId()

std::string hueplusplus::Scene::getId | ( |  | ) | const

Get scene identifier.

## getLastUpdated()

time::AbsoluteTime hueplusplus::Scene::getLastUpdated | ( |  | ) | const

Get time the scene was created/updated.

## getLightIds()

std::vector< int > hueplusplus::Scene::getLightIds | ( |  | ) | const

Get light ids.

For a GroupScene, the light ids are the lights in the group.

## getLightStates()

std::map< int, LightState > hueplusplus::Scene::getLightStates | ( |  | ) | const

Get stored states of the lights.

Returns
  LightStates for each light in the scene, or an empty map for legacy scenes.

## getName()

std::string hueplusplus::Scene::getName | ( |  | ) | const

Get scene name.

The scene name is always unique for the bridge. It defaults to the id.

## getOwner()

std::string hueplusplus::Scene::getOwner | ( |  | ) | const

Get user that created or last changed the scene.

## getPicture()

std::string hueplusplus::Scene::getPicture | ( |  | ) | const

Get picture, reserved for future use.

Currently always an empty string.

## getRecycle()

bool hueplusplus::Scene::getRecycle | ( |  | ) | const

Get whether the scene can be automatically deleted.

## getType()

Scene::Type hueplusplus::Scene::getType | ( |  | ) | const

Get scene type.

GroupScenes are deleted when the group is deleted.

## getVersion()

int hueplusplus::Scene::getVersion | ( |  | ) | const

Get version of the scene.

Returns
  1 for legacy scene without lightstates
  2 for updated scenes with lightstates

## isLocked()

bool hueplusplus::Scene::isLocked | ( |  | ) | const

Get whether scene is locked by a rule or schedule.

## recall()

void hueplusplus::Scene::recall | ( |  | ) |

Recall scene, putting every light in the stored state.

Exceptions

  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

## refresh()

void hueplusplus::Scene::refresh | ( | bool | force = false | ) |

Refreshes internal cached state.

Parameters

  force | `true` forces a refresh, regardless of how long the last refresh was ago. `false` to only refresh when enough time has passed (needed e.g. when calling only const methods).

Exceptions

  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

## setAppdata()

void hueplusplus::Scene::setAppdata | ( | const std::string & | data,
|  | int | version )

Set app specific data.

Parameters

  data | Custom data in any format, max length 16.
  version | Version of the data

Exceptions

  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

## setLightIds()

void hueplusplus::Scene::setLightIds | ( | const std::vector< int > & | ids | ) |

Set light ids for LightScene.

Parameters

  ids | New light ids

Light ids cannot be changed on GroupScene. Change the lights in the group instead.

Exceptions

  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

## setLightStates()

void hueplusplus::Scene::setLightStates | ( | const std::map< int, LightState > & | states | ) |

Set light states.

Parameters

  states | New states for each light in the scene. Should contain exactly the lights in the scene. Additional states might cause an error.

Exceptions

  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

## setName()

void hueplusplus::Scene::setName | ( | const std::string & | name | ) |

Set scene name.

Parameters

  name | New name for the scene. Must be unique for all schedules, otherwise a number is added.

Exceptions

  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

## setRefreshDuration()

void hueplusplus::Scene::setRefreshDuration | ( | std::chrono::steady_clock::duration | refreshDuration | ) |

Sets custom refresh interval for this group.

Parameters

  refreshDuration | The new minimum duration between refreshes. May be 0 or c_refreshNever.

## storeCurrentLightState() [1/2]

void hueplusplus::Scene::storeCurrentLightState | ( |  | ) |

Store current light state of every light in the scene.

Exceptions

  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

## storeCurrentLightState() [2/2]

void hueplusplus::Scene::storeCurrentLightState | ( | int | transition | ) |

Store current light state and update transition time.

Parameters

  transition | The updated transition time to this scene

Exceptions

  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

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

- include/hueplusplus/Scene.h
- src/Scene.cpp