Repository navigation
Conversation
The leader of a HomePod stereo pair sends logicalDeviceCount: 0 in its DEVICE_INFO_MESSAGE even while it is playing, so _get_power_state returned PowerState.Off. Clients that treat Off as "nothing to show", such as Home Assistant, then drop the pair's playback state and metadata, although both are delivered correctly. When the count is zero, also check the cluster fields: a cluster-aware device whose clusterLeaderID is its own deviceUID is the active member of the pair, so report it as On. The other member, and an Apple TV that is asleep (which sends no cluster fields), still report Off. Verified against a HomePod mini stereo pair (software 27.0, build 24J361): the leader went from PowerState.Off to PowerState.On while playing, with metadata unchanged. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This branch has not been deployed
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.
Fixes #2916
Problem
A HomePod mini that leads a stereo pair reports
PowerState.Offwhile it is playing over AirPlay. Its DEVICE_INFO_MESSAGE carrieslogicalDeviceCount: 0, andMrpPower._get_power_statemaps 0 to Off. Playback state and metadata do arrive correctly. In Home Assistant'sapple_tvintegration, though, an Off player is shown asoff, and all of its media attributes are dropped, so a playing pair looks switched off.The leader's DEVICE_INFO while playing (IDs redacted):
Change
When
logicalDeviceCountis 0,_get_power_statenow also checks the cluster fields. A cluster-aware device whoseclusterLeaderIDequals its owndeviceUIDis reported asOn. The pair's other member, and an Apple TV that is asleep (which sends no cluster fields), still reportOff, so the existing behaviour for Apple TVs is unchanged.Testing
test_power_state_from_device_info, covers: count 1 → On, count 0 → Off, pair leader → On, pair follower → Off, and a sleeping Apple TV with no cluster fields → Off. The leader case fails without this change.master.atvremote --scan-hosts <leader> power_state playing, on a HomePod mini stereo pair running software 27.0 (24J361):power_stateplayingmasterPowerState.OffPowerState.OnPowerState.OffOpen question
The follower also reports
Device state: Playingwith metadata. I left it as Off, to keep the change narrow and because clients control a pair through its leader. Happy to treat any cluster member as On instead, if you'd prefer that.🤖 Generated with Claude Code