mikebrady / shairport-sync

AirPlay and AirPlay 2 audio player
Other
7.3k stars 574 forks source link

HomeKit Support? #1382

Closed Hoseasack closed 2 years ago

Hoseasack commented 2 years ago

When I set up SharePort-Sync on my Pi, it shows up as a new accessory in the Home app. But whenever I try to add it to my home, it fails instantly. I don't know if this is supposed to happen or if I did something wrong?

charlesomer commented 2 years ago

Hi, which version are you running, you might need to update. ‘shairport-sync -V’ should tell you the version 😊

Hoseasack commented 2 years ago

I'm running 4.1-dev-128-g4cb485d2-AirPlay2-OpenSSL-Avahi-ALSA-soxr-sysconfdir:/etc

mikebrady commented 2 years ago

Thanks. FWIW it's working fine for me on iOS 15.2.

mikebrady commented 2 years ago

As a matter of interest, did you build Shairport Sync yourself or is it in a Docker image?

charlesomer commented 2 years ago

I remember some people had to restart their iPhones before it would go through the sequence correctly, might be worth a try if you haven’t already :)

Hoseasack commented 2 years ago

I built it myself.

Hoseasack commented 2 years ago

I remember some people had to restart their iPhones before it would go through the sequence correctly, might be worth a try if you haven’t already :)

I've tried that already. Though I can add it to a new Home with no hubs.

fade2metal commented 2 years ago

I have the same issue and this is the debug output:

117.912413028 "rtsp.c:5193" Connection 4: new connection from address:4938:49440 to self at address2:7000.
0.455956198 "rtsp.c:1939" pair-add cb for 7D1E9113-E91F-41EC-AE16-B66BB142C100
0.005380573 "rtsp.c:1967" pair-list cb

Then the iPhone / iPad tells me that the device could not be added. Any ideas?

mikebrady commented 2 years ago

Thanks for the post. Have you tried restarting the iPhone?

Also, maybe you could tell us the versions of the software involved?

fade2metal commented 2 years ago

I restarted the iPhone and iPad several times but no luck.

This is the version I use: 4.1-dev-107-g3705d8e2-AirPlay2-OpenSSL-Avahi-ALSA-soxr-sysconfdir:/etc

mikebrady commented 2 years ago

Thanks. Are the iPhone and iPad up to date?

fade2metal commented 2 years ago

I tried with iPhone 12 pro on 15.2 and iPad Air 2 on 15.2 an iPad Air 1 on 12.5.5.

mikebrady commented 2 years ago

Thanks again. I'm afraid I'm out of ideas or suggestions... Maybe someone else who has had similar difficulties could chime in...

charlesomer commented 2 years ago

4.1-dev-107-g3705d8e2-AirPlay2-OpenSSL-Avahi-ALSA-soxr-sysconfdir:/etc

Whilst I don’t think it would change much, it might be worth updating to the latest version: ‘4.1-dev-147-g636ccf98’. You could also try using the docker image to see if that works.

fade2metal commented 2 years ago

I updated to the latest version but it didn't change anything.

Couldn't manage to get the Docker image running. I always get errors with the avahi daemon (Connection refused) or errors that the port is already blocked.

mikebrady commented 2 years ago

Another question. I've noticed that if a device has been providing an AP1 service and then, after rebuilding, switches to offering an AP2 service, players seem to get confused for at least a few minutes afterwards. Could anything like that be happening?

fade2metal commented 2 years ago

Thanks a lot for the suggestions!

But this raspberry pi was directly built for AP2.

Is there any chance to get more logging output to see whats going on?

srtonz commented 2 years ago

Same issue here. Version string: 4.1-dev-166-g55c111ca-AirPlay2-alac-OpenSSL-Avahi-ALSA-soxr-sysconfdir:/etc

I don't really have much to add in terms of troubleshooting, except:

TXT Record for B827EB340349@Lounge photo_2022-01-15_21-20-36

TXT Record for Lounge photo_2022-01-15_21-20-40

mikebrady commented 2 years ago

Thanks a lot for the suggestions!

But this raspberry pi was directly built for AP2.

Is there any chance to get more logging output to see whats going on?

Sincere apologies, @fade2metal. Somehow I missed this.

Anyway, yes, there are some hints in the TROUBLESHOOTING.md guide.

mikebrady commented 2 years ago

