hueplusplus  1.0.0
ZLLSensors.h
Go to the documentation of this file.
1 
22 #ifndef INCLUDE_HUEPLUSPLUS_ZLL_SENSORS_H
23 #define INCLUDE_HUEPLUSPLUS_ZLL_SENSORS_H
24 
25 #include "Sensor.h"
26 
27 namespace hueplusplus
28 {
29 namespace sensors
30 {
32 class ZGPSwitch : public BaseDevice
33 {
34 public:
36  explicit ZGPSwitch(Sensor sensor) : BaseDevice(std::move(sensor)) { }
37 
41  bool isOn() const;
47  void setOn(bool on);
48 
52  int getButtonEvent() const;
53 
55  static constexpr int c_button1 = 34;
57  static constexpr int c_button2 = 16;
59  static constexpr int c_button3 = 17;
61  static constexpr int c_button4 = 18;
62 
64  static constexpr const char* typeStr = "ZGPSwitch";
65 };
66 
68 class ZLLSwitch : public BaseDevice
69 {
70 public:
72  explicit ZLLSwitch(Sensor sensor) : BaseDevice(std::move(sensor)) { }
73 
77  bool isOn() const;
83  void setOn(bool on);
84 
86  bool hasBatteryState() const;
89  int getBatteryState() const;
90 
93  Alert getLastAlert() const;
99  void sendAlert(Alert type);
100 
102  bool isReachable() const;
103 
107  int getButtonEvent() const;
108 
112  time::AbsoluteTime getLastUpdated() const;
113 
115  static constexpr int c_ON_INITIAL_PRESS = 1000;
117  static constexpr int c_ON_HOLD = 1001;
119  static constexpr int c_ON_SHORT_RELEASED = 1002;
121  static constexpr int c_ON_LONG_RELEASED = 1003;
123  static constexpr int c_UP_INITIAL_PRESS = 2000;
125  static constexpr int c_UP_HOLD = 2001;
127  static constexpr int c_UP_SHORT_RELEASED = 2002;
129  static constexpr int c_UP_LONG_RELEASED = 2003;
131  static constexpr int c_DOWN_INITIAL_PRESS = 3000;
133  static constexpr int c_DOWN_HOLD = 3001;
135  static constexpr int c_DOWN_SHORT_RELEASED = 3002;
137  static constexpr int c_DOWN_LONG_RELEASED = 3003;
139  static constexpr int c_OFF_INITIAL_PRESS = 4000;
141  static constexpr int c_OFF_HOLD = 4001;
143  static constexpr int c_OFF_SHORT_RELEASED = 4002;
145  static constexpr int c_OFF_LONG_RELEASED = 4003;
146 
148  static constexpr const char* typeStr = "ZLLSwitch";
149 };
150 
152 class ZLLPresence : public BaseDevice
153 {
154 public:
156  explicit ZLLPresence(Sensor sensor) : BaseDevice(std::move(sensor)) { }
157 
161  bool isOn() const;
167  void setOn(bool on);
168 
170  bool hasBatteryState() const;
173  int getBatteryState() const;
174 
177  Alert getLastAlert() const;
183  void sendAlert(Alert type);
184 
186  bool isReachable() const;
187 
189  int getSensitivity() const;
191  int getMaxSensitivity() const;
194  void setSensitivity(int sensitivity);
195 
197  bool getPresence() const;
198 
202  time::AbsoluteTime getLastUpdated() const;
203 
205  static constexpr const char* typeStr = "ZLLPresence";
206 };
207 
210 {
211 public:
213  explicit ZLLTemperature(Sensor sensor) : BaseDevice(std::move(sensor)) { }
214 
218  bool isOn() const;
224  void setOn(bool on);
225 
227  bool hasBatteryState() const;
230  int getBatteryState() const;
231 
234  Alert getLastAlert() const;
240  void sendAlert(Alert type);
241 
243  bool isReachable() const;
244 
247  int getTemperature() const;
248 
252  time::AbsoluteTime getLastUpdated() const;
253 
255  static constexpr const char* typeStr = "ZLLTemperature";
256 };
257 
259 class ZLLLightLevel : public BaseDevice
260 {
261 public:
263  explicit ZLLLightLevel(Sensor sensor) : BaseDevice(std::move(sensor)) { }
264 
268  bool isOn() const;
274  void setOn(bool on);
275 
277  bool hasBatteryState() const;
280  int getBatteryState() const;
281 
283  bool isReachable() const;
284 
286  int getDarkThreshold() const;
293  void setDarkThreshold(int threshold);
295  int getThresholdOffset() const;
302  void setThresholdOffset(int offset);
303 
306  int getLightLevel() const;
308  bool isDark() const;
312  bool isDaylight() const;
313 
317  time::AbsoluteTime getLastUpdated() const;
318 
320  static constexpr const char* typeStr = "ZLLLightLevel";
321 };
322 
323 detail::ConditionHelper<bool> makeConditionDark(const ZLLLightLevel& sensor);
324 detail::ConditionHelper<bool> makeConditionDaylight(const ZLLLightLevel& sensor);
325 detail::ConditionHelper<int> makeConditionLightLevel(const ZLLLightLevel& sensor);
326 } // namespace sensors
327 } // namespace hueplusplus
328 
329 #endif
static constexpr int c_button1
Code for tap button 1.
Definition: ZLLSensors.h:55
ZigBee temperature sensor.
Definition: ZLLSensors.h:209
bool isOn() const
Check if sensor is on.
Definition: ZLLSensors.cpp:37
ZigBee sensor detecting ambient light level.
Definition: ZLLSensors.h:259
ZLLPresence(Sensor sensor)
Construct from generic sensor.
Definition: ZLLSensors.h:156
detail::ConditionHelper< bool > makeConditionDaylight(const ZLLLightLevel &sensor)
Definition: ZLLSensors.cpp:302
void setOn(bool on)
Enable or disable sensor.
Definition: ZLLSensors.cpp:42
Namespace for the hueplusplus library.
Definition: Action.h:27
Alert
Specifies light alert modes.
Definition: Sensor.h:38
ZigBee sensor reporting button presses.
Definition: ZLLSensors.h:68
Base class for physical devices connected to the bridge (sensor or light).
Definition: BaseDevice.h:35
Sensor detecting presence in the vicinity.
Definition: ZLLSensors.h:152
ZLLTemperature(Sensor sensor)
Construct from generic sensor.
Definition: ZLLSensors.h:213
ZGPSwitch(Sensor sensor)
Construct from generic sensor.
Definition: ZLLSensors.h:36
One-time, absolute time point.
Definition: TimePattern.h:72
static constexpr const char * typeStr
ZGPSwitch sensor type name.
Definition: ZLLSensors.h:64
static constexpr int c_button4
Code for tap button 4.
Definition: ZLLSensors.h:61
static constexpr int c_button3
Code for tap button 3.
Definition: ZLLSensors.h:59
Class for generic or unknown sensor types.
Definition: Sensor.h:59
ZigBee Green Power sensor for button presses.
Definition: ZLLSensors.h:32
ZLLSwitch(Sensor sensor)
Construct from generic sensor.
Definition: ZLLSensors.h:72
ZLLLightLevel(Sensor sensor)
Construct from generic sensor.
Definition: ZLLSensors.h:263
static constexpr int c_button2
Code for tap button 2.
Definition: ZLLSensors.h:57
int getButtonEvent() const
Get the code of the last switch event.
Definition: ZLLSensors.cpp:47
detail::ConditionHelper< bool > makeConditionDark(const ZLLLightLevel &sensor)
Definition: ZLLSensors.cpp:297
detail::ConditionHelper< int > makeConditionLightLevel(const ZLLLightLevel &sensor)
Definition: ZLLSensors.cpp:307