This openHAB 2 Binding implements control for the Apple-TV devices. This includes sending remote keys (control the Apple-TV from openHAB). An upcoming version will also process the status updates to provide information about the media being played.
Author: Markus Michels (markus7017) Check https://community.openhab.org/t/binding-for-apple-tv for more information, questions and contributing ideas. Any comment is welcome!
Release: alpha2, check master branch for stable release
Known issues:
Please note: This is a beta release, it has bugs, requires manual install etc. Questions, feedback and contributions are welcome (e.g. improving this documentation).
Looking for contribution: If you are familar with HTML and CSS you are welcome to contribute a nice HABpanel widget. ;-)
Devices
Platforms
Thing | Type |
---|---|
device | Represents an Apple-TV device |
The binding supports auto discovery of Apple-TVs on the local network. Once the Apple-TV (using atvremote) the binding could discover the device. Integration of pairing functionality is planned for an upcoming release. For now you need to pair your device first (using atvremote cli) before performing auto discovery in Paper UI.
Proceed with Thing Configuration below.
For now the bindinng is not available on the Eclipse Smart Home Market Place nor part of the openHAB distribution so you need to install it manually.
As described the binding integrates the Phyton-based PyATV project so you need to install Python 3.5 and the required modules:
Platform software packages: sudo apt-get update sudo apt-get install python3.5 python3-pip libpython3.5 python3-jpy sudo apt-get install avahi-utils Python 3.5 for macOS can be found here: https://www.python.org/downloads/mac-osx/
Python modules: sudo python3.5 -m pip install pyatv zeroconf sh On macOS use Homebrew to install the Python 3.6(!) and additional modules. Make sure those modules go into the Python 3.5/3.6 folders. if you have multiple versions installed (by using the pip3.5/pip3.6 command).
Verification
You should verify the installation before installing/configuring the binding:
atvremote --address
The binding itself Copy the binding jar to openHAB's addons folder, add the thing in Paper UI (see below) and restart openHAB.
There are no textual configuration files.
Before adding the thing make sure that all pre-requisites are met and all modules have been installed (see above).
You could use Paper UI to run auto discvery from the Inbox or to add a thing manually
Group | Channel | Type |
---|---|---|
control | remoteKey | Send a key or key sequence to the Apple-TV, see below for valid keys |
----------- | ----------- | ---------------------------------------------------------------------------------- |
playStatus | playMode | Current play mode: No Media/Idle/Loading/Playing/Paused/Fast Forward/Fast Backward |
mediaType | Media type being played: None/Music/Video/TV/Unknown ] | |
title | Title of current media. ] | |
artist | Artist - only for Media Music ] | |
album | Album - only for Media Music ] | |
genre | Genre - only for Media Music ] | |
position | Position within the media. While playing the position gets updated in intervals. ] | |
The position could be changed, send the following format to the channel. ] | ||
+ |
||
- |
||
totalTime | Total time/duration of the media currently plaing. Note: could be 00:00:00! ] | |
shuffle | Music Shuffle Mode - True: shuffeling, False: no shuffeling ] | |
repeat | Music Repeat Mode - Off: no repeat, Track: repeat track, All: repeat playlis ] |
The following keys could ne semd with channel remoteKey
There are special keys, which will be mapped into a key sequence:
The key sequences can be configured in the thing settings if the defaults don't work for your setup. RThe sequence must match the order of the menu items on the main menu.
Note: You could also send a key sequence, e.g. "top_menu up up left left select"
Note: PaperUI is recommended, if you want to use text files make sure to replace the thing id from you channel definition
.things
.items String Atv_Remote "ATV [%s]" {channel="appletv:device:34fc39d8:control#remoteKey"}
.sitemap Switch item=Atv_Remote mappings=[up = "^" ] Switch item=Atv_Remote mappings=[left = "<", select = "Sel", right = ">" ] Switch item=Atv_Remote mappings=[menu = "Menu", down = " v ", play = "Play" ] Switch item=Atv_Remote mappings=[previous='Prev', pause='Pause', next='Next']
.rules // wakeup the Apple-TV sendCommand(Atv_Remote, "top_menu")
It integrates the PyATV Python library, which implements the protocol layer. The binding includes also platform specific stuff (jpy Java/Phyton bridge). All modules are included in the binding package and the binding tries to auto-select them. An upcoming version will allow to overwrite this auto-detection in case something went wrong or you have specific installation requirements.
Thanks postlund for his great work in contributing the PyATV library (https://github.com/postlund/pyatv) and the jpy team (https://github.com/bcdev/jpy).