|
hueplusplus 1.2.0
|
Rule stored in the bridge. More...
#include <hueplusplus/Rule.h>
Public Member Functions | |
| Rule (int id, const std::shared_ptr< APICache > &baseCache) | |
| Creates rule with shared cache. | |
| Rule (int id, const HueCommandAPI &commands, std::chrono::steady_clock::duration refreshDuration, const nlohmann::json ¤tState) | |
| Creates rule with id. | |
| void | refresh (bool force=false) |
| Refreshes internal cached state. | |
| void | setRefreshDuration (std::chrono::steady_clock::duration refreshDuration) |
| Sets custom refresh interval for this rule. | |
| int | getId () const |
| Get rule identifier. | |
| std::string | getName () const |
| Get rule name. | |
| void | setName (const std::string &name) |
| Set rule name. | |
| time::AbsoluteTime | getCreated () const |
| Get created time. | |
| time::AbsoluteTime | getLastTriggered () const |
| Get time the rule was last triggered. | |
| int | getTimesTriggered () const |
| Get the number of times the rule was triggered. | |
| bool | isEnabled () const |
| Get whether rule is enabled or disabled. | |
| void | setEnabled (bool enabled) |
| Enable or disable rule. | |
| std::string | getOwner () const |
| Get user that created or last changed the rule. | |
| std::vector< Condition > | getConditions () const |
| Get the conditions that have to be met. | |
| std::vector< Action > | getActions () const |
| Get the actions that are executed. | |
| void | setConditions (const std::vector< Condition > &conditions) |
| Set conditions for the rule. | |
| void | setActions (const std::vector< Action > &actions) |
| Set actions for the rule. | |
Rule stored in the bridge.
Rules are used to automatically trigger Actions when certain events happen. The bridge can only support a limited number of rules, conditions and actions.
They are deactivated if any errors occur when they are evaluated.
| hueplusplus::Rule::Rule | ( | int | id, |
| const std::shared_ptr< APICache > & | baseCache | ||
| ) |
Creates rule with shared cache.
| id | Rule id in the bridge |
| baseCache | Cache of the rule list. |
| hueplusplus::Rule::Rule | ( | int | id, |
| const HueCommandAPI & | commands, | ||
| std::chrono::steady_clock::duration | refreshDuration, | ||
| const nlohmann::json & | currentState | ||
| ) |
Creates rule with id.
| id | Rule id in the bridge |
| commands | HueCommandAPI for requests |
| refreshDuration | Time between refreshing the cached state. |
| currentState | The current state, may be null. |
| std::vector< Action > hueplusplus::Rule::getActions | ( | ) | const |
Get the actions that are executed.
At least one action must exist.
| std::vector< Condition > hueplusplus::Rule::getConditions | ( | ) | const |
Get the conditions that have to be met.
The rule triggers the actions when all conditions are true. At least one condition must exist.
| time::AbsoluteTime hueplusplus::Rule::getCreated | ( | ) | const |
Get created time.
| int hueplusplus::Rule::getId | ( | ) | const |
Get rule identifier.
| time::AbsoluteTime hueplusplus::Rule::getLastTriggered | ( | ) | const |
Get time the rule was last triggered.
| std::string hueplusplus::Rule::getName | ( | ) | const |
Get rule name.
The rule name is always unique for the bridge.
| std::string hueplusplus::Rule::getOwner | ( | ) | const |
Get user that created or last changed the rule.
| int hueplusplus::Rule::getTimesTriggered | ( | ) | const |
Get the number of times the rule was triggered.
| bool hueplusplus::Rule::isEnabled | ( | ) | const |
Get whether rule is enabled or disabled.
| void hueplusplus::Rule::refresh | ( | bool | force = false | ) |
Refreshes internal cached state.
| 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). |
| 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 |
| void hueplusplus::Rule::setActions | ( | const std::vector< Action > & | actions | ) |
Set actions for the rule.
| actions | The actions that are triggered when the conditions are met. Must not be empty. |
| void hueplusplus::Rule::setConditions | ( | const std::vector< Condition > & | conditions | ) |
Set conditions for the rule.
| conditions | All conditions that need to be fulfilled. Must not be empty. |
| 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 |
| void hueplusplus::Rule::setEnabled | ( | bool | enabled | ) |
Enable or disable rule.
| enabled | whether the rule is triggered. |
| 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 |
| void hueplusplus::Rule::setName | ( | const std::string & | name | ) |
Set rule name.
| name | New name for the rule. Must be unique for all rules, otherwise a number is added. |
| 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 |
| void hueplusplus::Rule::setRefreshDuration | ( | std::chrono::steady_clock::duration | refreshDuration | ) |
Sets custom refresh interval for this rule.
| refreshDuration | The new minimum duration between refreshes. May be 0 or c_refreshNever. |