Reference application: atvremote¶
To more easily test pyatv, the atvremote
application can be used. It is
bundled with pyatv and supports all the functionality implemented by the library.
So it is also a good place to go to for inspiration when implementing your own
application.
Discovering devices¶
If you want to automatically discover devices on your network, use the scan command:
$ atvremote scan
Found Apple TVs:
- Apple TV at 10.0.10.22 (hsgid: 00000000-1234-5678-9abc-def012345678)
In case you have multiple devices, they should all show up. The discovery
process is performed for 3 seconds, which might be too short and sometimes
a device might not show up. Either just try again or raise the discover
time with the -t flag, e.g. atvremote -t 10 scan
.
More details about the discovery process can be found here.
Specifying a device¶
You have two choices:
- Use
-a
that will perform the auto discover process and pick the first discovered command - Run
scan
yourself and manually specify IP-address and HSGID for device
Using the first option is easiest but also the slowest (you have to wait three seconds every time) and also works poorly with multiple devices. You can try it out like this:
$ atvremote -a <command>
To manually specify IP-address and HSGID, just do like this:
$ atvremote --adress <IP> --hsgid <HSGID>
Using these methods are mutually exclusive, so you may only pick one.
Working with commands¶
Several commands are supported by the library (and thus the device). Easiest
is just to use the command called commands
, as it will present a list of
availble commands:
$ atvremote -a commands
Remote control commands:
- play - Press key play
- down - Press key down
- left - Press key left
- right - Press key right
- previous - Press key previous
- topmenu - Go to top menu (long press menu)
- set_position - Seeks in the current playing media
- menu - Press key menu
- up - Press key up
- next - Press key next
- pause - Press key play
- select - Press key select
Metadata commands:
- artwork - Returns artwork for what is currently playing (or None)
- playing - Returns what is currently playing
Playing commands commands:
- position - Current position in the playing media (seconds)
- album - Album of the currently playing song
- play_state - Current play state, e.g. playing or paused
- artist - Artist of the currently playing song
- media_type - What type of media is currently playing, e.g. video, music
- total_time - Total play time in seconds
- title - Title of the current media, e.g. movie or song name
You can for instance get what is currently playing with playing
:
atvremote -a playing
album: None
artist: None
media_type: 1
play_state: 1
position: 0
title: None
total_time: 0
Or seek in the currently playing media:
atvremote -a set_position=123
Logging and debugging¶
You can enable additional debugging information by specifying either
--verbose
or --debug
. There are also some additional developer commands
that might be useful, if you also specify --developer
. They will
show up if you query all available commands.