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