Thanks @srtonz, @fade2metal, @Hoseasack, @charlesomer for all your help trying to track this thing down. It's a real mystery.

Same issue here. Version string: 4.1-dev-166-g55c111ca-AirPlay2-alac-OpenSSL-Avahi-ALSA-soxr-sysconfdir:/etc

I don't really have much to add in terms of troubleshooting, except:

  • I tried both an iOS 15.2 and an 15.1 device, exactly the same issue as others above. Streaming music directly from the Music app or other apps works without an issue.
  • I noticed that shows twice over bonjour - as <12_digit_hex_string>@name and as name. I'm not sure if this is the correct behaviour, but other devices on the network show only once. Attached screenshots.

This is intended behaviour -- one is in the _airplay._tcp service (AirPlay 2) and the other is in the _raop._tcp service (AirPlay 1), because Shairport Sync offers both services for backward compatibility. This is the same as other AirPlay 2 devices.

  • I tried disabling all network devices on my RPI except for one, restarting the avahi daemon and shairport-sync.
  • I disabled ipv6 just because (note screenshots were taken before that)
  • I noticed that after attempting to add the device to the home app it would not show on subsequent attempts. The most reliable way to get it to show again was use the Music app to play something to the device, disconnecting the music stream, then trying to add the device in the home app.
fade2metal commented 2 years ago

I found out that openairplay/airplay2-receiver works with HomeKit. I was able to add my raspberry pi with it, so there must be an issue in the Shairport-sync pair code.

Could someone who is able to add it to HomeKit please share the logs (from command "Shairport-sync -vu statistics") to see what should normally happen? In my case it stops working here: "rtsp.c:1961" pair-list cb

mikebrady commented 2 years ago

Thanks for that interesting information. As soon as time permits, I'll take another look at this... Here is a sample sequence to add a Shairport Sync device called "Living Audio System" to HomeKit with shairport-sync -vvu.

        64.803371156 "rtsp.c:5190" Connection 1: new connection from 192.168.1.18:52789 to self at 192.168.1.20:7000.
         0.007187209 "rtsp.c:1863" Connection 1: GET /info :: Content-Length 70
         0.000045833 "rtsp.c:1053" GET request
         0.000037917 "rtsp.c:1058"   Content Plist (as XML):
--
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
    <key>qualifier</key>
    <array>
        <string>txtAirPlay</string>
    </array>
</dict>
</plist>
--
         0.000230208 "rtsp.c:1053" GET /info:
         0.000055042 "rtsp.c:1058"   Content Plist (as XML):
--
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
    <key>qualifier</key>
    <array>
        <string>txtAirPlay</string>
    </array>
</dict>
</plist>
--
         0.000311250 "rtsp.c:1534" Connection 1: GET_INFO: Source AirPlay Version is: 600.8.1.
         0.000067291 "rtsp.c:1557" GET /info Stage 1: qualifier: txtAirPlay
         0.000623500 "rtsp.c:1053" GET /info Stage 1 Response:
         0.000140542 "rtsp.c:1058"   Content Plist (as XML):
