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