Unable to play media to Homepod Mini

I just picked up a HomePod Mini hoping to use it in Home Assistant for announcements but I cannot get any media playback to work.

I was able to set it up successfully and controlling media with it works perfectly fine (e.g. start playback, volume, etc.)

HomePod is on firmware 17.3.
HA is on 2024.2.1

The error I get is:

Failed to call service media_player/play_media. no response to SETUP rtsp://192.168.1.36/3375721462 (RTSP/1.0)

Logs:

2024-02-16 16:16:49.542 ERROR (MainThread) [homeassistant.components.websocket_api.http.connection] [140051124707648] no response to SETUP rtsp://192.168.1.36/2342145127 (RTSP/1.0)
Traceback (most recent call last):
  File "/usr/local/lib/python3.12/site-packages/pyatv/support/http.py", line 463, in send_and_receive
    await pending_request.event.wait()
  File "/usr/local/lib/python3.12/asyncio/locks.py", line 212, in wait
    await fut
asyncio.exceptions.CancelledError

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/local/lib/python3.12/site-packages/pyatv/support/http.py", line 462, in send_and_receive
    async with async_timeout.timeout(timeout):
  File "/usr/local/lib/python3.12/site-packages/async_timeout/__init__.py", line 141, in __aexit__
    self._do_exit(exc_type)
  File "/usr/local/lib/python3.12/site-packages/async_timeout/__init__.py", line 228, in _do_exit
    raise asyncio.TimeoutError
