Add the apps and widgets API - #1167
Merged
Merged
Conversation
The only app endpoints covered were next and prev, which left the whole app control surface unreachable. This adds the remaining four: apps() GET /device/apps app() GET /device/apps/:package activate_widget() PUT /device/apps/:pkg/widgets/:id/activate app_action() POST /device/apps/:pkg/widgets/:id/actions Apps and widgets are returned keyed by package name and widget ID, the way the device reports them, rather than as lists. The App, Widget and AppParameter models follow what the device actually sends. Three fields are optional for reasons worth recording: apps with no actions leave the key out entirely, trigger parameters carry no required flag, and widget visibility is only reported when listing all apps, not when fetching one. Actions are addressed by name with a free form params mapping, since each app declares its own actions and their parameters. Both are reported by apps() and app(), so callers can discover them. The fixtures are real responses from a LaMetric TIME (sa8, OS 3.2.7), which all four methods were verified against. Co-Authored-By: Claude Opus 5 <noreply@anthropic.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.
Proposed Changes
Only
nextandprevwere covered, which left the whole app control surface unreachable. This adds the remaining four endpoints:apps()GET /device/appsapp()GET /device/apps/:packageactivate_widget()PUT /device/apps/:pkg/widgets/:id/activateapp_action()POST /device/apps/:pkg/widgets/:id/actionsApps and widgets come back keyed by package name and widget ID, the way the device reports them, rather than converted to lists — the keys are meaningful and are what the other endpoints take as path segments.
Actions are addressed by name with a free form
paramsmapping. Each app declares its own actions and their parameter specs, and both are reported byapps()andapp(), so callers can discover what is available rather than having it hardcoded here.Model notes
App,WidgetandAppParameterfollow what the device actually sends. Three fields are optional, each for a specific reason worth recording:App.actions— apps with no actions omit the key entirely, ascom.lametric.custommessagedoes.AppParameter.required— present on action parameters, absent on trigger parameters.Widget.visible— only reported byGET /device/apps, not byGET /device/apps/:package. Theapp()docstring points atapps()for visibility, and both cases are covered by tests.Widget.settingsisdict[str, Any], since its contents are specific to each app.The fixtures are real responses from a LaMetric TIME (model
sa8, OS 3.2.7). All six of its apps parse, including the empty-actions and empty-parameter cases. All four methods were verified against that device: listing, fetching one app, activating a widget, and runningstopwatch.start,stopwatch.pauseandstopwatch.reset.app_action()carries apylint: disable=too-many-arguments, matching howdisplay()already handles the same limit.Related Issues
None.
🤖 Generated with Claude Code