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);
170 nlohmann::json request;
Caches API GET requests and refreshes regularly.
Definition APICache.h:38
Parameters for creating a new Rule.
Definition Rule.h:151
CreateRule & setStatus(bool enabled)
Set status.
Definition Rule.cpp:286
CreateRule & setName(const std::string &name)
Set name.
Definition Rule.cpp:280
nlohmann::json getRequest() const
Get request to create the rule.
Definition Rule.cpp:292
Definition HueCommandAPI.h:38
Rule stored in the bridge.
Definition Rule.h:43
void setName(const std::string &name)
Set rule name.
Definition Rule.cpp:170
std::vector< Condition > getConditions() const
Get the conditions that have to be met.
Definition Rule.cpp:213
std::string getOwner() const
Get user that created or last changed the rule.
Definition Rule.cpp:208
void setActions(const std::vector< Action > &actions)
Set actions for the rule.
Definition Rule.cpp:247
int getId() const
Get rule identifier.
Definition Rule.cpp:160
std::vector< Action > getActions() const
Get the actions that are executed.
Definition Rule.cpp:224
int getTimesTriggered() const
Get the number of times the rule was triggered.
Definition Rule.cpp:192
void setRefreshDuration(std::chrono::steady_clock::duration refreshDuration)
Sets custom refresh interval for this rule.
Definition Rule.cpp:155
time::AbsoluteTime getCreated() const
Get created time.
Definition Rule.cpp:177
bool isEnabled() const
Get whether rule is enabled or disabled.
Definition Rule.cpp:197
time::AbsoluteTime getLastTriggered() const
Get time the rule was last triggered.
Definition Rule.cpp:182
void setConditions(const std::vector< Condition > &conditions)
Set conditions for the rule.
Definition Rule.cpp:235
std::string getName() const
Get rule name.
Definition Rule.cpp:165
void refresh(bool force=false)
Refreshes internal cached state.
Definition Rule.cpp:143
void setEnabled(bool enabled)
Enable or disable rule.
Definition Rule.cpp:202
One-time, absolute time point.
Definition TimePattern.h:73
Namespace for the hueplusplus library.
Definition Action.h:28
Contains information about error location, use CURRENT_FILE_INFO to create.
Definition HueException.h:35