hueplusplus
1.0.0
|
The library supports the sensor types listed on the Hue developer documentation. Include hueplusplus/ZLLSensors.h
for ZigBee sensors and hueplusplus/CLIPSensors.h
for CLIP sensors. Other sensors can be used with the generic Sensor class.
In most cases, the type of the sensors is known in advance, such as a switch. The classes in the sensors namespace provide the documented functionality. The type can be specified when accessing the sensor. When it does not match, an exception is thrown.
You can also get all sensors of a specified type by using getAllByType<T>().
When the sensor type is not known, use the generic sensor class. In this case, some attributes might not exist, so they have to be checked first. This applies to all attributes that have a hasXXX
method.
It is easiest to compare the sensor type to the existing ones (typeStr
on the specific sensor classes) and then convert the sensor to that type.
ZLL sensors (defined in ZLLSensors.h
) are physical device sensors which send their data to the bridge using ZigBee. They are added in the same way as lights are, using search().
CLIP sensors (in CLIPSensors.h
) are added using create() with CreateSensor for parameters. In general, which config and state attributes exist is specified when the sensor is created. The values of CLIP sensors can be changed using requests, unlike ZLL sensors. They can also have a URL to query from.
The most important use for sensors is in Rules, to trigger changes. Conditions can be created from the specific sensor types using makeCondition()
.
These functions return a helper class with methods for the possible operators valid for the state.
For some sensors, which have multiple possible states, there exist multiple variations of makeCondition.
For generic sensors, the conditions must be created manually using the Condition constructor with a proper address to the sensor state.