hueplusplus  1.0.0
CLIPSensors.h
Go to the documentation of this file.
1 
22 #ifndef INCLUDE_HUEPLUSPLUS_CLIP_SENSORS_H
23 #define INCLUDE_HUEPLUSPLUS_CLIP_SENSORS_H
24 
25 #include "Sensor.h"
26 
27 namespace hueplusplus
28 {
29 namespace sensors
30 {
32 class BaseCLIP : public BaseDevice
33 {
34 public:
38  bool isOn() const;
44  void setOn(bool on);
45 
47  bool hasBatteryState() const;
51  int getBatteryState() const;
57  void setBatteryState(int percent);
58 
61  bool isReachable() const;
62 
64  bool hasURL() const;
66  std::string getURL() const;
72  void setURL(const std::string& url);
73 
78 
79 protected:
81  explicit BaseCLIP(Sensor sensor) : BaseDevice(std::move(sensor)) { }
82 };
83 
85 class CLIPSwitch : public BaseCLIP
86 {
87 public:
89  explicit CLIPSwitch(Sensor sensor) : BaseCLIP(std::move(sensor)) { }
90 
92  int getButtonEvent() const;
98  void setButtonEvent(int code);
99 
101  static constexpr const char* typeStr = "CLIPSwitch";
102 };
103 
105 class CLIPOpenClose : public BaseCLIP
106 {
107 public:
109  explicit CLIPOpenClose(Sensor sensor) : BaseCLIP(std::move(sensor)) { }
110 
112  bool isOpen() const;
120  void setOpen(bool open);
121 
123  static constexpr const char* typeStr = "CLIPOpenClose";
124 };
125 
126 detail::ConditionHelper<bool> makeCondition(const CLIPOpenClose& sensor);
127 
129 class CLIPPresence : public BaseCLIP
130 {
131 public:
133  explicit CLIPPresence(Sensor sensor) : BaseCLIP(std::move(sensor)) { }
134 
136  bool getPresence() const;
142  void setPresence(bool presence);
143 
145  static constexpr const char* typeStr = "CLIPPresence";
146 };
147 
149 class CLIPTemperature : public BaseCLIP
150 {
151 public:
153  explicit CLIPTemperature(Sensor sensor) : BaseCLIP(std::move(sensor)) { }
154 
157  int getTemperature() const;
164  void setTemperature(int temperature);
165 
167  static constexpr const char* typeStr = "CLIPTemperature";
168 };
169 
171 class CLIPHumidity : public BaseCLIP
172 {
173 public:
175  explicit CLIPHumidity(Sensor sensor) : BaseCLIP(std::move(sensor)) { }
176 
179  int getHumidity() const;
186  void setHumidity(int humidity);
187 
189  static constexpr const char* typeStr = "CLIPHumidity";
190 };
191 
192 detail::ConditionHelper<int> makeCondition(const CLIPHumidity& sensor);
193 
195 class CLIPLightLevel : public BaseCLIP
196 {
197 public:
199  explicit CLIPLightLevel(Sensor sensor) : BaseCLIP(std::move(sensor)) { }
200 
202  int getDarkThreshold() const;
209  void setDarkThreshold(int threshold);
210 
212  int getThresholdOffset() const;
219  void setThresholdOffset(int offset);
220 
223  int getLightLevel() const;
230  void setLightLevel(int level);
232  bool isDark() const;
236  bool isDaylight() const;
237 
239  static constexpr const char* typeStr = "CLIPLightLevel";
240 };
241 
245 class CLIPGenericFlag : public BaseCLIP
246 {
247 public:
249  explicit CLIPGenericFlag(Sensor sensor) : BaseCLIP(std::move(sensor)) { }
250 
252  bool getFlag() const;
258  void setFlag(bool flag);
259 
261  static constexpr const char* typeStr = "CLIPGenericFlag";
262 };
263 
264 detail::ConditionHelper<bool> makeCondition(const CLIPGenericFlag& sensor);
265 
270 {
271 public:
273  explicit CLIPGenericStatus(Sensor sensor) : BaseCLIP(std::move(sensor)) { }
274 
276  int getStatus() const;
282  void setStatus(int status);
283 
285  static constexpr const char* typeStr = "CLIPGenericStatus";
286 };
287 
288 detail::ConditionHelper<int> makeCondition(const CLIPGenericStatus& sensor);
289 
290 } // namespace sensors
291 } // namespace hueplusplus
292 
293 #endif
bool isReachable() const
Check whether the sensor is reachable.
Definition: CLIPSensors.cpp:51
void setOn(bool on)
Enable or disable sensor.
Definition: CLIPSensors.cpp:35
CLIP sensor to detect presence.
Definition: CLIPSensors.h:129
CLIP sensor for button presses.
Definition: CLIPSensors.h:85
CLIP sensor for humidity.
Definition: CLIPSensors.h:171
CLIPGenericStatus(Sensor sensor)
Construct from generic sensor.
Definition: CLIPSensors.h:273
void setURL(const std::string &url)
Set sensor URL.
Definition: CLIPSensors.cpp:64
void setBatteryState(int percent)
Set battery state.
Definition: CLIPSensors.cpp:47
Namespace for the hueplusplus library.
Definition: Action.h:27
detail::ConditionHelper< bool > makeCondition(const CLIPOpenClose &sensor)
Definition: CLIPSensors.cpp:103
CLIPLightLevel(Sensor sensor)
Construct from generic sensor.
Definition: CLIPSensors.h:199
bool hasURL() const
Check whether the sensor has a URL.
Definition: CLIPSensors.cpp:56
Base class for physical devices connected to the bridge (sensor or light).
Definition: BaseDevice.h:35
bool isOn() const
Check if sensor is on.
Definition: CLIPSensors.cpp:30
CLIPTemperature(Sensor sensor)
Construct from generic sensor.
Definition: CLIPSensors.h:153
CLIP sensor detecting whether a contact is open or closed.
Definition: CLIPSensors.h:105
CLIPSwitch(Sensor sensor)
Construct from generic sensor.
Definition: CLIPSensors.h:89
Common methods for CLIP sensors.
Definition: CLIPSensors.h:32
One-time, absolute time point.
Definition: TimePattern.h:72
CLIPHumidity(Sensor sensor)
Construct from generic sensor.
Definition: CLIPSensors.h:175
CLIPPresence(Sensor sensor)
Construct from generic sensor.
Definition: CLIPSensors.h:133
time::AbsoluteTime getLastUpdated() const
Get time of last status update.
Definition: CLIPSensors.cpp:69
CLIPGenericFlag(Sensor sensor)
Construct from generic sensor.
Definition: CLIPSensors.h:249
Class for generic or unknown sensor types.
Definition: Sensor.h:59
BaseCLIP(Sensor sensor)
Protected constructor to be used by subclasses.
Definition: CLIPSensors.h:81
CLIP sensor for light level.
Definition: CLIPSensors.h:195
CLIPOpenClose(Sensor sensor)
Construct from generic sensor.
Definition: CLIPSensors.h:109
std::string getURL() const
Get sensor URL.
Definition: CLIPSensors.cpp:60
CLIP sensor for a generic 3rd party sensor.
Definition: CLIPSensors.h:245
CLIP sensor for a generic 3rd party status.
Definition: CLIPSensors.h:269
int getBatteryState() const
Get battery state.
Definition: CLIPSensors.cpp:43
CLIP sensor for temperature.
Definition: CLIPSensors.h:149
bool hasBatteryState() const
Check whether the sensor has a battery state.
Definition: CLIPSensors.cpp:39