hueplusplus  1.0.0
Public Member Functions | Static Public Attributes | List of all members
hueplusplus::sensors::ZLLSwitch Class Reference

ZigBee sensor reporting button presses. More...

#include <hueplusplus/ZLLSensors.h>

+ Inheritance diagram for hueplusplus::sensors::ZLLSwitch:
+ Collaboration diagram for hueplusplus::sensors::ZLLSwitch:

Public Member Functions

 ZLLSwitch (Sensor sensor)
 Construct from generic sensor. More...
 
bool isOn () const
 Check if sensor is on. More...
 
void setOn (bool on)
 Enable or disable sensor. More...
 
bool hasBatteryState () const
 Check whether the sensor has a battery state. More...
 
int getBatteryState () const
 Get battery state. More...
 
Alert getLastAlert () const
 Get last sent alert. More...
 
void sendAlert (Alert type)
 Send alert. More...
 
bool isReachable () const
 Check whether the sensor is reachable. More...
 
int getButtonEvent () const
 Get the code of the last switch event. More...
 
time::AbsoluteTime getLastUpdated () const
 Get time of last status update. More...
 
- Public Member Functions inherited from hueplusplus::BaseDevice
virtual ~BaseDevice ()=default
 Virtual destructor. More...
 
virtual int getId () const
 Const function that returns the id of this device. More...
 
virtual std::string getType () const
 Const function that returns the device type. More...
 
virtual std::string getName ()
 Function that returns the name of the device. More...
 
virtual std::string getName () const
 Const function that returns the name of the device. More...
 
virtual std::string getModelId () const
 Const function that returns the modelid of the device. More...
 
virtual std::string getUId () const
 Const function that returns the uniqueid of the device. More...
 
virtual std::string getManufacturername () const
 Const function that returns the manufacturername of the device. More...
 
virtual std::string getProductname () const
 Const function that returns the productname of the device. More...
 
virtual std::string getSwVersion ()
 Function that returns the software version of the device. More...
 
virtual std::string getSwVersion () const
 Const function that returns the software version of the device. More...
 
virtual bool setName (const std::string &name)
 Function that sets the name of the device. More...
 
virtual void refresh (bool force=false)
 Refreshes internal cached state. More...
 
virtual void setRefreshDuration (std::chrono::steady_clock::duration refreshDuration)
 Sets custom refresh interval for this device. More...
 

Static Public Attributes

static constexpr int c_ON_INITIAL_PRESS = 1000
 Button 1 (ON) pressed. More...
 
static constexpr int c_ON_HOLD = 1001
 Button 1 (ON) held. More...
 
static constexpr int c_ON_SHORT_RELEASED = 1002
 Button 1 (ON) released short press. More...
 
static constexpr int c_ON_LONG_RELEASED = 1003
 Button 1 (ON) released long press. More...
 
static constexpr int c_UP_INITIAL_PRESS = 2000
 Button 2 (DIM UP) pressed. More...
 
static constexpr int c_UP_HOLD = 2001
 Button 2 (DIM UP) held. More...
 
static constexpr int c_UP_SHORT_RELEASED = 2002
 Button 2 (DIM UP) released short press. More...
 
static constexpr int c_UP_LONG_RELEASED = 2003
 Button 2 (DIM UP) released long press. More...
 
static constexpr int c_DOWN_INITIAL_PRESS = 3000
 Button 3 (DIM DOWN) pressed. More...
 
static constexpr int c_DOWN_HOLD = 3001
 Button 3 (DIM DOWN) held. More...
 
static constexpr int c_DOWN_SHORT_RELEASED = 3002
 Button 3 (DIM DOWN) released short press. More...
 
static constexpr int c_DOWN_LONG_RELEASED = 3003
 Button 3 (DIM DOWN) released long press. More...
 
static constexpr int c_OFF_INITIAL_PRESS = 4000
 Button 4 (OFF) pressed. More...
 
static constexpr int c_OFF_HOLD = 4001
 Button 4 (OFF) held. More...
 
static constexpr int c_OFF_SHORT_RELEASED = 4002
 Button 4 (OFF) released short press. More...
 
static constexpr int c_OFF_LONG_RELEASED = 4003
 Button 4 (OFF) released long press. More...
 
static constexpr const char * typeStr = "ZLLSwitch"
 ZLLSwitch sensor type name. More...
 

Additional Inherited Members

- Protected Member Functions inherited from hueplusplus::BaseDevice
 BaseDevice (int id, const std::shared_ptr< APICache > &baseCache)
 Protected ctor that is used by subclasses, construct with shared cache. More...
 
 BaseDevice (int id, const HueCommandAPI &commands, const std::string &path, std::chrono::steady_clock::duration refreshDuration, const nlohmann::json &currentState)
 Protected ctor that is used by subclasses. More...
 
virtual nlohmann::json sendPutRequest (const std::string &subPath, const nlohmann::json &request, FileInfo fileInfo)
 Utility function to send a put request to the device. More...
 
- Protected Attributes inherited from hueplusplus::BaseDevice
int id
 holds the id of the device More...
 
APICache state
 holds the current state of the device More...
 

Detailed Description

ZigBee sensor reporting button presses.

Constructor & Destructor Documentation

◆ ZLLSwitch()

hueplusplus::sensors::ZLLSwitch::ZLLSwitch ( Sensor  sensor)
inlineexplicit

Construct from generic sensor.

