TvOS 11 - Connection no working

I have upgraded my apple tv 4 to tvos 11 and… tadaa It no longer connect with HA. I have repeated the authentication but HA always tells me “Establishing connection with apple tv” …
Any ideas?

Thank you for your support!

1 Like

I have not tried pyatv with tvOS 11, so I don’t know if it works. Authentication is just for airplay so it’s not important for general use. Can you look in the log files and see if it says anything?

Can’t find anything…

Home Assistant
0.53.1

Path to configuration.yaml: /config

Developed by a bunch of awesome people.

Published under the Apache 2.0 license
Source: server — frontend-ui

Built using Python 3, Polymer 2.0.1, Icons by Google and MaterialDesignIcons.com.

The following errors have been logged this session:

2017-09-20 14:09:09 WARNING (MainThread) [homeassistant.setup] Setup of sensor is taking over 10 seconds.
2017-09-20 14:09:10 WARNING (MainThread) [homeassistant.setup] Setup of media_player is taking over 10 seconds.
2017-09-20 14:09:11 WARNING (MainThread) [homeassistant.setup] Setup of vacuum is taking over 10 seconds.
2017-09-20 14:09:11 WARNING (MainThread) [homeassistant.setup] Setup of switch is taking over 10 seconds.
2017-09-20 14:09:11 WARNING (MainThread) [homeassistant.setup] Setup of light is taking over 10 seconds.
2017-09-20 14:09:11 WARNING (MainThread) [homeassistant.setup] Setup of device_tracker is taking over 10 seconds.
2017-09-20 14:09:17 ERROR (SyncWorker_12) [plexapi] http://localhost:32400: HTTPConnectionPool(host='localhost', port=32400): Max retries exceeded with url: / (Caused by NewConnectionError('<requests.packages.urllib3.connection.HTTPConnection object at 0x73d94f10>: Failed to establish a new connection: [Errno 111] Connection refused',))
2017-09-20 14:09:17 ERROR (MainThread) [homeassistant.components.sensor] Error while setting up platform plex
Traceback (most recent call last):
  File "/usr/lib/python3.6/site-packages/requests/packages/urllib3/connection.py", line 141, in _new_conn
    (self.host, self.port), self.timeout, **extra_kw)
  File "/usr/lib/python3.6/site-packages/requests/packages/urllib3/util/connection.py", line 83, in create_connection
    raise err
  File "/usr/lib/python3.6/site-packages/requests/packages/urllib3/util/connection.py", line 73, in create_connection
    sock.connect(sa)
ConnectionRefusedError: [Errno 111] Connection refused

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/lib/python3.6/site-packages/requests/packages/urllib3/connectionpool.py", line 600, in urlopen
    chunked=chunked)
  File "/usr/lib/python3.6/site-packages/requests/packages/urllib3/connectionpool.py", line 356, in _make_request
    conn.request(method, url, **httplib_request_kw)
  File "/usr/lib/python3.6/http/client.py", line 1239, in request
    self._send_request(method, url, body, headers, encode_chunked)
  File "/usr/lib/python3.6/http/client.py", line 1285, in _send_request
    self.endheaders(body, encode_chunked=encode_chunked)
  File "/usr/lib/python3.6/http/client.py", line 1234, in endheaders
    self._send_output(message_body, encode_chunked=encode_chunked)
  File "/usr/lib/python3.6/http/client.py", line 1026, in _send_output
    self.send(msg)
  File "/usr/lib/python3.6/http/client.py", line 964, in send
    self.connect()
  File "/usr/lib/python3.6/site-packages/requests/packages/urllib3/connection.py", line 166, in connect
    conn = self._new_conn()
  File "/usr/lib/python3.6/site-packages/requests/packages/urllib3/connection.py", line 150, in _new_conn
    self, "Failed to establish a new connection: %s" % e)
requests.packages.urllib3.exceptions.NewConnectionError: <requests.packages.urllib3.connection.HTTPConnection object at 0x73d94f10>: Failed to establish a new connection: [Errno 111] Connection refused

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/lib/python3.6/site-packages/requests/adapters.py", line 438, in send
    timeout=timeout
  File "/usr/lib/python3.6/site-packages/requests/packages/urllib3/connectionpool.py", line 649, in urlopen
    _stacktrace=sys.exc_info()[2])
  File "/usr/lib/python3.6/site-packages/requests/packages/urllib3/util/retry.py", line 388, in increment
    raise MaxRetryError(_pool, url, error or ResponseError(cause))
