22 #ifndef INCLUDE_HUEPLUSPLUS_RULE_H 23 #define INCLUDE_HUEPLUSPLUS_RULE_H 48 Rule(
int id,
const std::shared_ptr<APICache>& baseCache);
54 Rule(
int id,
const HueCommandAPI& commands, std::chrono::steady_clock::duration refreshDuration,
const nlohmann::json& currentState);
63 void refresh(
bool force =
false);
84 void setName(
const std::string& name);
124 void setConditions(
const std::vector<Condition>& conditions);
128 void setActions(
const std::vector<Action>& actions);
140 nlohmann::json sendPutRequest(
const nlohmann::json& request,
FileInfo fileInfo);
156 CreateRule(
const std::vector<Condition>& conditions,
const std::vector<Action>& actions);
167 nlohmann::json getRequest()
const;
170 nlohmann::json request;
void setConditions(const std::vector< Condition > &conditions)
Set conditions for the rule.
Definition: Rule.cpp:235
Definition: HueCommandAPI.h:37
Rule(int id, const std::shared_ptr< APICache > &baseCache)
Creates rule with shared cache.
Definition: Rule.cpp:133
Rule stored in the bridge.
Definition: Rule.h:42
Namespace for the hueplusplus library.
Definition: Action.h:27
Caches API GET requests and refreshes regularly.
Definition: APICache.h:37
void refresh(bool force=false)
Refreshes internal cached state.
Definition: Rule.cpp:143
std::string getOwner() const
Get user that created or last changed the rule.
Definition: Rule.cpp:208
Parameters for creating a new Rule.
Definition: Rule.h:150
Contains information about error location, use CURRENT_FILE_INFO to create.
Definition: HueException.h:34
One-time, absolute time point.
Definition: TimePattern.h:72
void setRefreshDuration(std::chrono::steady_clock::duration refreshDuration)
Sets custom refresh interval for this rule.
Definition: Rule.cpp:155
void setEnabled(bool enabled)
Enable or disable rule.
Definition: Rule.cpp:202
int getTimesTriggered() const
Get the number of times the rule was triggered.
Definition: Rule.cpp:192
void setActions(const std::vector< Action > &actions)
Set actions for the rule.
Definition: Rule.cpp:247
bool isEnabled() const
Get whether rule is enabled or disabled.
Definition: Rule.cpp:197
std::vector< Action > getActions() const
Get the actions that are executed.
Definition: Rule.cpp:224
time::AbsoluteTime getLastTriggered() const
Get time the rule was last triggered.
Definition: Rule.cpp:182
void setName(const std::string &name)
Set rule name.
Definition: Rule.cpp:170
std::string getName() const
Get rule name.
Definition: Rule.cpp:165
time::AbsoluteTime getCreated() const
Get created time.
Definition: Rule.cpp:177
int getId() const
Get rule identifier.
Definition: Rule.cpp:160
std::vector< Condition > getConditions() const
Get the conditions that have to be met.
Definition: Rule.cpp:213