hueplusplus 1.2.0
Loading...
Searching...
No Matches
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
27namespace hueplusplus
28{
29namespace sensors
30{
32class ZGPSwitch : public BaseDevice
33{
34public:
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
68class ZLLSwitch : public BaseDevice
69{
70public:
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
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
153{
154public:
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
203
205 static constexpr const char* typeStr = "ZLLPresence";
206};
207
210{
211public:
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
253
255 static constexpr const char* typeStr = "ZLLTemperature";
256};
257
260{
261public:
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
318
320 static constexpr const char* typeStr = "ZLLLightLevel";
321};
322
323detail::ConditionHelper<bool> makeConditionDark(const ZLLLightLevel& sensor);
324detail::ConditionHelper<bool> makeConditionDaylight(const ZLLLightLevel& sensor);
325detail::ConditionHelper<int> makeConditionLightLevel(const ZLLLightLevel& sensor);
326} // namespace sensors
327} // namespace hueplusplus
328
329#endif
Base class for physical devices connected to the bridge (sensor or light).
Definition BaseDevice.h:36
Class for generic or unknown sensor types.
Definition Sensor.h:60
ZigBee Green Power sensor for button presses.
Definition ZLLSensors.h:33
bool isOn() const
Check if sensor is on.
Definition ZLLSensors.cpp:37
static constexpr int c_button1
Code for tap button 1.
Definition ZLLSensors.h:55
int getButtonEvent() const
Get the code of the last switch event.
Definition ZLLSensors.cpp:47
static constexpr int c_button2
Code for tap button 2.
Definition ZLLSensors.h:57
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
static constexpr const char * typeStr
ZGPSwitch sensor type name.
Definition ZLLSensors.h:64
void setOn(bool on)
Enable or disable sensor.
Definition ZLLSensors.cpp:42
ZGPSwitch(Sensor sensor)
Construct from generic sensor.
Definition ZLLSensors.h:36
ZigBee sensor detecting ambient light level.
Definition ZLLSensors.h:260
ZLLLightLevel(Sensor sensor)
Construct from generic sensor.
Definition ZLLSensors.h:263
int getDarkThreshold() const
Get threshold to detect darkness.
Definition ZLLSensors.cpp:252
bool isDaylight() const
Check whether light level is above light threshold.
Definition ZLLSensors.cpp:281
time::AbsoluteTime getLastUpdated() const
Get time of last status update.
Definition ZLLSensors.cpp:286
void setThresholdOffset(int offset)
Set offset to detect daylight.
Definition ZLLSensors.cpp:266
bool isDark() const
Check whether light level is below dark threshold.
Definition ZLLSensors.cpp:276
int getBatteryState() const
Get battery state.
Definition ZLLSensors.cpp:244
bool isReachable() const
Check whether the sensor is reachable.
Definition ZLLSensors.cpp:248
int getThresholdOffset() const
Get offset over dark threshold to detect daylight.
Definition ZLLSensors.cpp:261
void setOn(bool on)
Enable or disable sensor.
Definition ZLLSensors.cpp:236
bool hasBatteryState() const
Check whether the sensor has a battery state.
Definition ZLLSensors.cpp:240
bool isOn() const
Check if sensor is on.
Definition ZLLSensors.cpp:231
static constexpr const char * typeStr
ZLLLightLevel sensor type name.
Definition ZLLSensors.h:320
void setDarkThreshold(int threshold)
Set threshold to detect darkness.
Definition ZLLSensors.cpp:257
int getLightLevel() const
Get measured light level.
Definition ZLLSensors.cpp:271
Sensor detecting presence in the vicinity.
Definition ZLLSensors.h:153
void setSensitivity(int sensitivity)
Set sensor sensitivity.
Definition ZLLSensors.cpp:159
ZLLPresence(Sensor sensor)
Construct from generic sensor.
Definition ZLLSensors.h:156
bool isOn() const
Check if sensor is on.
Definition ZLLSensors.cpp:119
time::AbsoluteTime getLastUpdated() const
Get time of last status update.
Definition ZLLSensors.cpp:168
static constexpr const char * typeStr
ZLLPresence sensor type name.
Definition ZLLSensors.h:205
bool isReachable() const
Check whether the sensor is reachable.
Definition ZLLSensors.cpp:146
void sendAlert(Alert type)
Send alert.
Definition ZLLSensors.cpp:142
Alert getLastAlert() const
Get last sent alert.
Definition ZLLSensors.cpp:137
int getBatteryState() const
Get battery state.
Definition ZLLSensors.cpp:132
bool getPresence() const
Get presence status.
Definition ZLLSensors.cpp:163
int getMaxSensitivity() const
Get maximum sensitivity.
Definition ZLLSensors.cpp:155
bool hasBatteryState() const
Check whether the sensor has a battery state.
Definition ZLLSensors.cpp:128
void setOn(bool on)
Enable or disable sensor.
Definition ZLLSensors.cpp:124
int getSensitivity() const
Get sensor sensitivity.
Definition ZLLSensors.cpp:151
ZigBee sensor reporting button presses.
Definition ZLLSensors.h:69
void setOn(bool on)
Enable or disable sensor.
Definition ZLLSensors.cpp:75
int getBatteryState() const
Get battery state.
Definition ZLLSensors.cpp:83
static constexpr int c_OFF_SHORT_RELEASED
Button 4 (OFF) released short press.
Definition ZLLSensors.h:143
static constexpr int c_OFF_LONG_RELEASED
Button 4 (OFF) released long press.
Definition ZLLSensors.h:145
time::AbsoluteTime getLastUpdated() const
Get time of last status update.
Definition ZLLSensors.cpp:106
static constexpr int c_DOWN_HOLD
Button 3 (DIM DOWN) held.
Definition ZLLSensors.h:133
static constexpr int c_DOWN_LONG_RELEASED
Button 3 (DIM DOWN) released long press.
Definition ZLLSensors.h:137
static constexpr int c_ON_LONG_RELEASED
Button 1 (ON) released long press.
Definition ZLLSensors.h:121
Alert getLastAlert() const
Get last sent alert.
Definition ZLLSensors.cpp:88
static constexpr int c_DOWN_SHORT_RELEASED
Button 3 (DIM DOWN) released short press.
Definition ZLLSensors.h:135
bool hasBatteryState() const
Check whether the sensor has a battery state.
Definition ZLLSensors.cpp:79
static constexpr int c_ON_INITIAL_PRESS
Button 1 (ON) pressed.
Definition ZLLSensors.h:115
void sendAlert(Alert type)
Send alert.
Definition ZLLSensors.cpp:93
static constexpr int c_ON_SHORT_RELEASED
Button 1 (ON) released short press.
Definition ZLLSensors.h:119
static constexpr int c_OFF_INITIAL_PRESS
Button 4 (OFF) pressed.
Definition ZLLSensors.h:139
static constexpr int c_UP_SHORT_RELEASED
Button 2 (DIM UP) released short press.
Definition ZLLSensors.h:127
ZLLSwitch(Sensor sensor)
Construct from generic sensor.
Definition ZLLSensors.h:72
static constexpr int c_DOWN_INITIAL_PRESS
Button 3 (DIM DOWN) pressed.
Definition ZLLSensors.h:131
static constexpr int c_UP_LONG_RELEASED
Button 2 (DIM UP) released long press.
Definition ZLLSensors.h:129
bool isOn() const
Check if sensor is on.
Definition ZLLSensors.cpp:70
static constexpr int c_OFF_HOLD
Button 4 (OFF) held.
Definition ZLLSensors.h:141
static constexpr const char * typeStr
ZLLSwitch sensor type name.
Definition ZLLSensors.h:148
static constexpr int c_ON_HOLD
Button 1 (ON) held.
Definition ZLLSensors.h:117
bool isReachable() const
Check whether the sensor is reachable.
Definition ZLLSensors.cpp:97
static constexpr int c_UP_HOLD
Button 2 (DIM UP) held.
Definition ZLLSensors.h:125
int getButtonEvent() const
Get the code of the last switch event.
Definition ZLLSensors.cpp:101
static constexpr int c_UP_INITIAL_PRESS
Button 2 (DIM UP) pressed.
Definition ZLLSensors.h:123
ZigBee temperature sensor.
Definition ZLLSensors.h:210
bool hasBatteryState() const
Check whether the sensor has a battery state.
Definition ZLLSensors.cpp:190
bool isReachable() const
Check whether the sensor is reachable.
Definition ZLLSensors.cpp:208
void sendAlert(Alert type)
Send alert.
Definition ZLLSensors.cpp:204
Alert getLastAlert() const
Get last sent alert.
Definition ZLLSensors.cpp:199
int getBatteryState() const
Get battery state.
Definition ZLLSensors.cpp:194
ZLLTemperature(Sensor sensor)
Construct from generic sensor.
Definition ZLLSensors.h:213
void setOn(bool on)
Enable or disable sensor.
Definition ZLLSensors.cpp:186
static constexpr const char * typeStr
ZLLTemperature sensor type name.
Definition ZLLSensors.h:255
time::AbsoluteTime getLastUpdated() const
Get time of last status update.
Definition ZLLSensors.cpp:218
int getTemperature() const
Get recorded temperature.
Definition ZLLSensors.cpp:213
bool isOn() const
Check if sensor is on.
Definition ZLLSensors.cpp:181
One-time, absolute time point.
Definition TimePattern.h:73
detail::ConditionHelper< int > makeConditionLightLevel(const ZLLLightLevel &sensor)
Definition ZLLSensors.cpp:307
detail::ConditionHelper< bool > makeConditionDark(const ZLLLightLevel &sensor)
Definition ZLLSensors.cpp:297
detail::ConditionHelper< bool > makeConditionDaylight(const ZLLLightLevel &sensor)
Definition ZLLSensors.cpp:302
Namespace for the hueplusplus library.
Definition Action.h:28
Alert
Specifies light alert modes.
Definition Sensor.h:39