22#ifndef INCLUDE_HUEPLUSPLUS_CONDITION_H
23#define INCLUDE_HUEPLUSPLUS_CONDITION_H
27#include <nlohmann/json.hpp>
70 nlohmann::json
toJson()
const;
94class GeneralConditionHelper
97 explicit GeneralConditionHelper(
const std::string& address) : address(address) { }
111class ConditionHelper<int> :
public GeneralConditionHelper
114 using GeneralConditionHelper::GeneralConditionHelper;
120 Condition create(
Condition::Operator op,
int value) {
return Condition(address, op, std::to_string(value)); }
125class ConditionHelper<bool> :
public GeneralConditionHelper
128 using GeneralConditionHelper::GeneralConditionHelper;
132 Condition create(
Condition::Operator op,
bool value) {
return Condition(address, op, value ?
"true" :
"false"); }
137class ConditionHelper<time::AbsoluteTime> :
public GeneralConditionHelper
140 using GeneralConditionHelper::GeneralConditionHelper;
147 return Condition(address, op, value.toString());
151 return Condition(address, op, interval.toString());
155template <
typename... Ts>
161template <
typename... Ts>
162using void_t =
typename make_void<Ts...>::type;
Condition for a Rule.
Definition Condition.h:38
Condition(const std::string &address, Operator op, const std::string &value)
Create a condition from any address on the bridge.
Definition Rule.cpp:27
std::string getAddress() const
Get address on the bridge.
Definition Rule.cpp:30
nlohmann::json toJson() const
Create the json form of the condition.
Definition Rule.cpp:43
std::string getValue() const
Get value the attribute is checked against.
Definition Rule.cpp:38
static Condition parse(const nlohmann::json &json)
Parse condition from json value.
Definition Rule.cpp:87
Operator getOperator() const
Get used operator.
Definition Rule.cpp:34
Operator
Specifies which operation is used to check the condition.
Definition Condition.h:42
@ in
Time is in the given interval (triggered on start time, local time).
Definition Condition.h:50
@ gt
Attribute is greater than specified value (for int).
Definition Condition.h:44
@ ddx
Delayed attribute has changed (no value given).
Definition Condition.h:47
@ dx
Attribute has changed (no value given).
Definition Condition.h:46
@ notStable
Not stable for a given time. Does not trigger a rule change.
Definition Condition.h:49
@ lt
Attribute is less than specified value (for int).
Definition Condition.h:45
@ eq
Attribute is equal to specified value (for bool and int).
Definition Condition.h:43
@ notIn
Time is not in the interval (triggered on end time, local time).
Definition Condition.h:51
@ stable
Stable for a given time. Does not trigger a rule change.
Definition Condition.h:48
Namespace for the hueplusplus library.
Definition Action.h:28