hueplusplus  1.0.0
Public Types | Public Member Functions | Static Public Member Functions | List of all members
hueplusplus::Condition Class Reference

Condition for a Rule. More...

#include <hueplusplus/Condition.h>

Public Types

enum  Operator {
  Operator::eq, Operator::gt, Operator::lt, Operator::dx,
  Operator::ddx, Operator::stable, Operator::notStable, Operator::in,
  Operator::notIn
}
 Specifies which operation is used to check the condition. More...
 

Public Member Functions

 Condition (const std::string &address, Operator op, const std::string &value)
 Create a condition from any address on the bridge. More...
 
std::string getAddress () const
 Get address on the bridge. More...
 
Operator getOperator () const
 Get used operator. More...
 
std::string getValue () const
 Get value the attribute is checked against. More...
 
nlohmann::json toJson () const
 Create the json form of the condition. More...
 

Static Public Member Functions

static Condition parse (const nlohmann::json &json)
 Parse condition from json value. More...
 

Detailed Description

Condition for a Rule.

The condition checks whether a resource attribute (usually a Sensor value) matches the specified Operator.

Conditions from sensors can be created more easily using the makeCondition() helper functions.

Member Enumeration Documentation

◆ Operator

Specifies which operation is used to check the condition.

Enumerator
eq 

Attribute is equal to specified value (for bool and int)

gt 

Attribute is greater than specified value (for int)

lt 

Attribute is less than specified value (for int)

dx 

Attribute has changed (no value given)

ddx 

Delayed attribute has changed (no value given)

stable 

Stable for a given time. Does not trigger a rule change.

notStable 

Not stable for a given time. Does not trigger a rule change.

in 

Time is in the given interval (triggered on start time, local time)

notIn 

Time is not in the interval (triggered on end time, local time)

Constructor & Destructor Documentation

◆ Condition()

hueplusplus::Condition::Condition ( const std::string &  address,
Operator  op,
const std::string &  value 
)

Create a condition from any address on the bridge.

Parameters
addressPath to an attribute of the bridge
opOperator used for comparison.
valueString representation of the value to check against. Empty for some operators.

Member Function Documentation

◆ getAddress()

std::string hueplusplus::Condition::getAddress ( ) const

Get address on the bridge.

◆ getOperator()

Condition::Operator hueplusplus::Condition::getOperator ( ) const

Get used operator.

◆ getValue()

std::string hueplusplus::Condition::getValue ( ) const

Get value the attribute is checked against.

◆ parse()

Condition hueplusplus::Condition::parse ( const nlohmann::json &  json)
static

Parse condition from json value.

Parameters
jsonJson object with address, operator and value
Returns
The parsed condition with the same values
Exceptions
HueExceptionwhen the operator is unknown.

◆ toJson()

nlohmann::json hueplusplus::Condition::toJson ( ) const

Create the json form of the condition.

Returns
A json object with address, operator and value

The documentation for this class was generated from the following files: