Base class for physical devices connected to the bridge (sensor or light).
More...
#include <hueplusplus/BaseDevice.h>
|
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...
|
|
|
| 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 ¤tState) |
| 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...
|
|
Base class for physical devices connected to the bridge (sensor or light).
◆ ~BaseDevice()
virtual hueplusplus::BaseDevice::~BaseDevice |
( |
| ) |
|
|
virtualdefault |
◆ BaseDevice() [1/2]
hueplusplus::BaseDevice::BaseDevice |
( |
int |
id, |
|
|
const std::shared_ptr< APICache > & |
baseCache |
|
) |
| |
|
protected |
Protected ctor that is used by subclasses, construct with shared cache.
- Parameters
-
id | Integer that specifies the id of this device |
baseCache | Cache of the ResourceList containing this device (must not be null). |
◆ BaseDevice() [2/2]
hueplusplus::BaseDevice::BaseDevice |
( |
int |
id, |
|
|
const HueCommandAPI & |
commands, |
|
|
const std::string & |
path, |
|
|
std::chrono::steady_clock::duration |
refreshDuration, |
|
|
const nlohmann::json & |
currentState |
|
) |
| |
|
protected |
Protected ctor that is used by subclasses.
- Parameters
-
id | Integer that specifies the id of this device |
commands | HueCommandAPI for communication with the bridge |
path | Base path for the resource type, ending with a '/'. Example: "/lights/" |
refreshDuration | Time between refreshing the cached state. |
currentState | Current state of the device, may be null. |
◆ getId()
int hueplusplus::BaseDevice::getId |
( |
| ) |
const |
|
virtual |
Const function that returns the id of this device.
- Returns
- integer representing the device id
◆ getManufacturername()
std::string hueplusplus::BaseDevice::getManufacturername |
( |
| ) |
const |
|
virtual |
Const function that returns the manufacturername of the device.
- Note
- Only working on bridges with versions starting at 1.7
- Returns
- String containing the manufacturername or an empty string when the function is not supported
◆ getModelId()
std::string hueplusplus::BaseDevice::getModelId |
( |
| ) |
const |
|
virtual |
Const function that returns the modelid of the device.
- Returns
- String containing the modelid
◆ getName() [1/2]
std::string hueplusplus::BaseDevice::getName |
( |
| ) |
|
|
virtual |
Function that returns the name of the device.
- Returns
- String containig the name of the device
- Exceptions
-
std::system_error | when system or socket operations fail |
HueException | when response contained no body |
HueAPIResponseException | when response contains an error |
nlohmann::json::parse_error | when response could not be parsed |
◆ getName() [2/2]
std::string hueplusplus::BaseDevice::getName |
( |
| ) |
const |
|
virtual |
Const function that returns the name of the device.
- Note
- This will not refresh the device state
- Returns
- String containig the name of the thing
◆ getProductname()
std::string hueplusplus::BaseDevice::getProductname |
( |
| ) |
const |
|
virtual |
Const function that returns the productname of the device.
- Note
- Only working on bridges with versions starting at 1.24
- Returns
- String containing the productname or an empty string when the function is not supported
◆ getSwVersion() [1/2]
std::string hueplusplus::BaseDevice::getSwVersion |
( |
| ) |
|
|
virtual |
Function that returns the software version of the device.
- Returns
- String containing the software version
- Exceptions
-
std::system_error | when system or socket operations fail |
HueException | when response contained no body |
HueAPIResponseException | when response contains an error |
nlohmann::json::parse_error | when response could not be parsed |
◆ getSwVersion() [2/2]
std::string hueplusplus::BaseDevice::getSwVersion |
( |
| ) |
const |
|
virtual |
Const function that returns the software version of the device.
- Note
- This will not refresh the device state
- Returns
- String containing the software version
◆ getType()
std::string hueplusplus::BaseDevice::getType |
( |
| ) |
const |
|
virtual |
Const function that returns the device type.
- Returns
- String containing the type
◆ getUId()
std::string hueplusplus::BaseDevice::getUId |
( |
| ) |
const |
|
virtual |
Const function that returns the uniqueid of the device.
- Note
- Only working on bridges with versions starting at 1.4
- Returns
- String containing the uniqueid or an empty string when the function is not supported
◆ refresh()
void hueplusplus::BaseDevice::refresh |
( |
bool |
force = false | ) |
|
|
virtual |
Refreshes internal cached state.
- Parameters
-
force | true forces a refresh, regardless of how long the last refresh was ago. false to only refresh when enough time has passed (needed e.g. when calling only const methods). |
- Exceptions
-
std::system_error | when system or socket operations fail |
HueException | when response contained no body |
HueAPIResponseException | when response contains an error |
nlohmann::json::parse_error | when response could not be parsed |
◆ sendPutRequest()
nlohmann::json hueplusplus::BaseDevice::sendPutRequest |
( |
const std::string & |
subPath, |
|
|
const nlohmann::json & |
request, |
|
|
FileInfo |
fileInfo |
|
) |
| |
|
protectedvirtual |
Utility function to send a put request to the device.
- Parameters
-
subPath | A path that is appended to the uri, note it should always start with a slash ("/") |
request | A nlohmann::json aka the request to send |
fileInfo | FileInfo from calling function for exception details. |
- Returns
- The parsed reply
- Exceptions
-
std::system_error | when system or socket operations fail |
HueException | when response contained no body |
HueAPIResponseException | when response contains an error |
nlohmann::json::parse_error | when response could not be parsed |
◆ setName()
bool hueplusplus::BaseDevice::setName |
( |
const std::string & |
name | ) |
|
|
virtual |
Function that sets the name of the device.
- Returns
- Bool that is true on success
- Exceptions
-
std::system_error | when system or socket operations fail |
HueException | when response contained no body |
HueAPIResponseException | when response contains an error |
nlohmann::json::parse_error | when response could not be parsed |
◆ setRefreshDuration()
void hueplusplus::BaseDevice::setRefreshDuration |
( |
std::chrono::steady_clock::duration |
refreshDuration | ) |
|
|
virtual |
Sets custom refresh interval for this device.
- Parameters
-
refreshDuration | The new minimum duration between refreshes. May be 0 or c_refreshNever. |
◆ id
int hueplusplus::BaseDevice::id |
|
protected |
holds the id of the device
◆ state
holds the current state of the device
The documentation for this class was generated from the following files: