Apple TV issues

I’m having trouble with setting up Apple TV manually. I tried using ‘discovery’ but the HUD module on my HA dashboard just says “Not connected to the Apple TV.” When I type “atvremote scan” the following error comes back:
(homeassistant) pi@hassbian:~ $ atvremote scan
Traceback (most recent call last):
File “/usr/local/bin/atvremote”, line 7, in
from pyatv.main import main
File “/usr/local/lib/python3.4/dist-packages/pyatv/init.py”, line 13, in
from pyatv.internal.apple_tv import AppleTVInternal
File “/usr/local/lib/python3.4/dist-packages/pyatv/internal/apple_tv.py”, line 19, in
from pyatv.airplay.srp import (SRPAuthHandler, new_credentials)
File “/usr/local/lib/python3.4/dist-packages/pyatv/airplay/srp.py”, line 9, in
from ed25519.keys import SigningKey
ImportError: No module named ‘ed25519’

It’s clear that there’s a module missing, but I haven’t the slightest clue as to how I should fix this. Any suggestions?

Does anyone have any ideas? I have no idea what to do here.

Update: I tried to install pyatv again and this is the result:

Collecting pyatv
  Using cached pyatv-0.3.2-py3-none-any.whl
Requirement already satisfied: zeroconf>=0.17.7 in ./lib/python3.4/site-packages (from pyatv)
Collecting cryptography>=1.8.1 (from pyatv)
  Using cached cryptography-1.9.tar.gz
Requirement already satisfied: curve25519-donna<2,>=1.3 in ./lib/python3.4/site-packages (from pyatv)
Requirement already satisfied: aiohttp<3,>=1.3.5 in ./lib/python3.4/site-packages (from pyatv)
Requirement already satisfied: ed25519<2,>=1.4 in ./lib/python3.4/site-packages (from pyatv)
Requirement already satisfied: srptools>=0.2.0 in ./lib/python3.4/site-packages (from pyatv)
Requirement already satisfied: enum-compat in ./lib/python3.4/site-packages (from zeroconf>=0.17.7->pyatv)
Requirement already satisfied: six in ./lib/python3.4/site-packages (from zeroconf>=0.17.7->pyatv)
Requirement already satisfied: netifaces!=0.10.5 in ./lib/python3.4/site-packages (from zeroconf>=0.17.7->pyatv)
Requirement already satisfied: idna>=2.1 in ./lib/python3.4/site-packages (from cryptography>=1.8.1->pyatv)
Requirement already satisfied: asn1crypto>=0.21.0 in ./lib/python3.4/site-packages (from cryptography>=1.8.1->pyatv)
Collecting cffi>=1.7 (from cryptography>=1.8.1->pyatv)
  Using cached cffi-1.10.0.tar.gz
