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
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)
@ gt
Attribute is greater than specified value (for int)
@ ddx
Delayed attribute has changed (no value given)
@ dx
Attribute has changed (no value given)
@ notStable
Not stable for a given time. Does not trigger a rule change.
@ lt
Attribute is less than specified value (for int)
@ eq
Attribute is equal to specified value (for bool and int)
@ notIn
Time is not in the interval (triggered on end time, local time)
@ stable
Stable for a given time. Does not trigger a rule change.
Namespace for the hueplusplus library.
Definition Action.h:28