requests.packages.urllib3.exceptions.MaxRetryError: HTTPConnectionPool(host='localhost', port=32400): Max retries exceeded with url: / (Caused by NewConnectionError('<requests.packages.urllib3.connection.HTTPConnection object at 0x73d94f10>: Failed to establish a new connection: [Errno 111] Connection refused',))

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/lib/python3.6/site-packages/plexapi/server.py", line 47, in _connect
    return self.query('/')
  File "/usr/lib/python3.6/site-packages/plexapi/server.py", line 107, in query
    response = method(url, headers=headers, timeout=TIMEOUT, **kwargs)
  File "/usr/lib/python3.6/site-packages/requests/sessions.py", line 531, in get
    return self.request('GET', url, **kwargs)
  File "/usr/lib/python3.6/site-packages/requests/sessions.py", line 518, in request
    resp = self.send(prep, **send_kwargs)
  File "/usr/lib/python3.6/site-packages/requests/sessions.py", line 639, in send
    r = adapter.send(request, **kwargs)
  File "/usr/lib/python3.6/site-packages/requests/adapters.py", line 502, in send
    raise ConnectionError(e, request=request)
requests.exceptions.ConnectionError: HTTPConnectionPool(host='localhost', port=32400): Max retries exceeded with url: / (Caused by NewConnectionError('<requests.packages.urllib3.connection.HTTPConnection object at 0x73d94f10>: Failed to establish a new connection: [Errno 111] Connection refused',))

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/lib/python3.6/site-packages/homeassistant/helpers/entity_component.py", line 164, in _async_setup_platform
    SLOW_SETUP_MAX_WAIT, loop=self.hass.loop)
  File "/usr/lib/python3.6/asyncio/tasks.py", line 352, in wait_for
    return fut.result()
  File "/usr/lib/python3.6/asyncio/futures.py", line 244, in result
    raise self._exception
  File "/usr/lib/python3.6/concurrent/futures/thread.py", line 55, in run
    result = self.fn(*self.args, **self.kwargs)
  File "/usr/lib/python3.6/site-packages/homeassistant/components/sensor/plex.py", line 52, in setup_platform
    name, plex_url, plex_user, plex_password, plex_server)], True)
  File "/usr/lib/python3.6/site-packages/homeassistant/components/sensor/plex.py", line 74, in __init__
    self._server = PlexServer(plex_url)
  File "/usr/lib/python3.6/site-packages/plexapi/server.py", line 27, in __init__
    data = self._connect()
  File "/usr/lib/python3.6/site-packages/plexapi/server.py", line 50, in _connect
    raise NotFound('No server found at: %s' % self.baseurl)
plexapi.exceptions.NotFound: No server found at: http://localhost:32400
2017-09-20 14:09:20 WARNING (MainThread) [homeassistant.setup] Setup of tts is taking over 10 seconds.
2017-09-20 14:09:29 WARNING (MainThread) [homeassistant.components.media_player] Setup of platform plex is taking over 10 seconds.
2017-09-20 14:09:49 ERROR (SyncWorker_0) [plexapi] http://192.168.100.10:32400: HTTPConnectionPool(host='192.168.100.10', port=32400): Max retries exceeded with url: /?X-Plex-Token=bdA5pTba9JyZRnVG9Yqr (Caused by ConnectTimeoutError(<requests.packages.urllib3.connection.HTTPConnection object at 0x73e05c90>, 'Connection to 192.168.100.10 timed out. (connect timeout=30)'))
2017-09-20 14:10:01 WARNING (MainThread) [homeassistant.components.binary_sensor.template] Could not render template movie, the state is unknown
2017-09-20 14:10:23 WARNING (SyncWorker_8) [netdisco.ssdp] Error fetching description at http://192.168.0.1:8200/rootDesc.xml
2017-09-20 14:10:29 ERROR (MainThread) [homeassistant.components.binary_sensor.template] Could not render template movie: UndefinedError: 'mappingproxy object' has no attribute 'media_position'
2017-09-20 14:10:29 ERROR (MainThread) [homeassistant.core] Error doing job: Task exception was never retrieved
Traceback (most recent call last):
  File "/usr/lib/python3.6/asyncio/tasks.py", line 179, in _step
    result = coro.send(None)
  File "/usr/lib/python3.6/site-packages/homeassistant/helpers/entity.py", line 239, in async_update_ha_state
    state = self.state
  File "/usr/lib/python3.6/site-packages/homeassistant/components/media_player/apple_tv.py", line 98, in state
    state = self._playing.play_state
  File "/usr/lib/python3.6/site-packages/pyatv/internal/apple_tv.py", line 245, in play_state
    return convert.playstate(state)
  File "/usr/lib/python3.6/site-packages/pyatv/convert.py", line 48, in playstate
    raise exceptions.UnknownPlayState('Unknown playstate: ' + str(state))
pyatv.exceptions.UnknownPlayState: Unknown playstate: 0
2017-09-20 14:10:33 ERROR (SyncWorker_12) [pynetgear] Error talking to API
Traceback (most recent call last):
  File "/usr/lib/python3.6/site-packages/requests/models.py", line 374, in prepare_url
    scheme, auth, host, port, path, query, fragment = parse_url(url)
  File "/usr/lib/python3.6/site-packages/requests/packages/urllib3/util/url.py", line 199, in parse_url
    raise LocationParseError(url)
