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

Daylight sensor to detect sunrise and sunset. More...

#include <hueplusplus/Sensor.h>

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

Public Member Functions

 DaylightSensor (Sensor sensor)
 Construct from generic sensor. More...
 
bool isOn () const
 Check if the 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...
 
void setBatteryState (int percent)
 Set battery state. More...
 
void setCoordinates (const std::string &latitude, const std::string &longitude)
 Set GPS coordinates for the calculation. More...
 
bool isConfigured () const
 Check whether coordinates are configured. More...
 
int getSunriseOffset () const
 Get time offset in minutes to sunrise. More...
 
void setSunriseOffset (int minutes)
 Set sunrise offset time. More...
 
int getSunsetOffset () const
 Get time offset in minutes to sunset. More...
 
void setSunsetOffset (int minutes)
 Set sunset offset time. More...
 
bool isDaylight () const
 Check whether it is daylight or not. 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 const char * typeStr = "Daylight"
 Daylight 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

Daylight sensor to detect sunrise and sunset.

Every bridge has a daylight sensor always available.

Constructor & Destructor Documentation

◆ DaylightSensor()

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

Construct from generic sensor.

Member Function Documentation

◆ getBatteryState()

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

Get battery state.

Returns
Battery state in percent
Exceptions
nlohmann::json::out_of_rangewhen sensor has no battery state.

◆ getLastUpdated()

time::AbsoluteTime hueplusplus::sensors::DaylightSensor::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.

◆ getSunriseOffset()

int hueplusplus::sensors::DaylightSensor::getSunriseOffset ( ) const

Get time offset in minutes to sunrise.

The daylight is true if it is offset minutes after sunrise.

◆ getSunsetOffset()

int hueplusplus::sensors::DaylightSensor::getSunsetOffset ( ) const

Get time offset in minutes to sunset.

The daylight is false if it is offset minutes after sunset.

◆ hasBatteryState()

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

Check whether the sensor has a battery state.

◆ isConfigured()

bool hueplusplus::sensors::DaylightSensor::isConfigured ( ) const

Check whether coordinates are configured.

There is no way to retrieve the configured coordinates.

◆ isDaylight()

bool hueplusplus::sensors::DaylightSensor::isDaylight ( ) const

Check whether it is daylight or not.

◆ isOn()

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

Check if the sensor is on.

Sensors which are off do not change their status

◆ setBatteryState()

void hueplusplus::sensors::DaylightSensor::setBatteryState ( int  percent)

Set battery state.

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

◆ setCoordinates()

void hueplusplus::sensors::DaylightSensor::setCoordinates ( const std::string &  latitude,
const std::string &  longitude 
)

Set GPS coordinates for the calculation.

Parameters
latitudeDecimal latitude coordinate "DDD.DDDD{N|S}" with leading zeros ending with N or S. "none" to reset. (Empty string is null, which may be used instead of none in the future)
longitudeLongitude coordinate (same format as latitude), ending with W or E
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::DaylightSensor::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

◆ setSunriseOffset()

void hueplusplus::sensors::DaylightSensor::setSunriseOffset ( int  minutes)

Set sunrise offset time.

Parameters
minutesMinutes from -120 to 120
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

◆ setSunsetOffset()

void hueplusplus::sensors::DaylightSensor::setSunsetOffset ( int  minutes)

Set sunset offset time.

Parameters
minutesMinutes from -120 to 120
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

◆ typeStr

constexpr const char * hueplusplus::sensors::DaylightSensor::typeStr = "Daylight"
static

Daylight sensor type name.


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