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 4 fails to authenticate on 0.55.1 #9966

Closed
justinglow opened this issue Oct 19, 2017 · 11 comments · Fixed by #11104
Closed

Apple TV 4 fails to authenticate on 0.55.1 #9966

justinglow opened this issue Oct 19, 2017 · 11 comments · Fixed by #11104

Comments

@justinglow
Copy link

justinglow commented Oct 19, 2017

Home Assistant release (hass --version): 0.55.1

Python release (python3 --version): 2.7.9

Component/platform: apple_tv

Description of problem: Apple TV (version 4) will not authenticate and therefore cannot establish a connection with Home Assistant

Expected: A successfull connection between Apple TV and Home Assistant

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

apple_tv:
  - name: Apple TV
    host: 192.168.1.129
    login_id: !secret apple_tv_login_id
  1. Update to Home Assistant 0.55.1
  2. Check the logs after restart
  3. Notice repeating authentication errors (below)
  4. Attempt to run any automation or task relating to Apple TV and notice failure

Traceback (if applicable):

Additional info:

2017-10-19 08:50:17 WARNING (MainThread) [pyatv.tag_definitions] Unknown data: b'103'
2017-10-19 08:50:17 WARNING (MainThread) [pyatv.tag_definitions] Unknown data: b'103'
2017-10-19 08:50:17 WARNING (MainThread) [homeassistant.components.media_player.apple_tv] A <class 'pyatv.exceptions.AuthenticationError'> error occurred: failed to login: 503

@cmsimike
Copy link
Contributor

Shot in the dark here, but were you able to confirm this worked prior to the new tvOS version?

@themanieldaniel
Copy link

I am having the same issue and I haven’t been able to determine which caused the problem since both upgrades happened around the same time.

@postlund
Copy link
Contributor

This has been reported/seen before, have a look at postlund/pyatv#121. I am not really sure if I understand the solution entirely, but at least he solved it. Generally this issue happens due to authentication problems, so I would recommend disabling end enabling home sharing on your ATV. This seems to be the trick that solves problems for people.

@themanieldaniel
Copy link

I have tried, as your linked post suggests, to restart my Apple TV and then play something while I restart HA, but that doesn't change anything. Still the same problems.

I have also tried disabling and reenabling home sharing. No change.

My passwords have not changed since the last time my ATV was properly working with HA.

I am not sure how changing the ports on his router has any effect on ATV working with HA, but I have used LetsEncrypt with my HA configuration and port forwarding on my router. I have rechecked those settings and I don't see anything that should cause any interference.

@postlund
Copy link
Contributor

I assume that you verified that your login_id is correct? One thing that would be interesting if you tried is if you pair with your device. It's not possible to do that with HA yet, but you can use atvremote. You should just have to run atvremote pair on a machine on the same network as you ATV and pair from the Remote control menu on your ATV. This will give you another identifier that you use as login_id.

@morberg
Copy link
Contributor

morberg commented Oct 22, 2017

FWIW I was seeing this as well, but eventually got it to work. Turned off and on home sharing and restarted the Apple TV. After a restart home sharing should have been on, but it wasn't:

> atvremote scan -a
Found Apple TVs:
 - Apple TV at 192.168.1.134 (home sharing disabled)

When I re-enabled home sharing on the Apple TV I could access it through Home Assistant again. Running tvOS 11.0 and Hass 0.56.0.

@themanieldaniel
Copy link

themanieldaniel commented Oct 23, 2017

Thank you that worked.

What I was doing wrong: I turned off Home Sharing and then immediately turned it back on without restarting the Apple TV.

What did work: turning Home Sharing off, restarting Apple TV, then turning Home Sharing back on.

I suspect this is an issue with tvOS 11, because before turning Home Sharing off or restarting atvremote scan would not show my Apple TV at all, but after restarting it showed it but with Home Sharing disabled (as @morberg noted).

Running tvOS 11 and Hass 0.55.0

@chimpy
Copy link

chimpy commented Oct 30, 2017

