hueplusplus
1.0.0
|
Bridge class for a bridge. More...
#include <hueplusplus/Bridge.h>
Public Types | |
using | LightList = SearchableResourceList< Light > |
using | GroupList = GroupResourceList< Group, CreateGroup > |
using | ScheduleList = CreateableResourceList< ResourceList< Schedule, int >, CreateSchedule > |
using | SceneList = CreateableResourceList< ResourceList< Scene, std::string >, CreateScene > |
using | RuleList = CreateableResourceList< ResourceList< Rule, int >, CreateRule > |
Public Member Functions | |
Bridge (const std::string &ip, const int port, const std::string &username, std::shared_ptr< const IHttpHandler > handler, const std::string &clientkey="", std::chrono::steady_clock::duration refreshDuration=std::chrono::seconds(10), bool sharedState=false) | |
Constructor of Bridge class. More... | |
void | refresh () |
Refreshes the bridge state. More... | |
void | setRefreshDuration (std::chrono::steady_clock::duration refreshDuration) |
Sets refresh interval for the whole bridge state. More... | |
std::string | getBridgeIP () const |
Function to get the ip address of the hue bridge. More... | |
bool | startStreaming (std::string group_identifier) |
Function to set stream mode to active for entertainment mode. More... | |
bool | stopStreaming (std::string group_identifier) |
Function to set stream mode to active for entertainment mode. More... | |
int | getBridgePort () const |
Function to get the port of the hue bridge. More... | |
std::string | requestUsername () |
Send a username request to the Hue bridge. More... | |
std::string | getUsername () const |
Function that returns the username. More... | |
std::string | getClientKey () const |
Function that returns the client key. More... | |
void | setIP (const std::string &ip) |
Function to set the ip address of this class representing a bridge. More... | |
void | setPort (const int port) |
Function to set the port of this class representing a bridge. More... | |
BridgeConfig & | config () |
Provides access to the configuration of the bridge. More... | |
const BridgeConfig & | config () const |
Provides access to the configuration of the bridge. More... | |
LightList & | lights () |
Provides access to the Lights on the bridge. More... | |
const LightList & | lights () const |
Provides access to the Lights on the bridge. More... | |
GroupList & | groups () |
Provides access to the Groups on the bridge. More... | |
const GroupList & | groups () const |
Provides access to the Groups on the bridge. More... | |
ScheduleList & | schedules () |
Provides access to the Schedules on the bridge. More... | |
const ScheduleList & | schedules () const |
Provides access to the Schedules on the bridge. More... | |
SceneList & | scenes () |
Provides access to the Scenes on the bridge. More... | |
const SceneList & | scenes () const |
Provides access to the Scenes on the bridge. More... | |
SensorList & | sensors () |
Provides access to the Sensors on the bridge. More... | |
const SensorList & | sensors () const |
Provides access to the Sensors on the bridge. More... | |
RuleList & | rules () |
Provides access to the Rules on the bridge. More... | |
const RuleList & | rules () const |
Provides access to the Rules on the bridge. More... | |
Friends | |
class | BridgeFinder |
Bridge class for a bridge.
This is the main class used to interact with the Hue bridge.
using hueplusplus::Bridge::RuleList = CreateableResourceList<ResourceList<Rule, int>, CreateRule> |
using hueplusplus::Bridge::SceneList = CreateableResourceList<ResourceList<Scene, std::string>, CreateScene> |
using hueplusplus::Bridge::ScheduleList = CreateableResourceList<ResourceList<Schedule, int>, CreateSchedule> |
hueplusplus::Bridge::Bridge | ( | const std::string & | ip, |
const int | port, | ||
const std::string & | username, | ||
std::shared_ptr< const IHttpHandler > | handler, | ||
const std::string & | clientkey = "" , |
||
std::chrono::steady_clock::duration | refreshDuration = std::chrono::seconds(10) , |
||
bool | sharedState = false |
||
) |
Constructor of Bridge class.
ip | IP address in dotted decimal notation like "192.168.2.1" |
port | Port of the hue bridge |
username | String that specifies the username that is used to control the bridge. Can be left empty and acquired in requestUsername. |
handler | HttpHandler for communication with the bridge |
clientkey | Optional client key for streaming |
refreshDuration | Time between refreshing the cached state. |
sharedState | Uses a single, shared cache for all objects on the bridge. |
BridgeConfig & hueplusplus::Bridge::config | ( | ) |
Provides access to the configuration of the bridge.
const BridgeConfig & hueplusplus::Bridge::config | ( | ) | const |
Provides access to the configuration of the bridge.
std::string hueplusplus::Bridge::getBridgeIP | ( | ) | const |
Function to get the ip address of the hue bridge.
int hueplusplus::Bridge::getBridgePort | ( | ) | const |
Function to get the port of the hue bridge.
std::string hueplusplus::Bridge::getClientKey | ( | ) | const |
Function that returns the client key.
std::string hueplusplus::Bridge::getUsername | ( | ) | const |
Function that returns the username.
Bridge::GroupList & hueplusplus::Bridge::groups | ( | ) |
Provides access to the Groups on the bridge.
const Bridge::GroupList & hueplusplus::Bridge::groups | ( | ) | const |
Provides access to the Groups on the bridge.
Bridge::LightList & hueplusplus::Bridge::lights | ( | ) |
Provides access to the Lights on the bridge.
const Bridge::LightList & hueplusplus::Bridge::lights | ( | ) | const |
Provides access to the Lights on the bridge.
void hueplusplus::Bridge::refresh | ( | ) |
Refreshes the bridge state.
Should only be called rarely, as a full refresh is costly and usually not necessary. Instead refresh only the parts you are interested in or rely on periodic refreshes that happen automatically when calling non-const methods.
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 |
std::string hueplusplus::Bridge::requestUsername | ( | ) |
Send a username request to the Hue bridge.
Blocks for about 30 seconds and 5 seconds to prepare. It automatically sets the username variable according to the username received and returns the username received. This function should only be called once to acquire a username to control the bridge and the username should be saved for future use.
std::system_error | when system or socket operations fail |
HueException | when response contained no body |
HueAPIResponseException | when response contains an error except link button not pressed. |
nlohmann::json::parse_error | when response could not be parsed |
Bridge::RuleList & hueplusplus::Bridge::rules | ( | ) |
Provides access to the Rules on the bridge.
const Bridge::RuleList & hueplusplus::Bridge::rules | ( | ) | const |
Provides access to the Rules on the bridge.
Bridge::SceneList & hueplusplus::Bridge::scenes | ( | ) |
Provides access to the Scenes on the bridge.
const Bridge::SceneList & hueplusplus::Bridge::scenes | ( | ) | const |
Provides access to the Scenes on the bridge.
Bridge::ScheduleList & hueplusplus::Bridge::schedules | ( | ) |
Provides access to the Schedules on the bridge.
const Bridge::ScheduleList & hueplusplus::Bridge::schedules | ( | ) | const |
Provides access to the Schedules on the bridge.
hueplusplus::SensorList & hueplusplus::Bridge::sensors | ( | ) |
Provides access to the Sensors on the bridge.
const hueplusplus::SensorList & hueplusplus::Bridge::sensors | ( | ) | const |
Provides access to the Sensors on the bridge.
void hueplusplus::Bridge::setIP | ( | const std::string & | ip | ) |
Function to set the ip address of this class representing a bridge.
ip | String that specifies the ip in dotted decimal notation like "192.168.2.1" |
void hueplusplus::Bridge::setPort | ( | const int | port | ) |
Function to set the port of this class representing a bridge.
port | Integer that specifies the port of an address like "192.168.2.1:8080" |
void hueplusplus::Bridge::setRefreshDuration | ( | std::chrono::steady_clock::duration | refreshDuration | ) |
Sets refresh interval for the whole bridge state.
refreshDuration | The new minimum duration between refreshes. May be 0 or c_refreshNever. |
Also sets refresh duration on all resource lists on the bridge, but not on already existing lights. The resource lists (such as lights()) can have their own durations, but those must be set after calling this function.
bool hueplusplus::Bridge::startStreaming | ( | std::string | group_identifier | ) |
Function to set stream mode to active for entertainment mode.
bool hueplusplus::Bridge::stopStreaming | ( | std::string | group_identifier | ) |
Function to set stream mode to active for entertainment mode.
|
friend |