hueplusplus
1.0.0
|
A simple and easy to use library for Philips Hue Lights.
To start searching for a Hue Bridge you will need to choose an IHttpHandler and create one. The options are a WinHttpHandler (for windows) or a LinHttpHandler (for linux or linux-like).
Then create a BridgeFinder object with the handler. The handler is needed, because it tells the finder which functions to use to communicate with a bridge or your local network. After that you can call findBridges(), which will return a vector containing the ip and mac address of all found Bridges.
At this point you may want to decide whether to use a shared state cache model or keep the default settings.
If you have found the Bridge you were looking for, you can then move on with the authentication process. To get a new username from the Bridge (for now) you simply call getBridge(bridges[<index>]), where index is your preferred Bridge from the part Searching for Bridges. This requires the user to press the link button.
If you on the other hand already have a username you can add your bridge like so
If you do not want to use the BridgeFinder or you already know the ip and username of your bridge you have the option to create your own Bridge object. Here you will need to provide the ip address, the port number, a username and an HttpHandler
If you have your Bridge all set up, you can now control its lights. For that create a new Light object and call lights().get(<id>) on your bridge object to get a reference to a specific light, where id is the id of the light set internally by the Hue Bridge.
If you don't know the id of a specific light or want to get an overview over all lights that are controlled by your bridge, you can get a vector containing them by calling getAll() on your bridge object. If no lights are found the vector will be empty.
If you now want to control a light, call a specific function of it.
But keep in mind that some light types do not have all functions available. So you might call a specific function, but nothing will happen. For that you might want to check what type of a light you are controlling. For that you can call the function getColorType(), which will return a ColorType.
There's also a new way to check whether specific functions of a light are available:
These will either return true(light has specified function) or false(light lacks specified function).
If you want to build the library you can use cmake (at least version 3.8). First create a build folder and then execute cmake.
Then compile the code with make. If you are inpatient use the option -j<number>, where number specifies how many files are compiled at the same time. Note this number should not exceed the number of cores*2 of your machine.
If you want to install the library use
To remove it
If you have a project that already uses CMake you probably want to add the hueplusplus library directly in your cmake file. For that the best way is to use find_package(). When cmake finds the hueplusplus library you can then link against either the shared or static version of the library.
But this will only work if the hueplusplus library is already installed. To get around this problem there is a pretty awesome way. If you have the hueplusplus repository included in your project repository (as a submodule) or know where the folder lives you can do the following:
This will check if the hueplusplus library was found by find_package() and if not it will use the specified path to the library source and compile it during the build process.
If you additionally want to run the tests use cmake with the option -Dhueplusplus_TESTS=ON. Testing is done with Google gtest and gmock. Note that you wont need to install gtest/gmock yourself, because cmake will automatically download them and include them during the build. Since I added a custom target you will only need to call "make unittest" and the tests are compiled and executed.
If you also want to execute coverage tests you will need to install gcov and lcov yourself. To run the coverage test use