core icon indicating copy to clipboard operation
core copied to clipboard

Media playback automation not working

Open 400HPMustang opened this issue 2 years ago • 5 comments
trafficstars

The problem

I have an automation that plays an mp3 file to my homepods on a schedule. . The file is stored locally. It was working fine up until this morning. As of this morning the file is not playing on any of the homepods. I'm noticing the following errors in the logs shortly after the automation runs.

Logger: homeassistant
Source: components/apple_tv/media_player.py:292
First occurred: February 12, 2023 at 11:59:05 AM (4 occurrences)
Last logged: 9:39:00 AM

Error doing job: Task exception was never retrieved
Traceback (most recent call last):
  File "/usr/local/lib/python3.10/site-packages/pyatv/support/http.py", line 390, in send_and_receive
    await event.wait()
  File "/usr/local/lib/python3.10/asyncio/locks.py", line 214, 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.10/site-packages/pyatv/support/http.py", line 389, in send_and_receive
    async with async_timeout.timeout(4):
  File "/usr/local/lib/python3.10/site-packages/async_timeout/__init__.py", line 129, in __aexit__
    self._do_exit(exc_type)
  File "/usr/local/lib/python3.10/site-packages/async_timeout/__init__.py", line 212, in _do_exit
    raise asyncio.TimeoutError