TimeoutError

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/components/websocket_api/commands.py", line 240, in handle_call_service
    response = await hass.services.async_call(
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/core.py", line 2279, in async_call
    response_data = await coro
                    ^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/core.py", line 2316, in _execute_service
    return await target(service_call)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/helpers/service.py", line 892, in entity_service_call
    single_response = await _handle_entity_call(
                      ^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/helpers/service.py", line 962, in _handle_entity_call
    result = await task
             ^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/components/apple_tv/media_player.py", line 304, in async_play_media
    await self.atv.stream.stream_file(media_id)
  File "/usr/local/lib/python3.12/site-packages/pyatv/core/facade.py", line 371, in stream_file
    await self.relay("stream_file")(
  File "/usr/local/lib/python3.12/site-packages/pyatv/protocols/raop/__init__.py", line 356, in stream_file
    await client.initialize(self.core.service.properties)
  File "/usr/local/lib/python3.12/site-packages/pyatv/protocols/raop/stream_client.py", line 337, in initialize
    await self._protocol.setup(self.timing_server.port, self.control_client.port)
  File "/usr/local/lib/python3.12/site-packages/pyatv/protocols/raop/protocols/airplayv2.py", line 108, in setup
    await self._setup_base(timing_server_port)
  File "/usr/local/lib/python3.12/site-packages/pyatv/protocols/raop/protocols/airplayv2.py", line 55, in _setup_base
    setup_resp = await self.rtsp.setup(
                 ^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/pyatv/support/rtsp.py", line 176, in setup
    return await self.exchange("SETUP", headers=headers, body=body)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/pyatv/support/rtsp.py", line 293, in exchange
    resp = await self.connection.send_and_receive(
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/pyatv/support/http.py", line 474, in send_and_receive
    raise TimeoutError(f"no response to {method} {uri} ({protocol})") from ex
TimeoutError: no response to SETUP rtsp://192.168.1.36/2342145127 (RTSP/1.0)
2024-02-16 16:17:00.067 WARNING (MainThread) [homeassistant.components.apple_tv] Connection lost to Apple TV "Flat Living Room"
2024-02-16 16:17:40.687 ERROR (MainThread) [homeassistant.components.websocket_api.http.connection] [140051124707648] 
Traceback (most recent call last):
  File "/usr/local/lib/python3.12/site-packages/pyatv/protocols/mrp/protocol.py", line 275, in _receive
    await semaphore.acquire()
  File "/usr/local/lib/python3.12/asyncio/locks.py", line 386, in acquire
    await fut
asyncio.exceptions.CancelledError

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/components/websocket_api/commands.py", line 240, in handle_call_service
    response = await hass.services.async_call(
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/core.py", line 2279, in async_call
    response_data = await coro
                    ^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/core.py", line 2316, in _execute_service
    return await target(service_call)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/helpers/service.py", line 892, in entity_service_call
    single_response = await _handle_entity_call(
                      ^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/helpers/service.py", line 962, in _handle_entity_call
    result = await task
             ^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/components/apple_tv/media_player.py", line 461, in async_media_play
    await self.atv.remote_control.play()
  File "/usr/local/lib/python3.12/site-packages/pyatv/core/facade.py", line 71, in play
    return await self.relay("play")()
           ^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/pyatv/protocols/mrp/__init__.py", line 365, in play
    await self._send_command(CommandInfo_pb2.Play)
  File "/usr/local/lib/python3.12/site-packages/pyatv/protocols/mrp/__init__.py", line 334, in _send_command
    resp = await self.protocol.send_and_receive(messages.command(command, **kwargs))
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/pyatv/protocols/mrp/protocol.py", line 262, in send_and_receive
    return await self._receive(identifier, timeout)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/pyatv/protocols/mrp/protocol.py", line 274, in _receive
    async with async_timeout.timeout(timeout):
  File "/usr/local/lib/python3.12/site-packages/async_timeout/__init__.py", line 141, in __aexit__
    self._do_exit(exc_type)
  File "/usr/local/lib/python3.12/site-packages/async_timeout/__init__.py", line 228, in _do_exit
    raise asyncio.TimeoutError
TimeoutError

Any ideas I could try would be most welcome.

This was due to my restrictive network setup.

I had to open up all my ports on the HA machine for the HomePod and now it works. If anyone knows which exact ports I need that would be great :+1:

May depend on what you are trying to play, but try 554 and 3689.
May need others 8000-8999 and 42000-42999 …
If the first 2 don’t work, may be easier (or alternative) to just allow all ports to the specific HomePod Mini IP address.
Check out this:

1 Like

I had the same issue and I finally managed to get it working.

First I looked at the firewall logs in Proxmox but I couldn’t see any request using the ports listed in the Apple documentation, what I saw were IPv4 attempts using UDP on port 45129 which was likely randomly picked by Home Assistant.

After allowing any UDP request coming from the HomePod Mini I had a different error:
Failed to perform the action media_player/play_media. HTTPSConnectionPool(host='homeassistant.internal', port=443): Max retries exceeded with url: /api/tts_proxy/hVH5FvV34Sk282_SF90xvA.mp3 (Caused by NameResolutionError("<urllib3.connection.HTTPSConnection object at 0x7f0d2ccc87d0>: Failed to resolve 'homeassistant.internal' ([Errno -2] Name does not resolve)"))

This was due to a missing DNS entry on my Unbound server, and after adding it the DNS could resolve it properly (if you don’t have a DNS and don’t use HTTPS you can probably use http://homeassistant.local in Settings → System → Network) but I got yet another error:
Failed to perform the action media_player/play_media. HTTPSConnectionPool(host='homeassistant.internal', port=443): Max retries exceeded with url: /api/tts_proxy/7OT1kYTYsuV1QBPjT2-fBQ.mp3 (Caused by SSLError(SSLCertVerificationError(1, '[SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: self-signed certificate in certificate chain (_ssl.c:1032)')))

This is because I’m using HTTPS with a self-signed certificates so to avoid the issue completely I setup a Ngnix reverse-proxy with the following configuration:

# /etc/nginx/sites-available/reverse-proxy
server {
        listen 80;
        server_name _;

        location / {
                proxy_pass https://192.168.1.246:443;
                proxy_ssl_verify off;

                # access_log /var/log/nginx/proxy_access.log;
                # error_log /var/log/nginx/proxy_error.log debug;
        }
}

Then went to Home Assistant → Settings → System → Network and changed the first Home Assistant URL from https://homeassistant.internal to http://homeassistant-http.internal and created another DNS entry for that host pointing to the Ngnix server.