requests.packages.urllib3.exceptions.LocationParseError: Failed to parse: None:None

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/lib/python3.6/site-packages/pynetgear/__init__.py", line 113, in _make_request
    self.soap_url, headers=headers, data=message, timeout=10)
  File "/usr/lib/python3.6/site-packages/requests/api.py", line 112, in post
    return request('post', url, data=data, json=json, **kwargs)
  File "/usr/lib/python3.6/site-packages/requests/api.py", line 58, in request
    return session.request(method=method, url=url, **kwargs)
  File "/usr/lib/python3.6/site-packages/requests/sessions.py", line 504, in request
    prep = self.prepare_request(req)
  File "/usr/lib/python3.6/site-packages/requests/sessions.py", line 436, in prepare_request
    hooks=merge_hooks(request.hooks, self.hooks),
  File "/usr/lib/python3.6/site-packages/requests/models.py", line 302, in prepare
    self.prepare_url(url, params)
  File "/usr/lib/python3.6/site-packages/requests/models.py", line 376, in prepare_url
    raise InvalidURL(*e.args)
requests.exceptions.InvalidURL: Failed to parse: None:None
2017-09-20 14:10:33 ERROR (SyncWorker_12) [homeassistant.components.device_tracker.netgear] Failed to Login
2017-09-20 14:10:33 ERROR (MainThread) [homeassistant.components.device_tracker] Error setting up platform netgear
2017-09-20 14:10:41 WARNING (MainThread) [homeassistant.components.media_player] Setup of platform cast is taking over 10 seconds.
2017-09-20 14:21:37 ERROR (MainThread) [homeassistant.core] Timer got out of sync. Resetting
2017-09-20 14:27:06 ERROR (MainThread) [homeassistant.core] Error doing job: Fatal error on transport TCPTransport (error status in uv_stream_t.read callback)
TimeoutError: [Errno 110] Operation timed out
2017-09-20 14:45:22 ERROR (MainThread) [homeassistant.core] Error doing job: Fatal error on transport TCPTransport (error status in uv_stream_t.read callback)
OSError: [Errno 113] Host is unreachable
2017-09-20 14:55:33 WARNING (SyncWorker_7) [homeassistant.components.switch.tplink] Could not read state for Notte Plug: 
2017-09-20 15:09:17 ERROR (SyncWorker_2) [mirobo.device] Unable to discover a device at address 192.168.0.51
2017-09-20 15:09:17 WARNING (MainThread) [homeassistant.components.vacuum.xiaomi] Got exception while fetching the state: Unable to discover the device 192.168.0.51
2017-09-20 15:35:53 ERROR (SyncWorker_4) [mirobo.device] Unable to discover a device at address 192.168.0.51
2017-09-20 15:35:53 WARNING (MainThread) [homeassistant.components.vacuum.xiaomi] Got exception while fetching the state: Unable to discover the device 192.168.0.51

It’s this part:

Not sure why it’s using play state 0, but it’s not supported by pyatv (I would have to add it).

1 Like

I created an issue for it here: https://github.com/postlund/pyatv/issues/115

2 Likes

Super! Thanks

Seems to be related to when no media is playing, I found that if I play something on the Apple TV it gets picked up, that makes me think play state 0 is related to being idle.

My best guess is that play state 0 correlates to ”idle”. Seems strange that they would start using that now though. Anyways, I’m gonna try to get a fix out by Tuesday. That’s when I possibly have some time.

1 Like

There is now a PR with fix for this: https://github.com/home-assistant/home-assistant/pull/9586

pyatv v0.3.5 works now with tvOS11 (and BTW also with the ATV 4K) :wink:

If you can’t wait for a new HA release just change the pyatv version in requirements_all.txt from 0.3.4 to 0.3.5.

1 Like

I would recommend pulling in everything from the PR, otherwise the state will reported as “unknown” instead of idle.

How do you go about pulling it from the PR?

How do you run Home Assistant today? I guess a new release will be out this weekend, so the easiest solution is just to wait for that right now.

I’m running HASSbian on a Rasperry Pi 3. If you don’t mind sending me some sort of example or documentation I would definitely appreciate it. If not that’s fine, I don’t mind waiting but I would definitely be interested in learning how to update my home assistant from an unreleased confirmed pull request.

Ok, that’s good. I guess that you are running an official release (installed with pip)? To import he PR you need to clone the Home Assistant repo, cherry-pick the commit and install it again. It’s not that hard but it’s a few steps.

Yes that is correct, currently running the 0.54 release with it being installed with pip3. Alright, thank you for the information. I hate to sound like a baby that needs to be spoon fed, but is there a good guide I can find on the web possibly about cloning a repo and only pulling the commit from a certain pull request within the repo?

Again thank you for the help and I appreciate the work you’ve done on pyatv!