Add Philips Hue control tool example (examples/hue)#122
Open
bishwap wants to merge 1 commit into
Open
Conversation
Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Adds a new consumer Hue control tool as
examples/hue— a Light Phone 3 tool that connects to a Philips Hue bridge on the local network and turns lights off (the primary action), on, or toggles them individually. It's written entirely in the tool module using SDK primitives, mirroring the existingexamples/weatherstructure. No SDK/public-API changes and no new third-party dependencies — Ktor/OkHttp/Kotlinx Serialization/DataStore are already exposed transitively by:sdk:client.The three parts worth calling out (the rest is straightforward from the code):
1. Bridge HTTPS trust (
HueBridgeTls). The bridge is reached by LAN IP over HTTPS. Android (minSdk 33) blocks cleartext and the SDK-generated manifest gives no place to add a network-security config, so instead of HTTP we pin trust to Philips/Signify's published Hue root CAs and relax only hostname verification (the LAN IP never matches the cert's baked-in name; chain-pinning is the real trust boundary). Two Ktor clients are used:2. Hue v1 local API + link-button pairing (
HueApi). PairingPOST /apireturns[{"error":{"type":101}}]until the physical link button is pressed; that specific code becomes a "press the button, then tap Pair" retry prompt. State changes usePUT /lights/{id}/stateand, for ALL OFF, the special all-lights groupPUT /groups/0/action.3. State machine (
HueViewModel).Bridge IP + app key persist via DataStore (
HuePreferences); an unauthorized response auto-forgets the bridge and returns to discovery.Files
examples/hue/{build.gradle.kts, lighttool.toml}+settings.gradle.ktsregistrationHueModels,HueApi,HueBridgeTls,HuePreferences,HueViewModel,HueHomeScreenVerification
./gradlew :examples:hue:checkpasses — lint, tests, and the SDK's own plugin validation (allowed-dependency / banned-API checks). KSP generatesLightSdkRegistrywithHueHomeScreenas the@InitialScreen.