This binding is designed to emulate different protocols to interact with the AndroidTV platform.
I would GREATLY appreciate feedback from users even if to just confirm that it’s working as expected. Please include device model and software version so I can add it to the readme as confirmed working.
AndroidTV Binding
This binding is designed to emulate different protocols to interact with the AndroidTV platform.
Currently it emulates both the Google Video App to interact with a variety of AndroidTVs for purposes of remote control.
It also currently emulates the Nvidia ShieldTV Android App to interact with an Nvidia ShieldTV for purposes of remote control.
Supported Things
This binding supports two thing types:
- googletv - An AndroidTV running Google Video
- shieldtv - An Nvidia ShieldTV
Discovery
Both GoogleTVs and ShieldTVs should be added automatically to the inbox through the mDNS discovery process.
In the case of the ShieldTV, OpenHAB will likely create an inbox entry for both a GoogleTV and a ShieldTV device.
Only the ShieldTV device should be configured, the GoogleTV can be ignored.
There is no benefit to configuring two things for a ShieldTV device. This could cause undesired effects.
Binding Configuration
This binding does not require any special configuration files.
This binding does require a PIN login process (documented below) upon first connection.
This binding requires GoogleTV to be installed on the device (https://play.google.com/store/apps/details?id=com.google.android.videos)
Thing Configuration
There are three required fields to connect successfully to a ShieldTV.
Name | Type | Description | Default | Required | Advanced |
---|---|---|---|---|---|
ipAddress | text | IP address of the device | N/A | yes | no |
keystore | text | Location of the Java Keystore | N/A | no | no |
keystorePassword | text | Password of the Java Keystore | N/A | no | no |
Thing androidtv:shieldtv:livingroom [ ipAddress="192.168.1.2" ]
Thing androidtv:googletv:theater [ ipAddress="192.168.1.3" ]
Channels
Channel | Type | Description | GoogleTV | ShieldTV |
---|---|---|---|---|
keyboard | String | Keyboard Data Entry | RW | RW |
keypress | String | Manual Key Press Entry | RW | RW |
keycode | String | Direct KEYCODE Entry | RW | RW |
pincode | String | PIN Code Entry | RW | RW |
app | String | App Control | RO | RW |
appname | String | App Name | N/A | RW |
appurl | String | App URL | N/A | RW |
power | Switch | Power Control | RW | RW |
volume | Dimmer | Volume Control | RO | RO |
mute | Switch | Mute Control | RW | RW |
String ShieldTV_KEYBOARD "KEYBOARD [%s]" { channel = "androidtv:shieldtv:livingroom:keyboard" }
String ShieldTV_KEYPRESS "KEYPRESS [%s]" { channel = "androidtv:shieldtv:livingroom:keypress" }
String ShieldTV_KEYCODE "KEYCODE [%s]" { channel = "androidtv:shieldtv:livingroom:keycode" }
String ShieldTV_PINCODE "PINCODE [%s]" { channel = "androidtv:shieldtv:livingroom:pincode" }
String ShieldTV_APP "APP [%s]" { channel = "androidtv:shieldtv:livingroom:app" }
String ShieldTV_APPNAME "APPNAME [%s]" { channel = "androidtv:shieldtv:livingroom:appname" }
String ShieldTV_APPURL "APPURL [%s]" { channel = "androidtv:shieldtv:livingroom:appurl" }
Switch ShieldTV_POWER "POWER [%s]" { channel = "androidtv:shieldtv:livingroom:power" }
Dimmer ShieldTV_VOLUME "VOLUME [%s]" { channel = "androidtv:shieldtv:livingroom:volume" }
Switch ShieldTV_MUTE "MUTE [%s]" { channel = "androidtv:shieldtv:livingroom:mute" }
String GoogleTV_KEYBOARD "KEYBOARD [%s]" { channel = "androidtv:googletv:theater:keyboard" }
String GoogleTV_KEYPRESS "KEYPRESS [%s]" { channel = "androidtv:googletv:theater:keypress" }
String GoogleTV_KEYCODE "KEYCODE [%s]" { channel = "androidtv:googletv:theater:keycode" }
String GoogleTV_PINCODE "PINCODE [%s]" { channel = "androidtv:googletv:theater:pincode" }
String GoogleTV_APP "APP [%s]" { channel = "androidtv:googletv:theater:app" }
Switch GoogleTV_POWER "POWER [%s]" { channel = "androidtv:googletv:theater:power" }
Dimmer GoogleTV_VOLUME "VOLUME [%s]" { channel = "androidtv:googletv:theater:volume" }
Switch GoogleTV_MUTE "MUTE [%s]" { channel = "androidtv:googletv:theater:mute" }
KEYPRESS will accept the following commands as strings (case sensitive):
- KEY_UP
- KEY_DOWN
- KEY_RIGHT
- KEY_LEFT
- KEY_ENTER
- KEY_HOME
- KEY_BACK
- KEY_MENU
- KEY_PLAY
- KEY_PAUSE
- KEY_PLAYPAUSE
- KEY_STOP
- KEY_NEXT
- KEY_PREVIOUS
- KEY_REWIND
- KEY_FORWARD
- KEY_POWER
- KEY_GOOGLE
- KEY_VOLUP
- KEY_VOLDOWN
- KEY_MUTE
- KEY_SUBMIT
The list above causes an instantanious “press and release” of each button.
If you would like to manually control the press and release of each you may append _PRESS and _RELEASE to the end of each.
(e.g. KEY_FORWARD_PRESS or KEY_FORWARD_RELEASE)
You may also send an ASCII character as a single letter to simulate a key entry (e.g KEY_A, KEY_1, KEY_z).
Use KEY_SUBMIT when full text entry is complete to tell the shield to process the line.
KEY_SUBMIT is automatically sent by KEYBOARD when a command is sent to the channel.
APP will display the currently active app as presented by the AndroidTV.
You may also send it a command of the app package name (e.g. com.google.android.youtube.tv) to start/change-to that app.
KEYCODE values are listed at the bottom of this README.
NOTE: Not all KEYCODES work on all devices. Keycodes above 255 have not been tested.
Pin Code Process
For the AndroidTV to be successfully accessed an on-screen PIN authentication is required on the first connection.
To begin the PIN process, send the text “REQUEST” to the pincode channel while watching your AndroidTV. A 6 digit PIN should be displayed on the screen.
To complete the PIN process, send the PIN displayed to the pincode channel. The display should return back to where it was originally.
If you are on a ShieldTV you must run that process a second time to authenticate the GoogleTV protocol stack.
This completes the PIN process. Upon reconnection (either from reconfiguration or a restart of OpenHAB), you should now see a message of “Login Successful” in openhab.log
Full Example
Thing androidtv:shieldtv:livingroom [ ipAddress="192.168.1.2" ]
Thing androidtv:googletv:theater [ ipAddress="192.168.1.3" ]
String ShieldTV_KEYBOARD "KEYBOARD [%s]" { channel = "androidtv:shieldtv:livingroom:keyboard" }
String ShieldTV_KEYPRESS "KEYPRESS [%s]" { channel = "androidtv:shieldtv:livingroom:keypress" }
String ShieldTV_KEYCODE "KEYCODE [%s]" { channel = "androidtv:shieldtv:livingroom:keycode" }
String ShieldTV_PINCODE "PINCODE [%s]" { channel = "androidtv:shieldtv:livingroom:pincode" }
String ShieldTV_APP "APP [%s]" { channel = "androidtv:shieldtv:livingroom:app" }
String ShieldTV_APPNAME "APPNAME [%s]" { channel = "androidtv:shieldtv:livingroom:appname" }
String ShieldTV_APPURL "APPURL [%s]" { channel = "androidtv:shieldtv:livingroom:appurl" }
Switch ShieldTV_POWER "POWER [%s]" { channel = "androidtv:shieldtv:livingroom:power" }
Dimmer ShieldTV_VOLUME "VOLUME [%s]" { channel = "androidtv:shieldtv:livingroom:volume" }
Switch ShieldTV_MUTE "MUTE [%s]" { channel = "androidtv:shieldtv:livingroom:mute" }
String GoogleTV_KEYBOARD "KEYBOARD [%s]" { channel = "androidtv:googletv:theater:keyboard" }
String GoogleTV_KEYPRESS "KEYPRESS [%s]" { channel = "androidtv:googletv:theater:keypress" }
String GoogleTV_KEYCODE "KEYCODE [%s]" { channel = "androidtv:googletv:theater:keycode" }
String GoogleTV_PINCODE "PINCODE [%s]" { channel = "androidtv:googletv:theater:pincode" }
String GoogleTV_APP "APP [%s]" { channel = "androidtv:googletv:theater:app" }
Switch GoogleTV_POWER "POWER [%s]" { channel = "androidtv:googletv:theater:power" }
Dimmer GoogleTV_VOLUME "VOLUME [%s]" { channel = "androidtv:googletv:theater:volume" }
Switch GoogleTV_MUTE "MUTE [%s]" { channel = "androidtv:googletv:theater:mute" }
Google Keycodes
Google Keycodes can be found at the bottom of the readme file found at openhab-addons/README.md at androidtv · morph166955/openhab-addons · GitHub
Confirmed/Unconfirmed Models
Year | Name | Model | Android Ver | Shield Ver | OH4.0.0 | OH3.4.0 | Unverified |
---|---|---|---|---|---|---|---|
2015 | Shield TV | P2571 | X | ||||
2015 | Shield TV Pro | P2571 | X | ||||
2017 | Shield TV | P2897 | 11 | 9.1.1 | X | X | |
2017 | Shield TV Pro | P2571 | 11 | 9.1.1 | X | ||
2019 | Shield TV | P3430 | X | ||||
2019 | Shield TV Pro | P2897 | 11 | 9.1.1 | X |
Changelog
Version 0.08.1 (0e87cd3)
- Adds KEY_PLAY and KEY_PAUSE
Version 0.08 (d95ad7b)
- Adds servicePing to protocols
Version 0.07 (0811ce0)
- Fixes exception from individual app updates
- Adds additional logging
- Adds backwards compatibility to pom
Version 0.06.5 (74d1758)
- Minor bug fixes and code updates
Version 0.06.4 (2d02a80)
- Fixes keepalive bug causing reconnect before PIN completes
Version 0.06.3 (1fa8869)
- Fixes IPv6 issue with discovery
Version 0.06.2 (c6f7682)
- Small update to PIN process for misbehaving devices
- Updated jar to align with Karaf 4.4.3 update
Version 0.06.1 (df2f6a6)
- Bug updates
- Logger updates
Version 0.06 (152e942)
- Adds googletv protocol to binding.
Version 0.05.2 (1fd00be)
- Fixes regression from appdb fixes in PIN process
Version 0.05.1 (eb1eeb0)
- Adds KEY_SUBMIT
- Sorts appNameDB for DynamicCommand metadata
Version 0.05 (3dd2aa1)
- Adds KEYBOARD and KEY_(ASCII Character)
- More appdb fixes
- Updates to parser to avoid issues
Version 0.04.1 (dafb2a9)
- Adds DynamicCommandDescriptionProvider
- Fixes appdb bugs
- Adds periodic scheduled updates
Version 0.03 (53740f7)
- Thing status reworked
- Bug fixes
Version 0.02 (94ebc2f)
- Adds KEY_VOLUP, KEY_VOLDOWN, KEY_MUTE
- Optimizes message handler
Version 0.01 (342d4f9)
- Initial merge in from shieldtv to androidtv
To-Do
- GoogleTV: Make VOLUME R/W
- GoogleTV: Make APP R/W