Allow choosing Live Activity progress bar fill direction - #5180
Conversation
Adds an optional progress_bar_direction field (increasing / decreasing) alongside progress_bar_color: - Static progress bars: decreasing renders the remaining portion (progress_max - progress) so the bar drains as progress advances; percent labels keep showing the raw progress value. - Timer progress bars: the field overrides the built-in default (countdown drains, bounded count-up fills). - Unrecognised values decode leniently and fall back to the default direction instead of failing the strict OS-side content-state decode. - Promoted through the local-push parser so both delivery flows carry it, and covered by contract, handler, and local-push promotion tests. - New "Battery - Decreasing Bar" sample with matching YAML output.
|
Found 6 unused localization strings in the codebase. Click to see detailsTo remove them, run the |
There was a problem hiding this comment.
Pull request overview
This PR extends Live Activity notification payloads to support an optional progress_bar_direction field (increasing / decreasing), enabling progress bars to visually fill or drain while keeping existing behavior unchanged when the field is omitted. It carries the field through both APNs content-state and the local-push promotion path, updates widget rendering to honor the direction, and adds test coverage plus a new in-app sample.
Changes:
- Add
progress_bar_directiontoHALiveActivityAttributes.ContentStatewith a case-insensitive resolver and a static-bar fill helper. - Update Live Activity UI (Lock Screen + Dynamic Island) to use direction-aware fill for static bars and to optionally override timer bar direction.
- Propagate and validate the new field across handler/parsers and add contract/handler/local-push tests + a settings sample and localization.
Reviewed changes
Copilot reviewed 12 out of 12 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| Tests/Shared/LocalPushManager.test.swift | Extends local-push promotion expectation to include progress_bar_direction. |
| Tests/Shared/LiveActivity/LiveActivityContractTests.swift | Adds contract coverage for encoding keys and lenient direction decoding + fill behavior. |
| Tests/Shared/LiveActivity/HandlerLiveActivityTests.swift | Ensures handler parsing includes progress_bar_direction and remains nil when absent. |
| Sources/SharedPush/Sources/NotificationParserLegacy.swift | Promotes progress_bar_direction from local-push data into homeassistant. |
| Sources/Shared/Resources/Swiftgen/Strings.swift | Adds SwiftGen accessors for the new settings sample strings. |
| Sources/Shared/Notifications/NotificationCommands/HandlerLiveActivity.swift | Parses and forwards progress_bar_direction into the Live Activity content state. |
| Sources/Shared/LiveActivity/HALiveActivityAttributes.swift | Introduces progressBarDirection, resolver enum, and progressBarFillFraction; wires Codable keys. |
| Sources/Extensions/Widgets/LiveActivity/HALockScreenView.swift | Uses direction-aware progressBarFillFraction and passes direction override to timer bar. |
| Sources/Extensions/Widgets/LiveActivity/HADynamicIslandView.swift | Same as lock screen: direction-aware static bar and timer override. |
| Sources/Extensions/Widgets/LiveActivity/HAActivityTimerProgressBar.swift | Adds optional direction override affecting ProgressView(timerInterval:) count direction. |
| Sources/App/Settings/LiveActivity/LiveActivitySettingsView.swift | Adds a “Battery · Decreasing Bar” sample and emits progress_bar_direction in YAML output. |
| Sources/App/Resources/en.lproj/Localizable.strings | Adds English strings for the new sample (title/summary/note). |
The iOS app (home-assistant/iOS#5180) adds an optional progress_bar_direction field ("increasing"/"decreasing") to the Live Activity content state. This server only forwards recognized content-state keys, so pass the new field through from both the flat data fields and the explicit content_state object. Co-authored-by: Claude <noreply@anthropic.com>
Summary
Adds an optional
progress_bar_directionfield (increasing/decreasing) to Live Activity notifications, alongside the existingprogress_bar_color.decreasingrenders the remaining portion (progress_max − progress), so the bar drains as progress advances. Percent labels keep showing the raw progress value.Screenshots
Not available.
Link to pull request in Documentation repository
Documentation: home-assistant/companion.home-assistant#
Any other notes
Omitting the field keeps existing behavior unchanged.