asyncio.exceptions.TimeoutError

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

Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 968, in async_request_call
    await coro
  File "/usr/src/homeassistant/homeassistant/helpers/service.py", line 720, in _handle_entity_call
    await result
  File "/usr/src/homeassistant/homeassistant/components/apple_tv/media_player.py", line 292, in async_play_media
    await self.atv.stream.stream_file(media_id)
  File "/usr/local/lib/python3.10/site-packages/pyatv/core/facade.py", line 392, in stream_file
    await self.relay("stream_file")(file, **kwargs)
  File "/usr/local/lib/python3.10/site-packages/pyatv/protocols/raop/__init__.py", line 352, in stream_file
    await client.initialize(self.core.service.properties)
  File "/usr/local/lib/python3.10/site-packages/pyatv/protocols/raop/raop.py", line 457, in initialize
    await self._setup_session()
  File "/usr/local/lib/python3.10/site-packages/pyatv/protocols/raop/raop.py", line 479, in _setup_session
    await self.rtsp.announce(
  File "/usr/local/lib/python3.10/site-packages/pyatv/support/rtsp.py", line 153, in announce
    response = await self.exchange(
  File "/usr/local/lib/python3.10/site-packages/pyatv/support/rtsp.py", line 265, in exchange
    resp = await self.connection.send_and_receive(
  File "/usr/local/lib/python3.10/site-packages/pyatv/support/http.py", line 393, in send_and_receive
    raise TimeoutError(f"no response to {method} {uri} ({protocol})") from ex
TimeoutError: no response to ANNOUNCE rtsp://10.107.112.240/325807200 (RTSP/1.0)

Logger: homeassistant.components.apple_tv
Source: components/apple_tv/__init__.py:169
Integration: Apple TV (documentation, issues)
First occurred: February 9, 2023 at 4:30:09 PM (29 occurrences)
Last logged: 9:30:13 AM

Connection lost to Apple TV "Office"
Connection lost to Apple TV "Dining Room"
Connection lost to Apple TV "Basement"
Connection lost to Apple TV "Bedroom"
Logger: pyatv.support.http
Source: runner.py:128
First occurred: February 8, 2023 at 1:30:04 PM (59 occurrences)
Last logged: 9:30:09 AM

Got response without having a request: HttpResponse(protocol='RTSP', version='1.0', code=200, message='OK', headers={'date': 'Mon, 13 Feb 2023 14:30:08 GMT', 'content-length': '0', 'server': 'AirTunes/675.4.1', 'cseq': '1'}, body='')
Got response without having a request: HttpResponse(protocol='RTSP', version='1.0', code=200, message='OK', headers={'date': 'Mon, 13 Feb 2023 14:30:08 GMT', 'content-length': '55', 'content-type': 'application/x-apple-binary-plist', 'server': 'AirTunes/675.4.1', 'cseq': '1789'}, body=b'bplist00\xd1\x01\x02Wstreams\xa0\x08\x0b\x13\x00\x00\x00\x00\x00\x00\x01\x01\x00\x00\x00\x00\x00\x00\x00\x03\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x14')
Got response without having a request: HttpResponse(protocol='RTSP', version='1.0', code=200, message='OK', headers={'date': 'Mon, 13 Feb 2023 15:30:04 GMT', 'content-length': '0', 'server': 'AirTunes/675.4.1', 'cseq': '1'}, body='')
Got response without having a request: HttpResponse(protocol='RTSP', version='1.0', code=200, message='OK', headers={'date': 'Mon, 13 Feb 2023 15:30:09 GMT', 'content-length': '0', 'server': 'AirTunes/675.4.1', 'cseq': '1'}, body='')
Got response without having a request: HttpResponse(protocol='RTSP', version='1.0', code=200, message='OK', headers={'date': 'Mon, 13 Feb 2023 15:30:09 GMT', 'content-length': '55', 'content-type': 'application/x-apple-binary-plist', 'server': 'AirTunes/675.4.1', 'cseq': '1790'}, body=b'bplist00\xd1\x01\x02Wstreams\xa0\x08\x0b\x13\x00\x00\x00\x00\x00\x00\x01\x01\x00\x00\x00\x00\x00\x00\x00\x03\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x14')

What version of Home Assistant Core has the issue?

core-2023.2.3

What was the last working version of Home Assistant Core?

2023.2.3

What type of installation are you running?

Home Assistant OS

Integration causing the issue

apple_tv

Link to integration documentation on our website

https://www.home-assistant.io/integrations/apple_tv

Diagnostics information

No response

Example YAML snippet

alias: Dogs - Out to potty schedule
description: Reminder to take the dogs out
trigger:
  - platform: time_pattern
    hours: /1
    minutes: "30"
condition:
  - condition: time
    after: "07:00:00"
    before: "20:00:00"
    weekday:
      - sun
      - mon
      - tue
      - wed
      - thu
      - fri
      - sat
action:
  - service: media_player.play_media
    data:
      media_content_id: http://10.107.112.240:8123/local/sounds/Notification2.mp3
      media_content_type: music
    target:
      entity_id: media_player.all_homepods
mode: single

Anything in the logs that might be useful for us?

No response

Additional information

No response

400HPMustang avatar Feb 13 '23 15:02 400HPMustang

Hey there @postlund, mind taking a look at this issue as it has been labeled with an integration (apple_tv) you are listed as a code owner for? Thanks!

Code owner commands

Code owners of apple_tv can trigger bot actions by commenting:

  • @home-assistant close Closes the issue.
  • @home-assistant rename Awesome new title Change the title of the issue.
  • @home-assistant reopen Reopen the issue.
  • @home-assistant unassign apple_tv Removes the current integration label and assignees on the issue, add the integration domain after the command.

(message by CodeOwnersMention)


apple_tv documentation apple_tv source (message by IssueLinks)

home-assistant[bot] avatar Feb 13 '23 15:02 home-assistant[bot]

Something that might help that I've noticed is that when the automations don't seem to play the TTS or the mp3 file they seem to be either "became unknown" or "turned off" and that's odd since the devices are always on and connected.

image

400HPMustang avatar Feb 22 '23 17:02 400HPMustang

I am having the same behavior as yours... Unexpected error for call_service at pos 4: no response to ANNOUNCE TimeoutError: no response to ANNOUNCE rtsp://192.168.4.13/4248748160 (RTSP/1.0)

The workaround I've been using so far is playing some music from my phone in the affected homepod.. then everything is back to normal.

I am not sure who changed this behavior.. HA or Apple.

jpconfessor avatar Feb 26 '23 17:02 jpconfessor

I think it is the apple TV integration. My guess is that it hasn't kept up with changes in dependencies.

dkkr23 avatar Feb 26 '23 20:02 dkkr23

I think it is the apple TV integration. My guess is that it hasn't kept up with changes in dependencies.

Makes sense.. and btw, I've just ran into your bug here: https://github.com/postlund/pyatv/issues/1931 I hope @postlund will find a solution for this, since it seems to break the whole player integration.

jpconfessor avatar Feb 26 '23 21:02 jpconfessor

I have the same issue... hope that there will be a fix soon 👍

u20p17 avatar Feb 28 '23 16:02 u20p17

are you guys using any workaround? I've tried to play twice, but the continue_on_error: true doesn't seems to work for this timeout error.

jpconfessor avatar Mar 02 '23 23:03 jpconfessor

I tried the same thing. Haven’t found a workaround either

dkkr23 avatar Mar 03 '23 00:03 dkkr23

I've done some testing from the home app and it appears to be linked to this beta firmware (16.4), since the home app itself is kind of broken when you try to control the homepod.. it gets out of sync easily, and when you try to skip songs it will only work on the second try. pretty much the same as the behavior when media is played from HA. I will try to downgrade (if possible!?) and see if this fixes the problem.

jpconfessor avatar Mar 03 '23 20:03 jpconfessor

I tried the same thing. Haven’t found a workaround either

Same.

I've done some testing from the home app and it appears to be linked to this beta firmware (16.4), since the home app itself is kind of broken when you try to control the homepod.. it gets out of sync easily, and when you try to skip songs it will only work on the second try. pretty much the same as the behavior when media is played from HA. I will try to downgrade (if possible!?) and see if this fixes the problem.

I'm not running the beta or even the new architecture. iOS 16.3.1 on my phone and 16.3.2 on my homepods.

400HPMustang avatar Mar 03 '23 20:03 400HPMustang

Thanks @jpconfessor for the tip. I managed to downgrade to 16.3.2. Plug Homepod mini into a computer via USB-C. First download the ISPW: https://ipsw.me/AudioAccessory5,1. Once downloaded go to Finder or iTunes and select the HomePod mini in the Sidebar. Hold down the Option or Alt key and click on Restore. You should now be presented with a window to select the file you just downloaded. Choose the 16.3 IPSW and select open. The software will now install onto the HomePod. I removed and re-added the Homepod on the Home app. Tested TTS and it works perfectly!

dkkr23 avatar Mar 04 '23 00:03 dkkr23

@dkkr23 Thank you!!! It worked ;) after downgrading to 16.3.2 all problems stopped. Just a small correction.. on Windows, instead of Alt Key, you must hold SHIFT to select the fw file.

So... moving forward, I hope apple will fix their fw, since this seems to be linked to apple and not this addon. @400HPMustang in your case, it seems to be a different issue, no?

jpconfessor avatar Mar 04 '23 05:03 jpconfessor

It’s hit or miss for me. Some HomePods will do the TTS and some will not and I don’t think it’s always the same ones.

The same goes for playing audio from a locally stored file.

400HPMustang avatar Mar 04 '23 12:03 400HPMustang

@400HPMustang One thing I do in my automations - before I sent a TTS, i have 2 other steps first. I send a command to stop the media player, and another command to set the volume to 1, then I send the TTS. There may be a trick there that you can trial and error, even for the audio

dkkr23 avatar Mar 04 '23 14:03 dkkr23

Originally I was sending a stop, setting the volume to 50% and then after the announcement setting the volume back to 20%.

It didn’t seem to work either.

400HPMustang avatar Mar 04 '23 14:03 400HPMustang

@postlund any updates on this issue its quite frustrating and means using HomePods as TTS is useless and unreliable

SamB-GB avatar Mar 22 '23 11:03 SamB-GB

I am finding this issue is more prevalent when sending TTS to a HomePod group rather than individual HomePods.

I'm having issues whether it's playing media to a homepod or sending a TTS announcement. It seems like we've gone from not working at all to just being wildly inconsistent in the playback. I do TTS and an MP3 to 7 homepods (3 OG and 4 mini) and it's anyone's guess as to which one will play.

I stopped using groups. I was just playing to the homepod without doing anything else. Then I tried sending a "stop" before doing the TTS or playing the media. Also tried setting volume. None of it works consistently and all of it seems to throw some kind of error.

400HPMustang avatar Mar 23 '23 13:03 400HPMustang

Think I will just throw in the towel and switch to Alexa Media Player with some Echo dots around the house for TTS

SamB-GB avatar Mar 27 '23 12:03 SamB-GB

tried to upgrade one of my homepod minis to 16.4 and this issue is still happening in the final release... I will have to rollback one more time... hopefully someone will fix soon!

btw, has anyone tried 16.4 with the new "upgraded underlying architecture?" I can't test because this requires all hubs in 16.4 and I don't want to upgrade all my homepods

jpconfessor avatar Mar 28 '23 01:03 jpconfessor

I was never on 16.4 at all with this happening.. it was happening the prior version for me.

SamB-GB avatar Mar 28 '23 08:03 SamB-GB

I'm having the exact same issue since upgrading to 16.4. It doesn't work with either TTS or MP3 files. Both were working fine until the upgrade. I've done some experiments and here are my findings,

  • It works every other try.
  • When it doesn't work, the player goes to Standby then Off and eventually Paused.

musabshareef avatar Mar 30 '23 16:03 musabshareef

Glad I found this thread, same here with me, thought I was losing my mind.

monsieurlatte avatar Mar 30 '23 17:03 monsieurlatte

Hi together. i have the same problem. This solution worked for me: Disable automatic updates for HomePods in the Home-App. Downgrade all my HomePods(mini) to Version 16.3.2 After restart an newcofigure all my HomePods, all automations with play audio on a HomePod worked. :)

nireins avatar Mar 31 '23 05:03 nireins

I am also having the same issue trying to play media to my HomePods via the HA Media Browser and Scripts post the iOS upgrade to 16.4 (new Architecture). All other functions seem to work as before.

I hope @postlund or someone with a better brain than mine is able to come up with a fix!

Sooty70 avatar Mar 31 '23 08:03 Sooty70

Hi together. i have the same problem. This solution worked for me: Disable automatic updates for HomePods in the Home-App. Downgrade all my HomePods(mini) to Version 16.3.2 After restart an newcofigure all my HomePods, all automations with play audio on a HomePod worked. :)

I was on 16.3.2 when this was occurring as well so I would be reluctant to downgrade

SamB-GB avatar Mar 31 '23 08:03 SamB-GB

Hi together. i have the same problem. This solution worked for me: Disable automatic updates for HomePods in the Home-App. Downgrade all my HomePods(mini) to Version 16.3.2 After restart an newcofigure all my HomePods, all automations with play audio on a HomePod worked. :)

this workaround was discussed previously in this thread while 16.4 was in beta

jpconfessor avatar Mar 31 '23 12:03 jpconfessor

Any plan to fix this? I hit the same bug today.

djstroh avatar Mar 31 '23 15:03 djstroh

Hi together. i have the same problem. This solution worked for me: Disable automatic updates for HomePods in the Home-App. Downgrade all my HomePods(mini) to Version 16.3.2 After restart an newcofigure all my HomePods, all automations with play audio on a HomePod worked. :)

I was on 16.3.2 when this was occurring as well so I would be reluctant to downgrade

Yeah I had the problem in 16.3.2, seems to be happening more in 16.4

400HPMustang avatar Mar 31 '23 16:03 400HPMustang

I've heard about this is several places and I will look into it when I have some time over. I'm a bit choked right now though.

postlund avatar Mar 31 '23 16:03 postlund

I've heard about this is several places and I will look into it when I have some time over. I'm a bit choked right now though.

I WILL BUY YOU A COFFEEE!!! ❤️ everyone should do the same! go to his github and share some “love”

jpconfessor avatar Mar 31 '23 16:03 jpconfessor