Welcome to PHue++, a set of C++ classes which encapsulate the Philips Hue Lights API as defined at https://developers.meethue.com for Windows. The Hue API is implemented as a RESTful interface. PHue++ uses the author's WinHTTPWrappers classes to provide the HTTP connectivity and JSON++ to handle the JSON parsing. All the functionality provided is all included in a C++ namespace called PhilipsHue and is included in one PHue++.h header file.
Usage |
Copyright |
History |
API Reference |
Contacting the Author |
v1.06 (5 June 2022)
v1.05 (7 November 2021)
v1.04 (1 March 2020)
v1.03 (18 December 2019)
v1.02 (12 October 2019)
v1.01 (28 April 2019)
v1.0 (13 January 2019)
The API consists of the following variables, functions and classes and their methods and variables
CErrorResponse::m_sAddress
CErrorResponse::m_sDescription
CErrorResponse::m_Type
CLightState::m_Alert
CLightState::m_Brightness
CLightState::m_BrightnessInc
CLightState::m_CT
CLightState::m_CTInc
CLightState::m_Effect
CLightState::m_Hue
CLightState::m_HueInc
CLightState::m_On
CLightState::m_Saturation
CLightState::m_SaturationInc
CLightState::m_TransitionTime
CLightState::m_XY
CLightState::m_XYInc
CLight::Delete
CLight::GetAlert
CLight::GetBrightness
CLight::GetColorMode
CLight::GetColorTemperature
CLight::GetEffect
CLight::GetHue
CLight::GetLuminaireUniqueID
CLight::GetManufacturerName
CLight::GetModelID
CLight::GetName
CLight::GetOn
CLight::GetReachable
CLight::GetSaturation
CLight::GetType
CLight::GetUniqueID
CLight::GetXY
CLight::ID
CLight::Refresh
CLight::Rename
CLight::Set
CLight::SetAlert
CLight::SetBrightness
CLight::SetColorTemperature
CLight::SetEffect
CLight::SetHue
CLight::SetOff
CLight::SetOn
CLight::SetSaturation
CLight::SetXY
CLight::m_LastResponse
CLight::m_LastState
CBridge::CreateNewUser
CBridge::DeleteUser
CBridge::GetConfiguration
CBridge::GetDescriptionXML
CBridge::GetFullState
CBridge::GetLight
CBridge::GetLights
CBridge::GetNewLights
CBridge::HasLight
CBridge::Initialize
CBridge::IsErrorResponse
CBridge::SearchNewLights
CBridge::m_Connection
CBridge::m_LastLights
CBridge::m_LastResponse
CBridge::m_sUsername
Remarks
g_GamutA is an instance of type std::array<std::pair<float, float>, 3> and contains the three cartesian coordinates representing Gamut A as described at https://developers.meethue.com/develop/get-started-2/core-concepts/#colors-get-more-complicated.
Remarks
g_GamutB is an instance of type std::array<std::pair<float, float>, 3> and contains the three cartesian coordinates representing Gamut B as described at https://developers.meethue.com/develop/get-started-2/core-concepts/#colors-get-more-complicated.
Remarks
g_GamutC is an instance of type std::array<std::pair<float, float>, 3> and contains the three cartesian coordinates representing Gamut C as described at https://developers.meethue.com/develop/get-started-2/core-concepts/#colors-get-more-complicated.
Remarks
This class is used to contain one specific error instance as returned from the Philips Hue API. An array of these will be returned in failures from the Hue API.
Remarks
This member variable is of type std::wstring and contains the logical API address associated with the error.
CErrorResponse::m_sDescription
Remarks
This member variable is of type std::wstring and contains a text description associated with the error.
Remarks
This member variable is an enum of type of ERROR_TYPE and contains an identifier for the error as described at https://developers.meethue.com/develop/hue-api/error-messages/.
uint32_t KelvinToMired(uint32_t kelvin)
Return Value
Will contain the Mired converted value
Parameters
kelvin The color temperature to convert in degrees kelvin.
Remarks
A simple function which converts from Kelvin to Mired (aka “reciprocal megakelvin) as described at https://developers.meethue.com/develop/get-started-2/core-concepts/#colors-get-more-complicated.
uint32_t MiredToKelvin(uint32_t mired)
Return Value
Will contain the kelvin converted value
Parameters
mired The color temperature to convert in mired (aka “reciprocal megakelvin).
Remarks
A simple function which converts from Mired to Kelvin as described at https://developers.meethue.com/develop/get-started-2/core-concepts/#colors-get-more-complicated.
std::pair<float, float> RGBToXY(COLORREF color)
Return Value
A pair of floating point values representing the converted value. The "first" member variable of the pair will contain the X value and the "second" member variable will contain the Y value
Parameters
color A standard Windows rpresentation of a RGB color
Remarks
Allows conversion from the RGB color space to the XY color space. This code is based on the Python code at https://github.com/benknight/hue-python-rgb-converter.
COLORREF XYToRGB(float x, float y, float brightness, const std::array<std::pair<float, float>, 3>& gamut = g_GamutB)
Return Value
A standard windows color representation of the XY color.
Parameters
x The x value of the color
y This y value of the color.
brightness This brightness value of the color.
gamut An array of three cartesian coordinates which represent the color gamut triangle to use for the conversion. The default value for this parameter will be an array instance representing "Gamut B" as described at https://developers.meethue.com/develop/get-started-2/core-concepts/#colors-get-more-complicated.
Remarks
Allows conversion from the XY color space to the RGB color space. This code is based on the Python code at https://github.com/benknight/hue-python-rgb-converter.
COLORREF HSLToRGB(float h, float s, float l)
Return Value
A standard windows color representation of the HSL color.
Parameters
h The hue component of the color in the range [0, 1]
s The saturation component of the color in the range [0, 1]
l The luminance component of the color in the range [0, 1]
Remarks
Allows conversion from the HSL color space to the RGB color space. This code is based on the Javascript code at https://stackoverflow.com/questions/2353211/hsl-to-rgb-color-conversion.
std::array<float, 3> RGBToHSL(COLORREF color)
Return Value
An array containing the converted HSL color. The first element will contain the hue, the second element will contain the saturation and the third element will contain the luminance component of the color. All component values will be in the range [0, 1]
Parameters
color A standard windows color representation of the color to convert.
Remarks
Allows conversion from the RGB color space to the HSL color space. This code is based on the Javascript code at https://stackoverflow.com/questions/2353211/hsl-to-rgb-color-conversion.
HRESULT UPnPDiscover(_Inout_ std::vector<std::pair<std::string, std::string>>& devices, DWORD dwTimeout = 5, LPCSTR pszSearchTarget = "ssdp:all", LPCSTR pszUserAgent = nullptr, HANDLE hCancel = nullptr);
Return Value
A standard HRESULT value. Failures could be because of socket creation problems, failing to send the UPnP request over the socket or socket read errors.
Parameters
devices Upon successful return of this array this will contain the UPnP devices found. For each item in the array, the "first" element of the pair will contain the "Location" UPnP header which will be the IP address of the device, while the "second" element of the pair will contain the "Server" UPnP header of the device.
dwTimeout The time in seconds to monitor for UPnP broadbcasts
pszSearchTarget The value to pass to the "ST" UPnP request. This controls what devices to look for using UPnP.
pszUserAgent If a non null value is provided for this parameter, then a USER-AGENT header will this value will be included in the UPnP request.
hCancel If a non null parameter is provided for this parameter, then client code can cancel the search prematurely from a different thread by calling SetEvent or PulseEvent on this handle.
Remarks
This function issues a IPv4 UPnP request to search for devices on the local network. Philips Hue devices are discoverable using UPnP and this function can be used in your application to find these devices.
This class represents all the attributes of a light which can be set via the Hue API using the CLight::Set method.
Remarks
m_Alert is of type enum class ALERT and can have the values "NOT_SET", "NONE", "SELECT" or "LSELECT". This value corresponds to the "alert" attribute as described at https://developers.meethue.com/develop/hue-api/lights-api/#set-light-state.
Remarks
m_Brightness is of type std::optional<uint8_t>. If a value is provided in this value then it is used during the set light state API call. This value corresponds to the "bri" attribute as described at https://developers.meethue.com/develop/hue-api/lights-api/#set-light-state.
Remarks
m_BrightnessInc is of type std::optional<int16_t>. If a value is provided in this value then it is used during the set light state API call. This value corresponds to the "bri_inc" attribute as described at https://developers.meethue.com/develop/hue-api/lights-api/#set-light-state.
Remarks
m_CT is of type std::optional<uint16_t>. If a value is provided in this value then it is used during the set light state API call. This value corresponds to the "ct" attribute as described at https://developers.meethue.com/develop/hue-api/lights-api/#set-light-state.
Remarks
m_CTInc is of type std::optional<int32_t>. If a value is provided in this value then it is used during the set light state API call. This value corresponds to the "ct_inc" attribute as described at https://developers.meethue.com/develop/hue-api/lights-api/#set-light-state.
Remarks
m_Effect is of type enum class EFFECT and can have the values "NOT_SET", "NONE", "COLORLOPP". This value corresponds to the "effect" attribute as described at https://developers.meethue.com/develop/hue-api/lights-api/#set-light-state.
Remarks
m_Hue is of type std::optional<uint16_t>. If a value is provided in this value then it is used during the set light state API call. This value corresponds to the "hue" attribute as described at https://developers.meethue.com/develop/hue-api/lights-api/#set-light-state.
Remarks
m_HueInc is of type std::optional<int32_t>. If a value is provided in this value then it is used during the set light state API call. This value corresponds to the "hue_inc" attribute as described at https://developers.meethue.com/develop/hue-api/lights-api/#set-light-state.
Remarks
m_On is of type std::optional<bool>. If a value is provided in this value then it is used during the set light state API call. This value corresponds to the "on" attribute as described at https://developers.meethue.com/develop/hue-api/lights-api/#set-light-state.
Remarks
m_Saturation is of type std::optional<uint8_t>. If a value is provided in this value then it is used during the set light state API call. This value corresponds to the "sat" attribute as described at https://developers.meethue.com/develop/hue-api/lights-api/#set-light-state.
Remarks
m_SaturationInc is of type std::optional<int16_t>. If a value is provided in this value then it is used during the set light state API call. This value corresponds to the "sat_inc" attribute as described at https://developers.meethue.com/develop/hue-api/lights-api/#set-light-state.
Remarks
m_TransitionTime is of type std::optional<uint16_t>. If a value is provided in this value then it is used during the set light state API call. This value corresponds to the "transitiontime" attribute as described at https://developers.meethue.com/develop/hue-api/lights-api/#set-light-state.
Remarks
m_XY is of type std::optional<std::pair<float, float>>. If a value is provided in this value then it is used during the set light state API call. This value corresponds to the "xy" attribute as described at https://developers.meethue.com/develop/hue-api/lights-api/#set-light-state.
Remarks
m_XYInc is of type std::optional<std::pair<float, float>>. If a value is provided in this value then it is used during the set light state API call. This value corresponds to the "xy_inc" attribute as described at https://developers.meethue.com/develop/hue-api/lights-api/#set-light-state.
This class represents an actual bulb / light in the Hue API. You can obtain a usable instance of one using the CBridge::GetLight method.
HRESULT Delete(std::vector<CErrorResponse>& errors);
Return Value
A standard HRESULT value.
Parameters
errors If the API call fails and there is an error in the JSON response, then this parameter will contain all the parsed error values.
Remarks
This method deletes a light from the bridge. This method corresponds to the API call https://developers.meethue.com/develop/hue-api/lights-api/#del-lights.
HRESULT GetAlert(CLightState::ALERT& alert);
Return Value
A standard HRESULT value.
Parameters
alert Upon successful return from this method, this will contain the last "alert" value parsed from m_LastState response through the Refresh method.
Remarks
Returns the last "alert" value received for this light.
HRESULT GetBrightness(uint8_t& brightness);
Return Value
A standard HRESULT value.
Parameters
brightness Upon successful return from this method, this will contain the last "bri" value parsed from m_LastState response through the Refresh method.
Remarks
Returns the last "bri" value received for this light.
HRESULT GetColorMode(std::wstring& sColorMode);
Return Value
A standard HRESULT value.
Parameters
sColorMode Upon successful return from this method, this will contain the last "colormode" value parsed from m_LastState response through the Refresh method.
Remarks
Returns the last "colormode" value received for this light.
HRESULT GetColorTemperature(uint16_t& colorTemp);
Return Value
A standard HRESULT value.
Parameters
colorTemp Upon successful return from this method, this will contain the last "ct" value parsed from m_LastState response through the Refresh method.
Remarks
Returns the last "ct" value received for this light.
HRESULT GetEffect(CLightState::EFFECT& effect);
Return Value
A standard HRESULT value.
Parameters
effect Upon successful return from this method, this will contain the last "effect" value parsed from m_LastState response through the Refresh method.
Remarks
Returns the last "effect" value received for this light.
HRESULT GetHue(uint16_t& hue);
Return Value
A standard HRESULT value.
Parameters
hue Upon successful return from this method, this will contain the last "hue" value parsed from m_LastState response through the Refresh method.
Remarks
Returns the last "hue" value received for this light.
HRESULT GetLuminaireUniqueID(std::wstring& sLuminaireUniqueID);
Return Value
A standard HRESULT value.
Parameters
sLuminaireUniqueID Upon successful return from this method, this will contain the last "luminaireuniqueid" value parsed from m_LastState response through the Refresh method.
Remarks
Returns the last "luminaireuniqueid" value received for this light.
HRESULT GetManufacturerName(std::wstring& sManufacturerName);
Return Value
A standard HRESULT value.
Parameters
sManufacturerName Upon successful return from this method, this will contain the last "manufacturername" value parsed from m_LastState response through the Refresh method.
Remarks
Returns the last "manufacturername" value received for this light.
HRESULT GetModelID(std::wstring& sModelID);
Return Value
A standard HRESULT value.
Parameters
sModelID Upon successful return from this method, this will contain the last "modelid" value parsed from m_LastState response through the Refresh method.
Remarks
Returns the last "modelid" value received for this light.
HRESULT GetName(std::wstring& sName);
Return Value
A standard HRESULT value.
Parameters
sName Upon successful return from this method, this will contain the last "name" value parsed from m_LastState response through the Refresh method.
Remarks
Returns the last "name" value received for this light.
HRESULT GetOn(bool& bOn);
Return Value
A standard HRESULT value.
Parameters
bOn Upon successful return from this method, this will contain the last "on" value parsed from m_LastState response through the Refresh method.
Remarks
Returns the last "on" value received for this light.
HRESULT GetReachable();
Return Value
A standard HRESULT value.
Parameters
bReachable Upon successful return from this method, this will contain the last "reachable" value parsed from m_LastState response through the Refresh method.
Remarks
Returns the last "reachable" value received for this light.
HRESULT GetSaturation(uint8_t& saturation);
Return Value
A standard HRESULT value.
Parameters
saturation Upon successful return from this method, this will contain the last "sat" value parsed from m_LastState response through the Refresh method.
Remarks
Returns the last "sat" value received for this light.
HRESULT GetType(std::wstring& sType);
Return Value
A standard HRESULT value.
Parameters
sType Upon successful return from this method, this will contain the last "type" value parsed from m_LastState response through the Refresh method.
Remarks
Returns the last "type" value received for this light.
HRESULT GetUniqueID(std::wstring& sUniqueID);
Return Value
A standard HRESULT value.
Parameters
sUniqueID Upon successful return from this method, this will contain the last "uniqueid" value parsed from m_LastState response through the Refresh method.
Remarks
Returns the last "uniqueid" value received for this light.
HRESULT GetXY(std::pair<float, float>& xy);
Return Value
A standard HRESULT value.
Parameters
xy Upon successful return from this method, this will contain the last "xy" value parsed from m_LastState response through the Refresh method.
Remarks
Returns the last "xy" value received for this light.
int ID();
Return Value
The numeric identifier of the light.
Remarks
This method returns the identifier of the light as known by the bridge. The return value to this method corresponds corresponds to the <id> parameter in the https://developers.meethue.com/develop/hue-api/lights-api/#get-attr-and-state API call.
HRESULT Refresh(std::vector<CErrorResponse>& errors);
Return Value
A standard HRESULT value.
Parameters
errors If the API call fails and there is an error in the JSON response, then this parameter will contain all the parsed error values.
Remarks
This method gets the latest state of the light from the bridge. This method corresponds to the API call https://developers.meethue.com/develop/hue-api/lights-api/#get-attr-and-state. The response to this API is stored in CLight::m_LastState and all the attributes in this response are made available by the various CLight::Get* methods.
HRESULT Rename(LPCSTR pszNewName, std::vector<CErrorResponse>& errors);
Return Value
A standard HRESULT value.
Parameters
pszNewName The new name of the light.
errors If the API call fails and there is an error in the JSON response, then this parameter will contain all the parsed error values.
Remarks
Renames the light. This method corresponds to the API call https://developers.meethue.com/develop/hue-api/lights-api/#set-light-attr-rename.
HRESULT Set(const CLightState& state, std::vector<CErrorResponse>& errors);
Return Value
A standard HRESULT value.
Parameters
state An instance of the CLightState class which contains the attributes which you want to set on the light.
errors If the API call fails and there is an error in the JSON response, then this parameter will contain all the parsed error values.
Remarks
This is the main method call to control a Philips Hue light. This method corresponds to the API call https://developers.meethue.com/develop/hue-api/lights-api/#set-light-state.
HRESULT SetAlert(CLightState::ALERT alert, std::vector<CErrorResponse>& errors);
Return Value
A standard HRESULT value.
Parameters
alert The "alert" state to set the light to.
errors If the API call fails and there is an error in the JSON response, then this parameter will contain all the parsed error values.
Remarks
This is a simple helper function which just sets the "alert" attribute for the light. Internally this method creates a CLightState instance and then call the CLight::Set method.
HRESULT SetBrightness(uint8_t brightness, std::vector<CErrorResponse>& errors);
Return Value
A standard HRESULT value.
Parameters
brightness The "alert" value to set the light to.
errors If the API call fails and there is an error in the JSON response, then this parameter will contain all the parsed error values.
Remarks
This is a simple helper function which just sets the "bri" attribute for the light. Internally this method creates a CLightState instance and then call the CLight::Set method.
HRESULT SetColorTemperature(uint16_t colorTemp, std::vector<CErrorResponse>& errors);
Return Value
A standard HRESULT value.
Parameters
colorTemp The "ct" value to set the light to.
errors If the API call fails and there is an error in the JSON response, then this parameter will contain all the parsed error values.
Remarks
This is a simple helper function which just sets the "ct" attribute for the light. Internally this method creates a CLightState instance and then call the CLight::Set method.
HRESULT SetEffect(CLightState::EFFECT effect, std::vector<CErrorResponse>& errors);
Return Value
A standard HRESULT value.
Parameters
effect The "effect" value to set the light to.
errors If the API call fails and there is an error in the JSON response, then this parameter will contain all the parsed error values.
Remarks
This is a simple helper function which just sets the "effect" attribute for the light. Internally this method creates a CLightState instance and then call the CLight::Set method.
HRESULT SetHue(uint16_t hue, std::vector<CErrorResponse>& errors);
Return Value
A standard HRESULT value.
Parameters
hue The "hue" value to set the light to.
errors If the API call fails and there is an error in the JSON response, then this parameter will contain all the parsed error values.
Remarks
This is a simple helper function which just sets the "hue" attribute for the light. Internally this method creates a CLightState instance and then call the CLight::Set method.
HRESULT SetOff(std::vector<CErrorResponse>& errors);
Return Value
A standard HRESULT value.
Parameters
errors If the API call fails and there is an error in the JSON response, then this parameter will contain all the parsed error values.
Remarks
This is a simple helper function which just turns a light off. Internally this method creates a CLightState instance and then call the CLight::Set method.
HRESULT SetOn(std::vector<CErrorResponse>& errors);
Return Value
A standard HRESULT value.
Parameters
errors If the API call fails and there is an error in the JSON response, then this parameter will contain all the parsed error values.
Remarks
This is a simple helper function which just turns a light on. Internally this method creates a CLightState instance and then call the CLight::Set method.
HRESULT SetSaturation(uint8_t saturation, std::vector<CErrorResponse>& errors);
Return Value
A standard HRESULT value.
Parameters
saturation The "sat" value to set the light to.
errors If the API call fails and there is an error in the JSON response, then this parameter will contain all the parsed error values.
Remarks
This is a simple helper function which just sets the "sat" attribute for the light. Internally this method creates a CLightState instance and then call the CLight::Set method.
HRESULT SetXY(const std::pair<float, float>& xy, std::vector<CErrorResponse>& errors);
Return Value
A standard HRESULT value.
Parameters
xy The "xy" value to set the light to.
errors If the API call fails and there is an error in the JSON response, then this parameter will contain all the parsed error values.
Remarks
This is a simple helper function which just sets the "xy" attribute for the light. Internally this method creates a CLightState instance and then call the CLight::Set method.
Remarks
m_LastResponse is of type JSONPP::CValue. This variable contains the last JSON parsed response from the bridge through the CLight class.
Remarks
m_LastState is of type JSONPP::CValue. This variable contains the last JSON parsed response from the bridge from the CLight::Refresh call.
This class represents a connection to the Philips Hue Bridge device.
HRESULT CreateNewUser(LPCSTR pszUserName, std::wstring& sClientKey, std::vector<CErrorResponse>& errors);
Return Value
A standard HRESULT value.
Parameters
pszUserName The Username to pass to the API to create.
sClientKey Upon successful return from this method, this will contain the client key which must be provided to the bridge to authenticate
errors If the API call fails and there is an error in the JSON response, then this parameter will contain all the parsed error values.
Remarks
To successfuly use any API against the bridge a new user needs to be created. This method corresponds to the API call https://developers.meethue.com/develop/hue-api/7-configuration-api/#create-user.
HRESULT DeleteUser(LPCSTR pszUsername, _In_z_ LPCSTR pszClientKey, std::vector<CErrorResponse>& errors);
Return Value
A standard HRESULT value.
Parameters
pszUsername The username to remove from the bridge's whitelist.
pszClientKey The associated client key for the username.
errors If the API call fails and there is an error in the JSON response, then this parameter will contain all the parsed error values.
Remarks
This deletes a user from the bridge. It is the corrolary method to the CBridge::CreateNewUser method. This method corresponds to the API call https://developers.meethue.com/develop/hue-api/7-configuration-api/#del-user-from-whitelist.
HRESULT GetConfiguration(std::vector<CErrorResponse>& errors);
Return Value
A standard HRESULT value.
Parameters
errors If the API call fails and there is an error in the JSON response, then this parameter will contain all the parsed error values.
Remarks
This method corresponds to the API call https://developers.meethue.com/develop/hue-api/7-configuration-api/#get-configuration. The fully parsed response to this API will be stored in CBridge::m_LastResponse.
HRESULT GetDescriptionXML(std::string& sResponse);
Return Value
A standard HRESULT value.
Parameters
sResponse If Upon successful return from this method, this will contain the XML descriptor file text. Client code is then free to parse this XML to extract the data it wants. Example data you might want from this XML is to verify that this UPnP device is a Philips Hue device and also the icon image associated with the device for display purposes.
Remarks
As part of the hue Bridge discovery process, once you have got the IP address of the bridge, you can use this method call to UPnP xml descriptor file for the device.
HRESULT GetFullState(std::vector<CErrorResponse>& errors);
Return Value
A standard HRESULT value.
Parameters
errors If the API call fails and there is an error in the JSON response, then this parameter will contain all the parsed error values.
Remarks
This method corresponds to the API call https://developers.meethue.com/develop/hue-api/7-configuration-api/#get-full-state. The fully parsed response to this API will be stored in CBridge::m_LastResponse.
HRESULT GetLight(int nID, CLight& light);
Return Value
A standard HRESULT value.
Parameters
nID The numeric identifier of the light to get.
light Upon successful return from this method, this will contain a instance of the CLight class which you can then use to control the light.
Remarks
This method is the main way to obtain a CLight instance via the PHue++ class framework.
HRESULT GetLights(std::vector<CErrorResponse>& errors);
Return Value
A standard HRESULT value.
Parameters
errors If the API call fails and there is an error in the JSON response, then this parameter will contain all the parsed error values.
Remarks
This method corresponds to the API call https://developers.meethue.com/develop/hue-api/lights-api/#get-all-lights. The fully parsed response to this API will be stored in CBridge::m_LastResponse.
HRESULT GetNewLights(std::vector<int>& newLights, std::wstring& sLastScan, std::vector<CErrorResponse>& errors);
Return Value
A standard HRESULT value.
Parameters
newLights Upon successful return this will contain a array of the light identifiers which have been found.
sLastScan Upon successful return this will contain the "Lastscan" value in the response.
errors If the API call fails and there is an error in the JSON response, then this parameter will contain all the parsed error values.
Remarks
This method corresponds to the API call https://developers.meethue.com/develop/hue-api/lights-api/#get-new-lights. The fully parsed response to this API will be stored in CBridge::m_LastResponse.
bool HasLight(int nID);
Return Value
true if the specified light identifier exists from the last call to CBridge::GetLights, otherwise false
Parameters
nID The numeric light identifier to check to see if it exists
Remarks
This is a simple helper method which parses the last response to CBridge::GetLights to see if the specified light exists.
HRESULT Initialize(const WinHTTPWrappers::CSession& session, _In_z_ LPCWSTR pwszServerName, _In_ INTERNET_PORT nServerPort = INTERNET_DEFAULT_PORT);
Return Value
A standard HRESULT value.
Parameters
session The WinHTTP session wrapper class to use to initialize the WinHTTP connection with.
pwszServerName The IP address or hostname of the bridge to initialize the WinHTTP connection with.
nServerPort The port to connect to the bridge on. This defaults to the standard HTTP port of 80.
Remarks
To setup the connection to the Hue Bridge via the author's WinHTTPWrappers class framework, you first must call this method to specify the address and port number of the bridge device.
static HRESULT IsErrorResponse(const std::string& sResponse, bool& bError, std::vector<CErrorResponse>& errors);
Return Value
A standard HRESULT value.
Parameters
sResponse XThe JSON response from the bridge to check.
bError Upon successful return from this method, this parameter will be set to "true" if the response is an error response and "false" if it is not.
errors If this method return "bError" as true, then this parameter will contain all the parsed error values.
Remarks
This is a helper method used by the various CBridge methods which check the API response for logical errors.
HRESULT SearchNewLights(std::vector<CErrorResponse>& errors);
Return Value
A standard HRESULT value.
Parameters
errors If the API call fails and there is an error in the JSON response, then this parameter will contain all the parsed error values.
Remarks
This method corresponds to the API call https://developers.meethue.com/develop/hue-api/lights-api/#search-for-new-lights. The fully parsed response to this API will be stored in CBridge::m_LastResponse.
Remarks
m_Connection is of type WinHTTPWrappers::CConnection. This variable encapsulates the WinHTTP connection using to the bridge.
Remarks
m_LastLight is of type JSONPP::CValue. This variable contains the last parsed response from the CBridge::GetLights method call.
Remarks
m_LastResponse is of type JSONPP::CValue. This variable contains the last JSON parsed response from the bridge through the CBridge class.
Remarks
m_sClientKey is of type std::wstring. You should set this variable to the sClientKey parameter from a successful return from the CBridge::CreateNewUser method prior to calling any Hue API's which require a white listed user.
PJ Naughter
Email: pjna@naughter.com
Web: http://www.naughter.com
6 June
2022