Skip to content

mrp: report a HomePod stereo pair leader as powered on - #2917

Open
teriu wants to merge 1 commit into
postlund:masterfrom
teriu:mrp-homepod-stereo-pair-power
Open

teriu wants to merge 1 commit into
postlund:masterfrom
teriu:mrp-homepod-stereo-pair-power

Conversation

@teriu

@teriu teriu commented Oct 4, 2026 •

Copy link
Copy Markdown

Fixes #2916

Problem

A HomePod mini that leads a stereo pair reports PowerState.Off while it is playing over AirPlay. Its DEVICE_INFO_MESSAGE carries logicalDeviceCount: 0, and MrpPower._get_power_state maps 0 to Off. Playback state and metadata do arrive correctly. In Home Assistant's apple_tv integration, though, an Off player is shown as off, and all of its media attributes are dropped, so a playing pair looks switched off.

The leader's DEVICE_INFO while playing (IDs redacted):

name: "L HomePod"
modelID: "AudioAccessory5,1"
systemBuildVersion: "24J361"
logicalDeviceCount: 0
groupName: "Main Bedroom"
isGroupLeader: false
isAirplayActive: true
clusterID: "<redacted>"
clusterLeaderID: "<this device's own deviceUID>"
clusterType: 1
isClusterAware: true

Change

When logicalDeviceCount is 0, _get_power_state now also checks the cluster fields. A cluster-aware device whose clusterLeaderID equals its own deviceUID is reported as On. The pair's other member, and an Apple TV that is asleep (which sends no cluster fields), still report Off, so the existing behaviour for Apple TVs is unchanged.

Testing

  • New parametrised unit test, 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.
  • Full suite: 1251 passed, 6 skipped. Run on Python 3.13; 3.14 wasn't available on the machine I used.
  • black and isort are clean. flake8, mypy and pylint report the same as on master.
  • Against real hardware with atvremote --scan-hosts <leader> power_state playing, on a HomePod mini stereo pair running software 27.0 (24J361):
power_state playing
leader, master PowerState.Off Playing, full metadata
leader, this branch PowerState.On Playing, full metadata
follower, this branch PowerState.Off Playing

Open question

The follower also reports Device state: Playing with 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

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

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

HomePod stereo pair always reports PowerState.Off (logicalDeviceCount is 0 on the cluster leader)

1 participant