Apple TV Plugin: Intro

Posted on
Sat Mar 27, 2021 7:29 pm
kw123 offline
User avatar
Posts: 8366
Joined: May 12, 2013
Location: Dallas, TX

Apple TV Plugin: Intro

This plugin will read apple tv configs, settings, what is playing etc.
A next version it will also be able to set parameters ..

Each apple tv will create an indigo device type AppleTV
Screen Shot 2021-03-27 at 20.21.47.png
Screen Shot 2021-03-27 at 20.21.47.png (77.56 KiB) Viewed 857 times


=== you need to install
1. install x-code, in a terminal window
xcode-select —install

2. install python3 (do not use home-brew) >>> if you don't have it already on your mac<<<
after Xcode install you might have python3 also installed
test with
which python3
and/or
python3 --version
you should get something like this if it is already installed
Code: Select all
mini-09:43:15 indigo 22:which python3
/usr/bin/python3
mini-09:59:51 indigo 23:python3 --version
Python 3.8.2
if not:
go to https://www.python.org/downloads/release/python-392/
and download the 64 bit installer and install (all point and click)

3. download /install pyatv, in a terminal window
pip3 install pyatv

In config you only need to set one parameter: the path to python3. It is set to "/usr/local/bin/python" by default
Screen Shot 2021-03-27 at 20.26.47.png
Screen Shot 2021-03-27 at 20.26.47.png (85.98 KiB) Viewed 857 times

download at: https://www.indigodomo.com/pluginstore/248/

In device edit you can change the IP number of the appleTV if it changed, or delete it and in menu do a scan for new apple tv devices. It will be added automatically with the new IP number.

Most of the work was done by Postlund, who wrote PYATV.
see: https://github.com/postlund/pyatv


# =================== HELP for appleTV plugin===========================
## **credits**
This plugin is build on top of AVTpy by Postlund, see https://github.com/postlund/pyatv

## STEPS TO MAKE IT WORK
1. INSTALL X-CODE , in a terminal window
xcode-select —install

2. INSTALL PYTHON3 - if you don't have it on your mac (do not use home-brew)
go to eg https://www.python.org/downloads/release/python-392/
and download the 64 bit installer and install (all point and click)

3. DOWNLOAD/INSTALL, pyatv in a terminal window
pip3 install pyatv

path to python either /usr/local/bin/python3 for 10.14.x and earlier (w pip3 install)
or /usr/bin/python3 for 11.x and later)
Try 'which python3' in a terminal window to check for path on your MAC)

## WHAT DOES IT DO:
1. it scans the local network for apple TVs with atvscript.py scan
2. then is lauchnes a listener for any change of channel, volume, dev state etc and populates the indigo dev states accordingly
3. every xx minutes it will rescan for new apple TVs - or you can manually scan in plugin/menu
4. you can send predefined commands selectable from a list in menu or action to the apple TVs
5. you can send free text commands in menu or action to the apple TVs, see below for list
6. you can set certain IP numbers to be ignored, change ip number / mac# of an apple device in device edit if that has changed
-- not yet implemented: play music / video on apple TV. That requires to sync a pin between the apple TV and the plugin

## Possible things that can go wrong:
dev state: 'Unclosed client session' or something like it
try to use iphone remote app to connect to the appleTV. If that does not work a power cycle appleTV should fix it

## AVAILABE COMMANDS IN MENU AND ACTION

### RREMOTE CONTROLL COMMANDS:
- down - Press key down
- home - Press key home
- home_hold - Hold key home
- left - Press key left
- menu - Press key menu
- next - Press key next
- pause - Press key play
- play - Press key play
- play_pause - Toggle between play and pause
- previous - Press key previous
- right - Press key right
- select - Press key select
- set_position - Seek in the current playing media
- set_repeat - Change repeat state
- set_shuffle - Change shuffle mode to on or off
- skip_backward - Skip backwards a time interval
- skip_forward - Skip forward a time interval
- stop - Press key stop
- suspend - Suspend the device
- top_menu - Go to main menu (long press menu)
- up - Press key up
- volume_down - Press key volume down
- volume_up - Press key volume up
- delay=xxxx - Sleep for a certain amount in milliseconds before next command eg when you send 2 or more commands

### POWER COMMANDS:
- power_state - Return device power state
- turn_off - Turn device off
- turn_on - Turn device on

### METADATA COMMANDS, PRINTED TO LOG
- app - Return information about current app playing something
- artwork - Return artwork for what is currently playing (or None)
- artwork_id - Return a unique identifier for current artwork
- device_id - Return a unique identifier for current device
- playing - Return what is currently playing

### PLAYING COMMANDS: - print result to log
- album - Album of the currently playing song
- artist - Artist of the currently playing song
- device_state - Device state, e.g. playing or paused
- genre - Genre of the currently playing song
- hash - Create a unique hash for what is currently playing
- media_type - Type of media is currently playing, e.g. video, music
- position - Position in the playing media (seconds)
- repeat - Repeat mode
- shuffle - If shuffle is enabled or not
- title - Title of the current media, e.g. movie or song name
- total_time - Total play time in seconds

### DEVICE COMMANDS:
- artwork_save - Download artwork and save it to artwork.png
- features - Print a list of all features and options

## NOT IMPLEMENTED YET, needs pairing --
### AirPlay commands:
- play_url - Play media from an URL on the device

===============================================================================
Karl

Page 1 of 1

Who is online

Users browsing this forum: No registered users and 1 guest