Use state-aware icons for Wear OS shortcut tiles#6618
Use state-aware icons for Wear OS shortcut tiles#6618kdavh wants to merge 4 commits intohome-assistant:mainfrom
Conversation
There was a problem hiding this comment.
It seems you haven't yet signed a CLA. Please do so here.
Once you do that we will be able to review and accept this pull request.
Thanks!
|
Please take a look at the requested changes, and use the Ready for review button when you are done, thanks 👍 |
There was a problem hiding this comment.
Pull request overview
Updates Wear OS shortcut tiles to use state-aware icons (via full entity state + Entity.getIcon()), improving visual accuracy (e.g., locked vs unlocked) while preserving the existing domain-based fallback behavior.
Changes:
- Fetch full entity state for shortcut entries when building tile resources and resolve icons via
Entity.getIcon() - Keep domain-based fallback icon resolution when entity fetch fails
- Add a Wear changelog entry describing the user-visible change
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 3 comments.
| File | Description |
|---|---|
| wear/src/main/kotlin/io/homeassistant/companion/android/tiles/ShortcutsTile.kt | Concurrently fetches full entity state and uses state-aware icon resolution for tile resources |
| app/src/main/res/xml/changelog_master.xml | Documents the Wear shortcut tile icon behavior change |
| Resources.Builder() | ||
| .setVersion(entities.toString()) | ||
| .apply { | ||
| entities.map { entity -> | ||
| // Find icon and create Bitmap | ||
| val iconIIcon = getIcon( | ||
| entity.icon, | ||
| entity.domain, | ||
| this@ShortcutsTile, | ||
| ) | ||
| // Find icon: try state-aware icon from full entity, fall back to domain icon | ||
| val fullEntity = entityMap[entity.entityId] | ||
| val iconIIcon = if (fullEntity != null) { | ||
| fullEntity.getIcon(this@ShortcutsTile) | ||
| } else { |
There was a problem hiding this comment.
Resources.Builder().setVersion(entities.toString()) is still based only on the shortcut list, but the actual icon bitmaps now depend on live entity state. This can cause cached resources to keep showing an outdated icon (e.g., locked icon after unlocking) because the resource version may not change. Consider including relevant state in the version (or otherwise forcing a refresh/update strategy) so state changes invalidate cached resources.
|
Has the situation described in #2045 get resolved now? Last I recall we could not reliably add this because its very easy for the state to get out of sync. |
Shortcut tiles previously used the same icon regardless of entity state. This switches to using Entity.getIcon(), which returns state-specific icons for locks, fans, switches, covers, and more — matching the behavior already used in complications and other tiles. Full entities are fetched in parallel to minimize latency, with a graceful fallback to the original domain-only icon if a fetch fails. Custom icons set in Home Assistant are still respected.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
- Rethrow CancellationException instead of swallowing it in catch block - Add Timber.w logging for failed entity fetches - Wrap entity fetch in serverManager.isRegistered() check Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
3bdbd68 to
9189b98
Compare
…t tiles Include entity state in the tile resource version string so Wear OS invalidates cached icon bitmaps when entity state changes. Previously the version only reflected which entities were configured, causing stale icons to persist indefinitely. Also add a loading indicator (progress clock icon) when an entity is tapped. The tile polls for state changes at 1s and 4s after tap, clearing the loading state once the entity state has changed or after a 5s timeout. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Summary
Shortcut tiles on Wear OS currently use domain-based fallback icons that don't reflect entity state. For example, a lock entity always shows the same padlock icon regardless of whether it's locked or unlocked.
This change fetches full entity state from the server when building tile resources, and uses
Entity.getIcon()to resolve state-aware icons. The fallback to domain-based icons viagetIcon(icon, domain, context)is preserved when the full entity can't be fetched.Before: All lock entities show the same generic padlock icon.
After: Locked entities show a closed padlock, unlocked entities show an open padlock (and similar state-aware icons for other domains like covers, fans, etc.).
Checklist
Screenshots
Fallback icons (no entity state):
State-aware icons (locked vs unlocked):
Any other notes
Entity.getIcon()throughout the app — state-aware icons are only used when the entity doesn't have a customiconattribute set.asyncto minimize latency.