--
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
    <key>audioLatencies</key>
    <array>
        <dict>
            <key>inputLatencyMicros</key>
            <integer>0</integer>
            <key>outputLatencyMicros</key>
            <integer>400000</integer>
            <key>type</key>
            <integer>100</integer>
        </dict>
        <dict>
            <key>audioType</key>
            <string>default</string>
            <key>inputLatencyMicros</key>
            <integer>0</integer>
            <key>outputLatencyMicros</key>
            <integer>400000</integer>
            <key>type</key>
            <integer>100</integer>
        </dict>
        <dict>
            <key>audioType</key>
            <string>media</string>
            <key>inputLatencyMicros</key>
            <integer>0</integer>
            <key>outputLatencyMicros</key>
            <integer>400000</integer>
            <key>type</key>
            <integer>100</integer>
        </dict>
        <dict>
            <key>audioType</key>
            <string>media</string>
            <key>inputLatencyMicros</key>
            <integer>0</integer>
            <key>outputLatencyMicros</key>
            <integer>400000</integer>
            <key>type</key>
            <integer>102</integer>
        </dict>
    </array>
    <key>keepAliveLowPower</key>
    <true/>
    <key>keepAliveSendStatsAsBody</key>
    <true/>
    <key>manufacturer</key>
    <string>Shairport Sync</string>
    <key>nameIsFactoryDefault</key>
    <false/>
    <key>protocolVersion</key>
    <string>1.1</string>
    <key>sdk</key>
    <string>AirPlay;2.0.2</string>
    <key>sourceVersion</key>
    <string>366.0</string>
    <key>statusFlags</key>
    <integer>4</integer>
    <key>txtAirPlay</key>
    <data>
    BWFjbD0wGmRldmljZWlkPTAwOjFjOjQyOjVjOjA4OjRlG2ZlYXR1cmVzPTB4NDA1RkNB
    MDAsMHgxQzM0MAdyc2Y9MHgwCWZsYWdzPTB4NBRtb2RlbD1TaGFpcnBvcnQgU3luYw1t
    YW51ZmFjdHVyZXI9DXNlcmlhbE51bWJlcj0NcHJvdG92ZXJzPTEuMQ1zcmN2ZXJzPTM2
    Ni4wJ3BpPWJlMDM1OTI1LWNlOGItNGQ4YS1hY2M3LTgyYzdiYjdkNzg5YihnaWQ9YmUw
    MzU5MjUtY2U4Yi00ZDhhLWFjYzctODJjN2JiN2Q3ODliBmdjZ2w9MENwaz1iZTczY2M2
    MGQ0MzJmMmM2OGNjOTc5NjYzYjcxZmQ2ZGM0NDUyN2EyYWNkYTIxNDRlNDY2MDZhZDdh
    YWU4Zjg0
    </data>
    <key>features</key>
    <integer>496155702053376</integer>
    <key>deviceID</key>
    <string>00:1c:42:5c:08:4e</string>
    <key>pi</key>
    <string>be035925-ce8b-4d8a-acc7-82c7bb7d789b</string>
    <key>name</key>
    <string>Living Audio System</string>
    <key>model</key>
    <string>Shairport Sync</string>
</dict>
</plist>
--
         0.000564375 "rtsp.c:1388" Responding with content of length 919
         0.034875417 "rtsp.c:2068" Connection 1: pair-setup Content-Length 9
         0.009077833 "rtsp.c:1053" pair-setup response
         0.000086417 "rtsp.c:1063"   No Content Plist. Content length: 409.
         0.000010000 "rtsp.c:1388" Responding with content of length 409
         0.078913541 "rtsp.c:2068" Connection 1: pair-setup Content-Length 457
         0.014190792 "rtsp.c:1053" pair-setup response
         0.000032542 "rtsp.c:1063"   No Content Plist. Content length: 69.
         0.000007541 "rtsp.c:1388" Responding with content of length 69
         0.021019959 "rtsp.c:1388" Responding with content of length 142
         0.008265666 "rtsp.c:1388" Responding with content of length 32
         0.011118542 "rtsp.c:2621" Connection 1: SETUP (AirPlay 2)
         0.000087958 "rtsp.c:2632" Connection 1 SETUP: No "streams" array has been found -- create an event thread and open a TCP port.
         0.000010584 "rtsp.c:2659" Connection 1: SETUP: a "None" setup detected.
         0.000012375 "rtsp.c:2666" Connection 1: Remote Control connection from 192.168.1.18:52789 to self at 192.168.1.20:7000.
         0.000019958 "rtsp.c:1053" SETUP "isRemoteControlOnly" message
         0.000093583 "rtsp.c:1058"   Content Plist (as XML):
--
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
    <key>timingProtocol</key>
    <string>None</string>
    <key>name</key>
    <string>OBFUSCATED</string>
    <key>isRemoteControlOnly</key>
    <true/>
    <key>osName</key>
    <string>iPhone OS</string>
    <key>sessionUUID</key>
    <string>AA15DEBE-B84E-48F5-BD58-51E7EA3CD448</string>
    <key>osBuildVersion</key>
    <string>19C63</string>
    <key>sourceVersion</key>
    <string>600.8.1</string>
    <key>osVersion</key>
    <string>15.2.1</string>
    <key>internalBuild</key>
    <false/>
    <key>deviceID</key>
    <string>OBFUSCATED</string>
    <key>model</key>
    <string>iPhone11,6</string>
    <key>diagnosticsAndUsage</key>
    <true/>
    <key>macAddress</key>
    <string>OBFUSCATED</string>
</dict>
</plist>
--
         0.000220500 "rtsp.c:2863" Connection 1: TCP Remote Control event port opened: 59149.
         0.000228292 "rtp.c:1513" Connection 1: AP2 Event Receiver started
         0.000261750 "rtsp.c:1053"  SETUP response
         0.000030833 "rtsp.c:1058"   Content Plist (as XML):