I will retry these steps, but they only worked temorarily for me the first time.

@themanieldaniel
Copy link

update to my previous post:
That was only a temporary fix. Within a day the error was back. I have been too busy to post until now.

Since the last post I have upgraded to HA 0.57.3 and I have isolated tracebacks when the error occurs.

2017-11-18 14:39:42 ERROR (MainThread) [aiohttp.server] Error handling request
Traceback (most recent call last):
  File "/srv/homeassistant/lib/python3.4/site-packages/aiohttp/web_protocol.py", line 422, in start
    resp = yield from self._request_handler(request)
  File "/srv/homeassistant/lib/python3.4/site-packages/aiohttp/web.py", line 306, in _handle
    resp = yield from handler(request)
  File "/usr/lib/python3.4/asyncio/coroutines.py", line 143, in coro
    res = yield from res
  File "/usr/lib/python3.4/asyncio/coroutines.py", line 143, in coro
    res = yield from res
  File "/srv/homeassistant/lib/python3.4/site-packages/homeassistant/components/http/ban.py", line 58, in ban_middleware_handler
    return (yield from handler(request))
  File "/srv/homeassistant/lib/python3.4/site-packages/homeassistant/components/http/__init__.py", line 423, in handle
    result = yield from result
  File "/srv/homeassistant/lib/python3.4/site-packages/homeassistant/components/media_player/__init__.py", line 963, in get
    data, content_type = yield from player.async_get_media_image()
  File "/srv/homeassistant/lib/python3.4/site-packages/homeassistant/components/media_player/apple_tv.py", line 181, in async_get_media_image
    return (yield from self.atv.metadata.artwork()), 'image/png'
  File "/srv/homeassistant/lib/python3.4/site-packages/pyatv/internal/apple_tv.py", line 73, in artwork
    art = yield from self.daap.get(_ARTWORK_CMD, daap_data=False)
  File "/srv/homeassistant/lib/python3.4/site-packages/pyatv/daap.py", line 66, in get
    return (yield from self._do(_get_request, is_daap=daap_data))
  File "/srv/homeassistant/lib/python3.4/site-packages/pyatv/daap.py", line 89, in _do
    resp, status = yield from action()
  File "/srv/homeassistant/lib/python3.4/site-packages/pyatv/net.py", line 39, in get_data
    raise ex
  File "/srv/homeassistant/lib/python3.4/site-packages/pyatv/net.py", line 30, in get_data
    timeout=DEFAULT_TIMEOUT if timeout is None else timeout)
  File "/srv/homeassistant/lib/python3.4/site-packages/aiohttp/helpers.py", line 97, in __iter__
    ret = yield from self._coro
  File "/srv/homeassistant/lib/python3.4/site-packages/aiohttp/client.py", line 241, in _request
    yield from resp.start(conn, read_until_eof)
  File "/srv/homeassistant/lib/python3.4/site-packages/aiohttp/client_reqrep.py", line 559, in start
    (message, payload) = yield from self._protocol.read()
  File "/srv/homeassistant/lib/python3.4/site-packages/aiohttp/streams.py", line 509, in read
    yield from self._waiter
  File "/usr/lib/python3.4/asyncio/futures.py", line 388, in __iter__
    yield self  # This tells Task to wait for completion.
  File "/usr/lib/python3.4/asyncio/tasks.py", line 286, in _wakeup
    value = future.result()
  File "/usr/lib/python3.4/asyncio/futures.py", line 277, in result
    raise self._exception
