AppleTV error in 0.49

I’m getting the following error after upgrading to 0.49 on the appletv component:

ERROR (Thread-10) [homeassistant.util.package] Unable to install package pyatv==0.3.2: Command “/srv/hass/bin/python3.5 -u -c “import setuptools, tokenize;file=‘/tmp/pip-build-3uly45cj/cryptography/setup.py’;f=getattr(tokenize, ‘open’, open)(file);code=f.read().replace(‘\r\n’, ‘\n’);f.close();exec(compile(code, file, ‘exec’))” install --record /tmp/pip-rgvybuk0-record/install-record.txt --single-version-externally-managed --compile --install-headers /srv/hass/include/site/python3.5/cryptography --home=/tmp/tmpq0a13ua9” failed with error code 1 in /tmp/pip-build-3uly45cj/cryptography/
ERROR (MainThread) [homeassistant.setup] Not initializing apple_tv because could not install dependency pyatv==0.3.2
ERROR (MainThread) [homeassistant.setup] Setup failed for apple_tv: Could not install all requirements.
ERROR (MainThread) [homeassistant.setup] Unable to setup dependencies of media_player.apple_tv. Setup failed for dependencies: apple_tv
ERROR (MainThread) [homeassistant.setup] Unable to prepare setup for platform media_player.apple_tv: Could not setup all dependencies.

I did migrate the config to a component as per documentation… Any ideas?

Noticed myself that “/srv/hass/include/site/python3.5/cryptography” does not exist

Noob here. This is what helped me:

sudo apt-get install build-essential libssl-dev libffi-dev python-dev
sudo pip3 install --upgrade pyatv

Seems like the documentation is also a bit conflicting. Blog post says it should be a new component under apple_tv, yet the docs (recently updated) still call it out as being a media_player component.

Also struggling with loading up more than one Apple TV at the moment, one will load but any more than that will not.

The docs PR was not merged. It should be fixed now.

Similar error here, after upgrading to 0.49:

2017-07-16 13:01:31 ERROR (Thread-13) [homeassistant.util.package] Unable to install package pyatv==0.3.2: Command “/usr/bin/python3 -u -c “import setuptools, tokenize;file=‘/tmp/pip-build-etq2vk_9/cffi/setup.py’;f=getattr(tokenize, ‘open’, open)(file);code=f.read().replace(‘\r\n’, ‘\n’);f.close();exec(compile(code, file, ‘exec’))” install --record /tmp/pip-xha_n6q2-record/install-record.txt --single-version-externally-managed --compile --home=/tmp/tmpqlhvcn4j” failed with error code 1 in /tmp/pip-build-etq2vk_9/cffi/

Fixed the above issue by running (thanks @Radushka) :

sudo apt-get install build-essential libssl-dev libffi-dev python-dev
sudo pip3 install --upgrade pyatv

1 Like

Seeing the same thing with 3 Apple TVs in my home. I’m ignoring Apple TVs in the discovery component and I’m manually defining them the same way @postlund described in the PR. I copied this sort of format in my configuration.yaml file:

apple_tv:
  - host: 10.0.10.201
    name: Apple TV 1
    login_id: 00000000-1234-5678-9012-345678901234
  - host: 10.0.10.202
    name: Apple TV 2
    login_id: 00000000-1234-5678-9012-345678901432

Upon restarting the service, 3 remote platforms are created for my 3 Apple TVs (2 ATV4 and 1 ATV3), but only 1 media_player platform is created and it seems to randomly decide which Apple TV to create it for. Also, I think we’re supposed to have full remote control now (up, down, left, right) but I might have misread something. I’m only seeing On/Off for each remote.

Thanks for the tip!
I was able to fix it using only:

sudo apt install libssl-dev

  • activate venv environment
    pip3 install --upgrade pyatv
1 Like

Same here, only 1 Apple TV media_player showing, 2 remote’s…

Several people seems to have this issue and it boggles me a bit. Could you run this for each of your device and return the result:

atvremote --login_id --address device_id

It should return an id unique for each device. If it’s always the same, then we have found the issue. Not sure why that would happen though…

Maybe it would be a good idea to add details about the rehired system dependencies to docs too.

I think I did this right… I ran this command for each unique IP address of my 3 devices:

atvremote --login_id LOGINID --address IPADDRESS device_id

And the same string was returned for all 3. Also, just for fun I entered an IP address that doesn’t exist on my network (still a private IP, so not on the internet) and the same string was returned. Same with an IPv4 address that can’t exist (one of the octets was 855).

Hope this helps and please let me know if I’m doing something wrong with my usage of the command.

Haha, this is such a stupid error on my part… I know exactly what’s wrong. I’ll see if I can get the time to fix it later today so it can be included in next minor HA release. Thanks for testing this out, it helped a lot!

I have pushed fixes now so hopefully this should be solved in the next release!

This worked perfectly! Thanks.

@postlund Thanks so much for sorting the more than one ATV - can you share the code to change manually?

EDIT: Seen the edits on GitHUB - I will change manually :slight_smile:

Thanks again for all your work!!!

1 Like

I am seeing only one ATV instead of the two I have on the network in 49.0

Can someone share a link to the PR or what to change in apple tv please?

It’s here:

1 Like

0.49.1 is out now so no need for monkey patching, just upgrade.

3 Likes

Looks good, thanks for fixing!

@postlund Thanks for all your hard work on this component.

Unfortunately I’m still getting login errors in my logs, and the component says “Establishing a connection to atv_lr…” (atv_lr is the entity id name)

grep media_player.apple_tv /etc/homeassistant/home-assistant.log |wc -l
7201 

An example of these errors looks like this:

2017-08-02 20:02:44 WARNING (MainThread) [homeassistant.components.media_player.apple_tv] A <class 'pyatv.exceptions.AuthenticationError'> error occurred: failed to login: 400
2017-08-02 20:02:54 WARNING (MainThread) [homeassistant.components.media_player.apple_tv] A <class 'pyatv.exceptions.AuthenticationError'> error occurred: failed to login: 400

[EDIT]
Looks like I fixed my own problem…
I had:

  - name: NAME_1
    login_id: LOGIN_ID_1
    host: IP_1
    ....

Then I set it to:

  - host: IP_1
    login_id: LOGIN_ID_1
    name: NAME_1
    ....

Restarted, and bam, component works fine…

I have not not made any changes that I see would fix this issue (as I still don’t know what the root cause is). Glad that the changes you made works, but I really cannot see why it would make a difference :confused: