Expose now-playing, album colours and tempo as switch attributes#2
Merged
Conversation
While an area is syncing, the switch now publishes extra state attributes so a dashboard card can reflect what's playing -- recolour to the extracted album palette and lock a visualizer to the song: - album_colors: the engine's extracted album palette as #rrggbb (when Colour = Album colours) - bpm: detected tempo once the rhythm model locks - media_title / media_artist / entity_picture: now-playing from the followed player - source_player: the media_player being followed The session computes this snapshot in its render loop and only fires a state write when the values actually change (per track / on tempo lock), so it stays quiet for the state machine and recorder. The attributes disappear when the area stops syncing. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
engabd11
added a commit
that referenced
this pull request
Jun 10, 2026
PR #2 exposes album colours, tempo and now-playing on the switch, but not the playback position. The companion Hue Music Sync Card's visualizer locks a beat grid to the song from media_position + media_position_updated_at, and reads them off the switch when no media_player is configured in the card. Mirror those two anchors from the followed player into the published state. They re-anchor only on seek / play-pause / track-change, so the recorder isn't spammed and the card extrapolates the live position between updates. Co-Authored-By: Claude Opus 4.8 <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.
What
While an area is syncing, the area's
switchnow publishes extra stateattributes describing what's playing, so a dashboard card can recolour itself to
the album and lock a visualizer to the song:
album_colors#rrggbb(when Colour = Album colours).bpmmedia_title/media_artist/entity_picturesource_playermedia_playerthe sync is following.Why
The companion Hue Music Sync Card
colours itself from what's playing. It can extract album colours client-side from
the art, but the integration already extracts a vivid palette (k-means) and
tracks tempo — exposing those lets the card use the exact colours driving the
lights and run its bars at the real BPM, instead of approximating.
How
SyncSessioncomputes apublic_statesnapshot (coordinator.py) in itsrender loop and stores the latest
BeatGridand extracted album palette._maybe_publish()runs ~1 Hz and only fires a state write when the valueschange (per track / on tempo lock), so it stays quiet for the state machine
and recorder. Album colours also publish immediately when extraction completes.
SyncManager.area_attributes()returns the active session's snapshot (emptywhen idle);
HueMusicSyncSwitch.extra_state_attributessurfaces it, so theattributes appear only while syncing and disappear on stop.
No changes to the audio/effects/DTLS core. README updated with the attribute
table.
Notes / review points
None).bpmis rounded to an integer and gated onBeatGrid.locked, so it doesn'tchurn while the tempo estimate settles.
excluderecommendation or move them behind ahomeassistant.helpers.entityrecorder filter — they're already change-gated so the volume is low.
🤖 Generated with Claude Code