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 card flickers and throws errors #6293

Closed
mKeRix opened this issue Feb 27, 2017 · 14 comments · Fixed by #7189
Closed

Apple TV card flickers and throws errors #6293

mKeRix opened this issue Feb 27, 2017 · 14 comments · Fixed by #7189

Comments

@mKeRix
Copy link
Contributor

mKeRix commented Feb 27, 2017

Home Assistant release (hass --version): 0.39.1

Python release (python3 --version): 3.4.2

Component/platform: Apple TV

Description of problem: The Apple TV panel in the frontend constantly flashes as it tries to run some sort of animation and then goes back to being normal. In the Chrome Developer Console I'm seeing requests every second and the following error:
GET https://example.com/api/media_player_proxy/media_player.apple_tv?token=f6…12048928652b8f024f2648c4cb9a2c5bdb4&cache=398238c893b2a450b11cd4d1e51e0439 500 (Internal Server Error)
This happens no matter if my Apple TV 4 is turned on or off. The actual internal device state is correct and there are no errors showing up on the console either. I configured the device manually (as I'm suffering from the discovery memory leak issue). This has only been happening on 0.39.x.

Expected: The Apple TV card shows up without flickering and no errors are thrown in the Javascript Console.

Problem-relevant configuration.yaml entries and steps to reproduce:

media_player:
  - platform: apple_tv
    host: <ip>
    login_id: <id>

Traceback (if applicable):

GET /api/media_player_proxy/media_player.apple_tv?token=f63cb5705a09f9c5aa2ff1fb2bf0912048928652b8f024f2648c4cb9a2c5bdb4&cache=398238c893b2a450b11cd4d1e51e0439 HTTP/1.1
Host: example.com
Connection: keep-alive
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/56.0.2924.87 Safari/537.36
Accept: image/webp,image/*,*/*;q=0.8
Referer: https://example.com/states/group.example
Accept-Encoding: gzip, deflate, sdch, br
Accept-Language: de-DE,de;q=0.8,en-US;q=0.6,en;q=0.4

Additional info:

@terrycarlin
Copy link
Contributor

terrycarlin commented Feb 27, 2017 via email

@jer78
Copy link

jer78 commented Feb 27, 2017

I think it's a media_player issue since I see it on my Apple TV as well as Sonos.

@chimpy
Copy link

chimpy commented Feb 28, 2017

I see it on both my media-player cards too (LG TV and Apple TV)

@postlund
Copy link
Contributor

Can you try you comment out and keep only one player at the time, so we can single out if it only happens for one player?

@ViperRNMC
Copy link

I also have the problem with atv, comment out bravia and samsung tv, these 2 have not this issue.

@postlund
Copy link
Contributor

Does this happen even if the Apple TV is turned off in the web interface?

@ViperRNMC
Copy link

no, only when its turned on

@pascalmtts
Copy link

I can confirm this behavior on my side.

@postlund
Copy link
Contributor

postlund commented Mar 1, 2017

I have now created a PR with push update support which should also fix this, I hope. Please give it a spin: #6323

@dale3h
Copy link
Member

dale3h commented Mar 2, 2017

I'm glad I'm not the only one experiencing this issue. I made a screencast of the issue before seeing the fix, so I'll go ahead and post it anyway: https://youtu.be/nHKKhibytIE

@postlund I'll give the fix a try and let you know the results.

@postlund
Copy link
Contributor

postlund commented Mar 2, 2017

FYI: It's merged to dev now so you can just pull from dev.

@dale3h
Copy link
Member

dale3h commented Mar 2, 2017

I applied the necessary changes from #6323:

$ pip3 install --upgrade pyatv==0.2.1
$ mkdir -p /etc/homeassistant/custom_components/media_player
$ cd /etc/homeassistant/custom_components/media_player
$ wget https://raw.githubusercontent.com/postlund/home-assistant/1947ee153d59657abe9c9d45415592cc9c7fa976/homeassistant/components/media_player/apple_tv.py

Home Assistant is correctly loading the overridden file:

17-03-02 08:55:38 INFO (MainThread) [homeassistant.loader] Loaded media_player.apple_tv from custom_components.media_player.apple_tv

It is still happening even with #6323 in place. However, I think this might not be entirely related to the Apple TV platform, as I get a similar error in my Chrome Developer Console for a camera entity that I have disabled in Blue Iris, but still enabled in Home Assistant. When I attempt to load the proxy URL for either the Apple TV[1] or the Camera[2], Chrome spits out an ERR_INVALID_RESPONSE error. If I go to the actual Blue Iris camera URL[3], I get HTTP ERROR 503.

[1]Apple TV Proxy URL: https://my.domain/api/media_player_proxy/media_player.apple_tv_living_room?token=XXXXXXXX&cache=XXXXXXXX
[2]Camera Proxy URL: https://my.domain/api/camera_proxy/camera.camera_name?token=XXXXXXXX&time=XXXXXXXX
[3]Blue Iris Camera URL: http://X.X.X.X:12345/mjpg/camera_shortname/video.mjpg

@postlund
Copy link
Contributor

postlund commented Mar 8, 2017

@dale3h So, the frontend is making requests for the media image but in reality no image exists? If I have understood the flow correctly, the frontend uses entity_picture to get an URL to the media image. In the case of Apple TV, we can safely assume that no image exists if nothing is playing and return None in that case (that is how it's done now). But if something is playing, we can only know if artwork is available or if we try to fetch the artwork. A HTTP 500 error code is returned if no image is found. Maybe we are in a limbo here?

@mKeRix
Copy link
Contributor Author

mKeRix commented Mar 12, 2017

Just wanted to say that this problem is still there in 0.4.0 - same symptoms as described above. For now I'm back to hiding the platform in the frontend.

I haven't had time to take a deeper look at it, but if any further debugging information is needed I'll gladly provide it!

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

Successfully merging a pull request may close this issue.

8 participants