Apple TV integration - Airport Express Gen 2

Just got an airport express gen 2, added it via the ATV integration but it doesnt act as an proper media player?

Airplaying music shows idle
It doesnt appear in the media browser

Anyone else using these with HA?

It will only show whatever you stream to it from Home Assistant. AirPlay doesn’t support fetching metadata when someone else is streaming unfortunately.

Do you know why airport express units dont appear in the media browser?

Hello, I know I’m coming in late but I had a question for you. I’m not so much concerned with the metadata and the proper state when airplaying from another device, but did you control of the volume from HA at least? That’s the only part I’m trying to chase.

Yes you can control volume of HomePods from HA. Never tried TV as I use an AVR.

1 Like

But…that’s not entirely true, it does work for my Apple TVs. That’s how Home Assistant is able to see what my Apple TVs are playing when I’m AirPlaying to them from my phone:

image

That works for all the Apple TVs. However I have one AirPort Express, and when that’s included in what I’m Airplaying to (all via the AirPlay 2 protocol), it shows as Idle in HA:

image

I would think, since both devices are compatible with Airplay 2, that the Airport Express could also be “read” by Home Assistant. Has anyone figured out a way around this?

No, metadata from Apple TVs and HomePods are retrieved via another protocol. Said protocol is tunneled over AirPlay 2 since tvOS 15, but not supported by non-Apple devices nor the AirPort Express. So the metadata you see comes does not come from Airaplay, but rather Media Remote Protocol (MRP).

And as a clarification: there is no known way of retrieving what is playing from AirPlay alone. It is however possible to “retrieve” current play state via status flags in the zeroconf. This is not supported by pyatv yet though.

Very helpful, thanks. That explains the behavior.

So I guess if I want full metadata/automation control over AirPlay endpoints, all the endpoints have to be Apple TVs…well that’s frustrating.

Thanks. In my case, I’m using two Airport Express A1392 and I’m trying to get them to behave somewhat like our Sonos devices. My use case; we have “Home” iPads from each floor that are set to airplay to each room in the house. Even when airplaying from one device, anyone with HA on their phones, PC, etc. can hit the volume slider for their room and make an adjustment as it suits them.

I was able to integrate my AEs into HA, but unfortunately, while I can give volume commands, they don’t actually work. Trying to use the slider yields this:

Other methods of control don’t yield anything at all. I’m still researching to see if this is possible. If not, those units will have to get replaced with Ikea Symfonisk offerings, I suppose.

Ah sorry I misunderstood. I thought you meant HomePods.

Can’t say I have tried increasing the volume via HA on my AirPort Express. I have it setup so when it detects playback a binary sensor is triggered to switch on the speaker it’s connected to but I normally just used my phone as I’m air playing content from there.

That’s okay. It’s good to know that homepods are an option in the future.

And yeah, adjusting from the source device is definitely the primary. I just wanted to add some secondary options for those who may need to change the volume, but aren’t holding the source device.

As I said earlier, you can only change volume from the device streaming audio (I.e. you cannot change volume for someone else that is streaming). This is a limitation in AirPlay. The fact that it works with for instance the HomePod is because another protocol it used for changing volume.

I understand that, but I wanted to be thorough and leave behind a little more info for the next person like me who’s googling around.

As I said earlier, you can only change volume from the device streaming audio

Respectfully, before I posted anything in this thread, there was no explicit use of the word “volume” so I just wanted to make doubly sure before I went shopping for new devices.

1 Like

I never knew that either, but that explains some other behavior I was struggling with about a month ago. Also very disappointing because I was hoping to make an all-AirPlay setup, but if other people can’t control zone volumes if they didn’t start the music, that’s a major downside.

@postlund You clearly know a lot about the underlying protocols because you’ve helped implement integrations, but to most people it’s just “Airplay”, and I can speak from experience when I say that it’s really confusing what AirPlay does and doesn’t support in different combinations. It’s hard to know what’s maybe a bug in an integration and what’s an “AirPlay” limitation.

I think I might start an AirPlay function matrix document to try and lay all this out, and put it on GitHub or something. From what I’ve seen here and in other threads, there is different control behavior depending on which device is streaming the music (iOS vs tvOS vs HomePod…OS?), and which device(s) are receiving the music. There is different metadata/information available depending on the receiving device type (aTV vs AE vs other). Need to figure out how to put this into a table or something.

1 Like

OK I took a first swing at defining what is expected for various Airplay devices/scenarios. Much of this is based on my own experience, so please feel free to comment/open PRs if you have something to add or correct. I will try to find a format for it that’s easier to read so you don’t have to side-scroll.

2 Likes

I have the same issue with 2nd Gen Airport Express devices (I have 3 of them). Each one lets me pair itself to HA, but they don’t display the status (their state is always “Idle”), they don’t respond to commands (mostly showing errors like in the comment I’m replying to). The minimum I need is to know whether it’s playing something or not - because I want to automate turning the speakers they’re connected to, when the music starts playing.

You can’t, it will only display whenever you stream something in Home Assistant. It’s a limitation in AidPlay (you can’t see or control what someone else is streaming).

1 Like

I don’t care what they’re streaming, just want to know if something is playing. It’s a shame it doesn’t work for ApEx, but I can get similar info from Apple TV or Music.app on a Mac

So I’m using docker and run this to install required files into the container

docker exec -it homeassistant apk add --no-cache libplist libplist-util

Then I have the following binary_sensor configured

- platform: command_line
  unique_id: kitchen_speaker
  name: 'Airplay Speaker'
  command: 'expr $(echo "obase=16;" `curl -s -X GET IPADDRESS:7000/info | plistutil | grep "<key>statusFlags</key>" -A1 | grep -Eo "[0-9]{1,4}"` | bc | cut -c1) - 4 > /dev/null 2>&1 && echo "true" || echo "false"'
  payload_on: 'true'
  payload_off: 'false'
  scan_interval: 10

This then toggles on when playing. I can use to switch on a plug connected to some speakers.