--
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
    <key>eventPort</key>
    <integer>59149</integer>
    <key>timingPort</key>
    <integer>0</integer>
</dict>
</plist>
--
         0.000009500 "rtsp.c:1388" Responding with content of length 76
         0.031017959 "rtsp.c:1863" Connection 1: GET /info :: Content-Length 0
         0.000079000 "rtsp.c:1053" GET request
         0.000003625 "rtsp.c:1063"   No Content Plist. Content length: 0.
         0.000003958 "rtsp.c:1053" GET /info:
         0.000002083 "rtsp.c:1063"   No Content Plist. Content length: 0.
         0.000110500 "rtsp.c:1053" GET /info Stage 2 Response
         0.000071709 "rtsp.c:1058"   Content Plist (as XML):
--
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
    <key>audioLatencies</key>
    <array>
        <dict>
            <key>inputLatencyMicros</key>
            <integer>0</integer>
            <key>outputLatencyMicros</key>
            <integer>400000</integer>
            <key>type</key>
            <integer>100</integer>
        </dict>
        <dict>
            <key>audioType</key>
            <string>default</string>
            <key>inputLatencyMicros</key>
            <integer>0</integer>
            <key>outputLatencyMicros</key>
            <integer>400000</integer>
            <key>type</key>
            <integer>100</integer>
        </dict>
        <dict>
            <key>audioType</key>
            <string>media</string>
            <key>inputLatencyMicros</key>
            <integer>0</integer>
            <key>outputLatencyMicros</key>
            <integer>400000</integer>
            <key>type</key>
            <integer>100</integer>
        </dict>
        <dict>
            <key>audioType</key>
            <string>media</string>
            <key>inputLatencyMicros</key>
            <integer>0</integer>
            <key>outputLatencyMicros</key>
            <integer>400000</integer>
            <key>type</key>
            <integer>102</integer>
        </dict>
    </array>
    <key>keepAliveLowPower</key>
    <true/>
    <key>keepAliveSendStatsAsBody</key>
    <true/>
    <key>manufacturer</key>
    <string>Shairport Sync</string>
    <key>nameIsFactoryDefault</key>
    <false/>
    <key>protocolVersion</key>
    <string>1.1</string>
    <key>sdk</key>
    <string>AirPlay;2.0.2</string>
    <key>sourceVersion</key>
    <string>366.0</string>
    <key>statusFlags</key>
    <integer>4</integer>
    <key>features</key>
    <integer>496155702053376</integer>
    <key>deviceID</key>
    <string>OBFUSCATED</string>
    <key>pi</key>
    <string>be035925-ce8b-4d8a-acc7-82c7bb7d789b</string>
    <key>name</key>
    <string>Living Audio System</string>
    <key>model</key>
    <string>Shairport Sync</string>
</dict>
</plist>
--
         0.000055750 "rtsp.c:1388" Responding with content of length 584
         0.006553416 "rtsp.c:1464" Connection 1: RECORD on Remote Control stream
         0.050517042 "rtsp.c:1933" pair-add cb for 8D07E423-A2F4-4794-8DF8-5330CBED296F
         0.000098667 "rtsp.c:1053" pair-add response
         0.000004333 "rtsp.c:1063"   No Content Plist. Content length: 3.
         0.000007875 "rtsp.c:1388" Responding with content of length 3
         0.009111542 "rtsp.c:1961" pair-list cb
         0.000083041 "rtsp.c:1053" pair-list response
         0.000006875 "rtsp.c:1063"   No Content Plist. Content length: 78.
         0.000011209 "rtsp.c:1388" Responding with content of length 78
         0.007712041 "rtsp.c:1053" POST /configure response:
         0.000052459 "rtsp.c:1058"   Content Plist (as XML):
--
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
    <key>Identifier</key>
    <string>be035925-ce8b-4d8a-acc7-82c7bb7d789b</string>
    <key>Enable_HK_Access_Control</key>
    <true/>
    <key>PublicKey</key>
    <data>
    vnPMYNQy8saMyXlmO3H9bcRFJ6Ks2iFE5GYGrXquj4Q=
    </data>
    <key>Device_Name</key>
    <string>Living Audio System</string>
    <key>Access_Control_Level</key>
    <integer>0</integer>