aiohttp.client_exceptions.ServerDisconnectedError: None
2017-11-18 14:39:42 ERROR (MainThread) [aiohttp.server] Error handling request
Traceback (most recent call last):
  File "/srv/homeassistant/lib/python3.4/site-packages/aiohttp/web_protocol.py", line 422, in start
    resp = yield from self._request_handler(request)
  File "/srv/homeassistant/lib/python3.4/site-packages/aiohttp/web.py", line 306, in _handle
    resp = yield from handler(request)
  File "/usr/lib/python3.4/asyncio/coroutines.py", line 143, in coro
    res = yield from res
  File "/usr/lib/python3.4/asyncio/coroutines.py", line 143, in coro
    res = yield from res
  File "/srv/homeassistant/lib/python3.4/site-packages/homeassistant/components/http/ban.py", line 58, in ban_middleware_handler
    return (yield from handler(request))
  File "/srv/homeassistant/lib/python3.4/site-packages/homeassistant/components/http/__init__.py", line 423, in handle
    result = yield from result
  File "/srv/homeassistant/lib/python3.4/site-packages/homeassistant/components/media_player/__init__.py", line 963, in get
    data, content_type = yield from player.async_get_media_image()
  File "/srv/homeassistant/lib/python3.4/site-packages/homeassistant/components/media_player/apple_tv.py", line 181, in async_get_media_image
    return (yield from self.atv.metadata.artwork()), 'image/png'
  File "/srv/homeassistant/lib/python3.4/site-packages/pyatv/internal/apple_tv.py", line 73, in artwork
    art = yield from self.daap.get(_ARTWORK_CMD, daap_data=False)
  File "/srv/homeassistant/lib/python3.4/site-packages/pyatv/daap.py", line 66, in get
    return (yield from self._do(_get_request, is_daap=daap_data))
  File "/srv/homeassistant/lib/python3.4/site-packages/pyatv/daap.py", line 89, in _do
    resp, status = yield from action()
  File "/srv/homeassistant/lib/python3.4/site-packages/pyatv/net.py", line 39, in get_data
    raise ex
  File "/srv/homeassistant/lib/python3.4/site-packages/pyatv/net.py", line 30, in get_data
    timeout=DEFAULT_TIMEOUT if timeout is None else timeout)
  File "/srv/homeassistant/lib/python3.4/site-packages/aiohttp/helpers.py", line 97, in __iter__
    ret = yield from self._coro
  File "/srv/homeassistant/lib/python3.4/site-packages/aiohttp/client.py", line 241, in _request
    yield from resp.start(conn, read_until_eof)
  File "/srv/homeassistant/lib/python3.4/site-packages/aiohttp/client_reqrep.py", line 559, in start
    (message, payload) = yield from self._protocol.read()
  File "/srv/homeassistant/lib/python3.4/site-packages/aiohttp/streams.py", line 509, in read
    yield from self._waiter
  File "/usr/lib/python3.4/asyncio/futures.py", line 388, in __iter__
    yield self  # This tells Task to wait for completion.
  File "/usr/lib/python3.4/asyncio/tasks.py", line 286, in _wakeup
    value = future.result()
  File "/usr/lib/python3.4/asyncio/futures.py", line 277, in result
    raise self._exception
aiohttp.client_exceptions.ServerDisconnectedError: None
2017-11-18 14:39:42 WARNING (MainThread) [homeassistant.components.media_player.apple_tv] A <class 'aiohttp.client_exceptions.ServerDisconnectedError'> error occurred: None
2017-11-18 14:39:52 WARNING (MainThread) [homeassistant.components.media_player.apple_tv] A <class 'pyatv.exceptions.AuthenticationError'> error occurred: failed to login: 400
2017-11-18 14:40:03 WARNING (MainThread) [homeassistant.components.media_player.apple_tv] A <class 'pyatv.exceptions.AuthenticationError'> error occurred: failed to login: 400

@morberg
Copy link
Contributor

morberg commented Nov 19, 2017

Probably unrelated to your issue, but it wouldn't hurt to upgrade your python version: https://home-assistant.io/blog/2017/10/06/deprecating-python-3.4-support/

@themanieldaniel
Copy link

unfortunately I don't believe I am able to upgrade python, at least as written in that link. I have tried it and the repositories for my CHIP computer get screwed up since the manufacturer hasn't updated support for stretch yet. :(

@postlund postlund mentioned this issue Dec 12, 2017
4 tasks
@home-assistant home-assistant locked and limited conversation to collaborators Mar 30, 2018
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.

6 participants