A library to simplify the process of connecting to a Hue bridge and storing the credentials for future use.
- Initializes the Philips Hue SDK
- Searches for a Hue bridge over the network
- Handles PushLink authentication
- Stores the credentials returned by the Hue bridge in a temp. file
- Uses the stored credentials on subsequent executions of the library, so connecting is fast
Make the following changes to your build.gradle
file:
- Add
maven { url "https://jitpack.io" }
to therepositories
closure- NOTE: It's important that this is declared last in the the
repositories
closure
- NOTE: It's important that this is declared last in the the
- Add
compile 'com.github.todd-elvers:simple-hue-bridge-service:1.2.0'
to thedependencies
closure
The only class you need to call from this library is HueBridgeService
. This class will take care of
initializing the SDK, adding a hook to shutdown the SDK, authenticating with the bridge, and storing
the bridge credentials.
To initialize the HueBridgeService
simply provide the name of your application
and a callback that will be executed once the service has successfully connected to a bridge.
In Groovy:
HueBridgeService hueBridgeService = HueBridgeService.createWithBridgeConnectionCallback("<your-app-name>") {
// Callback that will execute when the bridge has connected
}
hueBridgeService.findAndConnectToBridge()
In Java:
HueBridgeService hueBridgeService = HueBridgeService.createWithBridgeConnectionCallback("<your-app-name>", () -> {
// Callback that will execute when the bridge has connected
});
hueBridgeService.findAndConnectToBridge();
When the HueBridgeService
instance is no longer of use, call hueBridgeService.shutdown()
to terminate the connection to the bridge.