Member Function Documentation

◆ getBatteryState()

int hueplusplus::sensors::ZLLSwitch::getBatteryState ( ) const

Get battery state.

Returns
Battery state in percent

◆ getButtonEvent()

int hueplusplus::sensors::ZLLSwitch::getButtonEvent ( ) const

Get the code of the last switch event.

Possible values are c_ON_INITIAL_PRESS etc., or any other value.

◆ getLastAlert()

Alert hueplusplus::sensors::ZLLSwitch::getLastAlert ( ) const

Get last sent alert.

Note
This is not cleared when the alert ends.

◆ getLastUpdated()

time::AbsoluteTime hueplusplus::sensors::ZLLSwitch::getLastUpdated ( ) const

Get time of last status update.

Returns
The last update time, or a time with a zero duration from epoch if the last update time is not set.

◆ hasBatteryState()

bool hueplusplus::sensors::ZLLSwitch::hasBatteryState ( ) const

Check whether the sensor has a battery state.

◆ isOn()

bool hueplusplus::sensors::ZLLSwitch::isOn ( ) const

Check if sensor is on.

Sensors which are off do not change their status

◆ isReachable()

bool hueplusplus::sensors::ZLLSwitch::isReachable ( ) const

Check whether the sensor is reachable.

◆ sendAlert()

void hueplusplus::sensors::ZLLSwitch::sendAlert ( Alert  type)

Send alert.

Exceptions
std::system_errorwhen system or socket operations fail
HueExceptionwhen response contained no body
HueAPIResponseExceptionwhen response contains an error
nlohmann::json::parse_errorwhen response could not be parsed

◆ setOn()

void hueplusplus::sensors::ZLLSwitch::setOn ( bool  on)

Enable or disable sensor.

Exceptions
std::system_errorwhen system or socket operations fail
HueExceptionwhen response contained no body
HueAPIResponseExceptionwhen response contains an error
nlohmann::json::parse_errorwhen response could not be parsed

Member Data Documentation

◆ c_DOWN_HOLD

constexpr int hueplusplus::sensors::ZLLSwitch::c_DOWN_HOLD = 3001
static

Button 3 (DIM DOWN) held.

◆ c_DOWN_INITIAL_PRESS

constexpr int hueplusplus::sensors::ZLLSwitch::c_DOWN_INITIAL_PRESS = 3000
static

Button 3 (DIM DOWN) pressed.

◆ c_DOWN_LONG_RELEASED

constexpr int hueplusplus::sensors::ZLLSwitch::c_DOWN_LONG_RELEASED = 3003
static

Button 3 (DIM DOWN) released long press.

◆ c_DOWN_SHORT_RELEASED

constexpr int hueplusplus::sensors::ZLLSwitch::c_DOWN_SHORT_RELEASED = 3002
static

Button 3 (DIM DOWN) released short press.

◆ c_OFF_HOLD

constexpr int hueplusplus::sensors::ZLLSwitch::c_OFF_HOLD = 4001
static

Button 4 (OFF) held.

◆ c_OFF_INITIAL_PRESS

constexpr int hueplusplus::sensors::ZLLSwitch::c_OFF_INITIAL_PRESS = 4000
static

Button 4 (OFF) pressed.

◆ c_OFF_LONG_RELEASED

constexpr int hueplusplus::sensors::ZLLSwitch::c_OFF_LONG_RELEASED = 4003
static

Button 4 (OFF) released long press.

◆ c_OFF_SHORT_RELEASED

constexpr int hueplusplus::sensors::ZLLSwitch::c_OFF_SHORT_RELEASED = 4002
static

Button 4 (OFF) released short press.

◆ c_ON_HOLD

constexpr int hueplusplus::sensors::ZLLSwitch::c_ON_HOLD = 1001
static

Button 1 (ON) held.

◆ c_ON_INITIAL_PRESS

constexpr int hueplusplus::sensors::ZLLSwitch::c_ON_INITIAL_PRESS = 1000
static

Button 1 (ON) pressed.

◆ c_ON_LONG_RELEASED

constexpr int hueplusplus::sensors::ZLLSwitch::c_ON_LONG_RELEASED = 1003
static

Button 1 (ON) released long press.

◆ c_ON_SHORT_RELEASED

constexpr int hueplusplus::sensors::ZLLSwitch::c_ON_SHORT_RELEASED = 1002
static

Button 1 (ON) released short press.

◆ c_UP_HOLD

constexpr int hueplusplus::sensors::ZLLSwitch::c_UP_HOLD = 2001
static

Button 2 (DIM UP) held.

◆ c_UP_INITIAL_PRESS

constexpr int hueplusplus::sensors::ZLLSwitch::c_UP_INITIAL_PRESS = 2000
static

Button 2 (DIM UP) pressed.

◆ c_UP_LONG_RELEASED

constexpr int hueplusplus::sensors::ZLLSwitch::c_UP_LONG_RELEASED = 2003
static

Button 2 (DIM UP) released long press.

◆ c_UP_SHORT_RELEASED

constexpr int hueplusplus::sensors::ZLLSwitch::c_UP_SHORT_RELEASED = 2002
static

Button 2 (DIM UP) released short press.

◆ typeStr

constexpr const char * hueplusplus::sensors::ZLLSwitch::typeStr = "ZLLSwitch"
static

ZLLSwitch sensor type name.


The documentation for this class was generated from the following files: