Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Apple TV State Not Updating #44305

Closed
danbayliss opened this issue Dec 17, 2020 · 16 comments · Fixed by #45799
Closed

Apple TV State Not Updating #44305

danbayliss opened this issue Dec 17, 2020 · 16 comments · Fixed by #45799

Comments

@danbayliss
Copy link

The problem

I've been using the ATV Beta custom_component for some time but after speaking to Postlund on Discord he recommended when 2020.12 is released it's best to move over to the core ATV Integration.

The Apple TV state when not playing content should be 'idle'. When I play movies it changes to 'playing' and when stopping the movie it changes back to 'idle'. When I call the service 'camera.play_stream' to play my camera the state succesfully changes to 'playing' but when I press home on my ATV remote and the ATV goes back to the main menu then state does not change to 'idle'. If I then try and play a movie the state remains as 'playing' and when I exit it remains as 'playing'. The only way to fix it is to reboot the ATV

Environment

  • Home Assistant Core release with the issue: 2020.12.1
  • Last working Home Assistant Core release (if known): n/a
  • Operating environment (OS/Container/Supervised/Core): Supervised
  • Integration causing this issue: Apple TV
  • Link to integration documentation on our website: https://www.home-assistant.io/integrations/apple_tv/

Problem-relevant configuration.yaml

Nothing in YAML

Traceback/Error logs

Nothing in logs

Additional information

@probot-home-assistant
Copy link

apple_tv documentation
apple_tv source
(message by IssueLinks)

@Nenodema
Copy link

I can confirm this issue, it might be something with the last update of AppleTV (14.3) ?

@danbayliss
Copy link
Author

I don't think it's related to tvOS version as i'm still on 14.0.2

@dgomes
Copy link
Contributor

dgomes commented Dec 20, 2020

cc @postlund

@gitaroomaan
Copy link

I can confirm this is happening for me as well - specifically when using the Apple Fitness+ app. A reload of the component typically resolves the problem.

@postlund
Copy link
Contributor

It would be great if you could attach some debug logs I can look at. Suggestion for log points:

logger:
  logs:
    pyatv: debug
    custom_components.apple_tv: debug

@danbayliss
Copy link
Author

Hi. Attached is the log where I call play_stream, wait around 30 seconds and then press home on my ATV remote to stop the camera stream. Hopefully this is useful
ATV.log

@postlund
Copy link
Contributor

I believe this is the same issue I've been rambling about in postlund/pyatv#905. Will start working on a fix for that.

@Moumoustache
Copy link

Same here...after going idle (like tv is off) the component is losing track of what s happening on the atv anymore...i need to reload the component in the integrations section and then it s working again.

@sira87
Copy link

sira87 commented Dec 30, 2020

I'm thinking my open issue (#43462) could be related to this one. I have no comments on that issue, so it maybe went unnoticed. This still happens with 2020.12 update.

@postlund
Copy link
Contributor

@sira87 Since I don't have any logs to look at, I can't tell for sure. But since this appears to be a general issue now, it's likely that it at least relates.

@MarvinSchenkel
Copy link

Same issue here. @postlund, are the logs supplied by @sira87 in #43462 sufficient, or do you need any additional log to figure this one out?

@Didel
Copy link

Didel commented Jan 6, 2021

It appears that the most recent version of Home Assistant (2021.1, see Release notes ) resolves this issue. I just updated Home Assistant, and now the status of the media player is updated correctly, including the state (idle, playing, paused) and the media source (movie/stream and app name).

@sira87
Copy link

sira87 commented Jan 8, 2021

It appears that the most recent version of Home Assistant (2021.1, see Release notes ) resolves this issue.).

The issue is still present for me in 2021.1, my ATV turned off due to inactivity but the entity state in HA remained Playing. It seems like no logs are being generated, it just stays in Playing state, with no errors.

The only logs I have were generated when I tried to interact with the stuck entity via this script:

alias: Apple TV OFF
sequence:
  - service: remote.send_command
    data:
      entity_id: remote.sala
      command: home_hold
  - delay: '00:00:01'
  - service: remote.send_command
    data:
      entity_id: remote.sala
      command: select
mode: single

Here are the logs it generated when I started the script:

Logger: aiohttp.server
Source: custom_components/apple_tv/media_player.py:205
First occurred: 14:42:42 (6 occurrences)
Last logged: 14:43:51

Error handling request
Traceback (most recent call last):
  File "/usr/local/lib/python3.8/site-packages/aiohttp/web_protocol.py", line 422, in _handle_request
    resp = await self._request_handler(request)
  File "/usr/local/lib/python3.8/site-packages/aiohttp/web_app.py", line 499, in _handle
    resp = await handler(request)
  File "/usr/local/lib/python3.8/site-packages/aiohttp/web_middlewares.py", line 118, in impl
    return await handler(request)
  File "/usr/src/homeassistant/homeassistant/components/http/request_context.py", line 18, in request_context_middleware
    return await handler(request)
  File "/usr/src/homeassistant/homeassistant/components/http/ban.py", line 72, in ban_middleware
    return await handler(request)
  File "/usr/src/homeassistant/homeassistant/components/http/auth.py", line 127, in auth_middleware
    return await handler(request)
  File "/usr/src/homeassistant/homeassistant/components/http/view.py", line 129, in handle
    result = await result
  File "/usr/src/homeassistant/homeassistant/components/media_player/__init__.py", line 971, in get
    data, content_type = await player.async_get_media_image()
  File "/config/custom_components/apple_tv/media_player.py", line 205, in async_get_media_image
    artwork = await self.atv.metadata.artwork()
  File "/usr/local/lib/python3.8/site-packages/pyatv/mrp/__init__.py", line 441, in artwork
    artwork = await self._fetch_artwork(width or 0, height or -1)
  File "/usr/local/lib/python3.8/site-packages/pyatv/mrp/__init__.py", line 456, in _fetch_artwork
    item = resp.inner().playbackQueue.contentItems[playing.location]
  File "/usr/local/lib/python3.8/site-packages/google/protobuf/internal/containers.py", line 209, in __getitem__
    return self._values[key]
IndexError: list index out of range

@postlund
Copy link
Contributor

postlund commented Jan 8, 2021

I was actually quite surprised hearing that HA 2021.1 solved the problem as it didn't contain any bug fixes of magnitude. However, I do believe it's fixed on master. I have some other bugs I'm working on, after that I will make a new release of pyatv and include a bump in the next HA release. Hopefully I can make a bump in the beta repo, so you can test it there. It all depends on how much time I manage to find.

@sira87
Copy link

sira87 commented Jan 8, 2021

Awesome news! Thank you for your work @postlund, it's really appreciated!

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

9 participants