Requirement already satisfied: chardet in ./lib/python3.4/site-packages (from aiohttp<3,>=1.3.5->pyatv)
Requirement already satisfied: multidict>=2.1.4 in ./lib/python3.4/site-packages (from aiohttp<3,>=1.3.5->pyatv)
Requirement already satisfied: async_timeout>=1.2.0 in ./lib/python3.4/site-packages (from aiohttp<3,>=1.3.5->pyatv)
Requirement already satisfied: yarl<0.11,>=0.10.0 in ./lib/python3.4/site-packages (from aiohttp<3,>=1.3.5->pyatv)
Requirement already satisfied: pycparser in ./lib/python3.4/site-packages (from cffi>=1.7->cryptography>=1.8.1->pyatv)
Installing collected packages: cffi, cryptography, pyatv
  Running setup.py install for cffi ... error
    Complete output from command /srv/homeassistant/bin/python3 -u -c "import setuptools, tokenize;__file__='/tmp/pip-build-z7skk7rm/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-3d0rc0rk-record/install-record.txt --single-version-externally-managed --compile --install-headers /srv/homeassistant/include/site/python3.4/cffi:
    Package libffi was not found in the pkg-config search path.
    Perhaps you should add the directory containing `libffi.pc'
    to the PKG_CONFIG_PATH environment variable
    No package 'libffi' found
    Package libffi was not found in the pkg-config search path.
    Perhaps you should add the directory containing `libffi.pc'
    to the PKG_CONFIG_PATH environment variable
    No package 'libffi' found
    Package libffi was not found in the pkg-config search path.
    Perhaps you should add the directory containing `libffi.pc'
    to the PKG_CONFIG_PATH environment variable
    No package 'libffi' found
    Package libffi was not found in the pkg-config search path.
    Perhaps you should add the directory containing `libffi.pc'
    to the PKG_CONFIG_PATH environment variable
    No package 'libffi' found
    Package libffi was not found in the pkg-config search path.
    Perhaps you should add the directory containing libffi.pc'
    to the PKG_CONFIG_PATH environment variable
    No package 'libffi' found
    running install
    running build
    running build_py
    creating build
    creating build/lib.linux-armv7l-3.4
    creating build/lib.linux-armv7l-3.4/cffi
    copying cffi/setuptools_ext.py -> build/lib.linux-armv7l-3.4/cffi
    copying cffi/backend_ctypes.py -> build/lib.linux-armv7l-3.4/cffi
    copying cffi/recompiler.py -> build/lib.linux-armv7l-3.4/cffi
    copying cffi/cparser.py -> build/lib.linux-armv7l-3.4/cffi
    copying cffi/commontypes.py -> build/lib.linux-armv7l-3.4/cffi
    copying cffi/api.py -> build/lib.linux-armv7l-3.4/cffi
    copying cffi/verifier.py -> build/lib.linux-armv7l-3.4/cffi
    copying cffi/model.py -> build/lib.linux-armv7l-3.4/cffi
    copying cffi/vengine_cpy.py -> build/lib.linux-armv7l-3.4/cffi
    copying cffi/vengine_gen.py -> build/lib.linux-armv7l-3.4/cffi
    copying cffi/lock.py -> build/lib.linux-armv7l-3.4/cffi
    copying cffi/ffiplatform.py -> build/lib.linux-armv7l-3.4/cffi
    copying cffi/cffi_opcode.py -> build/lib.linux-armv7l-3.4/cffi
    copying cffi/error.py -> build/lib.linux-armv7l-3.4/cffi
    copying cffi/__init__.py -> build/lib.linux-armv7l-3.4/cffi
    copying cffi/_cffi_include.h -> build/lib.linux-armv7l-3.4/cffi
    copying cffi/parse_c_type.h -> build/lib.linux-armv7l-3.4/cffi
    copying cffi/_embedding.h -> build/lib.linux-armv7l-3.4/cffi
    running build_ext
    building '_cffi_backend' extension
    creating build/temp.linux-armv7l-3.4
    creating build/temp.linux-armv7l-3.4/c
    arm-linux-gnueabihf-gcc -pthread -DNDEBUG -g -fwrapv -O2 -Wall -Wstrict-prototypes -g -fstack-protector-strong -Wformat -Werror=format-security -D_FORTIFY_SOURCE=2 -fPIC -DUSE__THREAD -DHAVE_SYNC_SYNCHRONIZE -I/usr/include/ffi -I/usr/include/libffi -I/srv/homeassistant/include -I/usr/include/python3.4m -c c/_cffi_backend.c -o build/temp.linux-armv7l-3.4/c/_cffi_backend.o
    c/_cffi_backend.c:15:17: fatal error: ffi.h: No such file or directory
     #include <ffi.h>
                     ^
    compilation terminated.
    error: command 'arm-linux-gnueabihf-gcc' failed with exit status 1
    
    ----------------------------------------
Command "/srv/homeassistant/bin/python3 -u -c "import setuptools, tokenize;__file__='/tmp/pip-build-z7skk7rm/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-3d0rc0rk-record/install-record.txt --single-version-externally-managed --compile --install-headers /srv/homeassistant/include/site/python3.4/cffi" failed with error code 1 in /tmp/pip-build-z7skk7rm/cffi/``````````````

Is this your first time using Python?
If you just installed it, it’s probably not yet in the PATH of your shell.
Try restarting, that’s a sure-fire way to get an up to date shell.

1 Like

Yea. The Apple TV stuff is pretty bad.

I just use an IR blaster on my atv4. I tried some pytv and the hass component but they wouldn’t work for controlling the interface. the documentation was bad too. It doesn’t say what works and what models. It was mostly frustrating.

I don’t use it as an automatic media player.

Good luck.

1 Like

It says in the output that ffi.h is missing, which means that you are missing a dependency. Try running this (I just googled for the error):

sudo apt-get install build-essential libssl-dev libffi-dev python-dev

Then re-install pyatv and you should be fine.

2 Likes

I have an open PR with a lot of updates to the Apple TV platform. Once that is merged it should work better and more features (like remote control) will be available. Better support for the ATV4 will not be available until I have device that I can try with, I only own the 3rd generation.

3 Likes

The PR was merged yesterday, so it will be available in the next release. If you run from dev, feel free to give a spin and report any issues!

1 Like