</dict>
</plist>
--
         0.000030583 "rtsp.c:1388" Responding with content of length 244
         0.012480917 "rtsp.c:1053" TEARDOWN: 
         0.000089916 "rtsp.c:1058"   Content Plist (as XML):
--
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict/>
</plist>
--
         0.000024875 "rtsp.c:2451" Connection 1: TEARDOWN a Remote Control stream connection.
         0.000015000 "rtsp.c:2454" Connection 1: TEARDOWN Delete Event Thread.
         0.000292875 "rtp.c:1508" Connection 1: AP2 Event Receiver Cleanup.
         0.000231167 "rtsp.c:2460" Connection 1: TEARDOWN Close Event Socket.
         0.000058000 "rtsp.c:2464" Connection 1: closing TCP event port 59149.
         0.000008792 "rtsp.c:2511" Connection 1: TEARDOWN phase two complete
         0.033683666 "rtsp.c:4664" Connection 1: rtsp_conversation_thread_func_cleanup_function called.
         0.000077459 "rtsp.c:2451" Connection 1: TEARDOWN a Remote Control stream connection.
         0.000005375 "rtsp.c:2460" Connection 1: TEARDOWN Close Event Socket.
         0.000076625 "rtsp.c:4695" Connection 1: terminating connection from 192.168.1.18:52789 to self at 192.168.1.20:7000.
         0.000343875 "rtsp.c:4754" Connection 1: Closed.
        59.654736903 "rtsp.c:730" Connection 1: deleted in cleanup.
fade2metal commented 2 years ago

Thank you so much for your debug output!

I have got pretty much the same output. Hard to tell what the issue really is.

mikebrady commented 2 years ago

Indeed it is — it’ll take some quiet troubleshooting to get it 🙄.

anurodhp commented 2 years ago

Had this problem on a rpi4 (ethernet, not wifi). Ended up on this ticket with the exact same symptoms. Also compiled it myself. Ultimately restarting shairport resolved the issue for me. I am using Eero for wifi but I know a lot of HomeKit oddities in general are wifi related. Are you on wired or wireless connection with your pi? Might be worth trying.

Hoseasack commented 2 years ago

I am using a wireless connection via Wi-Fi (5Ghz).

fade2metal commented 2 years ago

I tried ethernet, 5Ghz Wifi and 2,4Ghz Wifi. Didn't work :(

ghost commented 2 years ago

I also cannot add connection via HomeKit. Via Music app, no problems. However, I have noticed that it takes much longer to connect to shairport than it does to my homepod and LG TV, which was not the case with shairport airplay1

https://user-images.githubusercontent.com/55313117/153401773-2e3030a0-d4c4-4691-98bc-5e07affc0204.MOV

mikebrady commented 2 years ago

Thanks for the observation -- I have noticed that occasionally alright.

Altrec commented 2 years ago

I've pretty much quite the same issue. I build shairport-sync on an rpi2 and it shows up in my list on my iPhone. With this I can tell my Homepod mini to stream music to it, but I'm not able to tell it to my Homepod using my voice (siri). Also it doesn't show up in my home app. Might there be anything I'm missing?

Edit: Ok, I just stopped the music on the homepod and now it showed up....

ghost commented 2 years ago

Look here https://github.com/mikebrady/shairport-sync/issues/1442#issuecomment-1060709537

ghost commented 2 years ago

I would also like to add that this issue has been resolved with the latest version "I have noticed that it takes much longer to connect to shairport than it does to my homepod and LG TV, which was not the case with shairport airplay1"

I also cannot add connection via HomeKit. Via Music app, no problems. However, I have noticed that it takes much longer to connect to shairport than it does to my homepod and LG TV, which was not the case with shairport airplay1

IMG_0156.MOV

fade2metal commented 2 years ago

Thanks so much! Worked perfectly!

grappelli commented 2 years ago

I had the same or similar issue - could not add shairport-sync (current dev build) to homekit. I was also only able to connect properly from a homepod and not via iOS to airplay music.

After rebooting, rebuilding and reinstalling everything I kept encountering the same.

... At least, until I thought of rebooting my router...

That fixed all these issues for me.

Hoseasack commented 2 years ago

HomeKit support is now properly working for me! Also, joining speakers and AirPlaying from a signal device is now lightning fast! I did a complete reinstallation with the latest dev release. Thanks so much!