Skip to main content

Google TV / Android TV Remote Control CLI

Project description

GTV - Google TV / Android TV Remote Control CLI

A command-line remote control for Android TV and Google TV devices. Uses the Android TV Remote protocol v2 -- the same protocol the official Google TV mobile app uses. Built with cmd2 for a rich interactive shell with tab completion, command history, and categorized help.

No ADB or developer mode required. Works over your local network via IP.

Features

  • Device Discovery -- Finds Android TV / Google TV devices on your network via mDNS
  • Bluetooth Discovery -- Scan for nearby Android TV devices via Bluetooth Low Energy
  • Secure Pairing -- Certificate-based pairing with on-screen PIN (same as the mobile app)
  • Full Remote Control -- Navigation, media, volume, power, number keys, color keys
  • App Launching -- YouTube, Netflix, Disney+, Prime Video, and more with shortcuts
  • Deep Links -- Open any URL or deep link on the TV
  • Tab Completion -- Complete app names, key codes, and commands with Tab
  • Command History -- Navigate previous commands with arrow keys
  • Categorized Help -- Commands organized by function (Navigation, Media, Volume, etc.)
  • One-shot Commands -- Send a single command without entering interactive mode
  • Async Notifications -- Real-time device status updates (power, app changes, volume)

Requirements

  • Python 3.9+
  • An Android TV / Google TV device on the same network
  • The Android TV Remote Service (pre-installed on most devices)

Installation

From PyPI:

pip install gtv-remote

From source:

git clone https://github.com/erodriguez/gtv-remote.git
cd gtv-remote
pip install .

For development:

pip install -e .

Project Structure

gtv/
├── __init__.py
├── __main__.py
├── cli.py
├── app.py
├── constants.py
├── models.py
├── remote.py
└── discovery/
    ├── __init__.py
    ├── mdns.py
    └── bluetooth.py

Quick Start

gtv-remote
gtv-remote discover
gtv-remote discover -b
gtv-remote pair 192.168.1.100
gtv-remote connect 192.168.1.100

Usage

Discover Devices

gtv-remote discover
gtv-remote discover --timeout 10
gtv-remote discover -b
gtv-remote discover -b -a

Pair with a Device

Pairing is required once per device. A PIN code will appear on your TV screen.

gtv-remote pair
gtv-remote pair 192.168.1.100

Certificates are stored in ~/.config/gtv/.

Interactive Remote Control

gtv-remote
gtv-remote connect
gtv-remote connect 192.168.1.100

Once connected, the prompt shows the device IP and power state:

gtv (192.168.1.100 [on])> _

Type help to see all commands organized by category:

Apps & Input        app, key, open
Connection          connect, disconnect, discover, pair
Device Info         apps, keys, status
Media               play, pause, playpause, stop, next, prev, rewind, ff, ...
Navigation          up, down, left, right, enter, back, home, menu, ...
Number Keys         0-9, red, green, yellow, blue
Volume & Power      volup, voldown, mute, power

Command Reference

Command Action
Navigation
up down left right D-pad navigation
enter / select / ok Confirm selection
back Go back
home Home screen
menu Open menu
settings Open settings
search Open search
assist Google Assistant
Media
play pause playpause Media playback
stop next prev Track control
rewind ff Seek
captions Toggle subtitles
chup chdown Channel up/down
Volume & Power
volup [N] Volume up (optionally N times)
voldown [N] Volume down (optionally N times)
mute Toggle mute
power Power on/off
Apps
app youtube Launch YouTube
app netflix Launch Netflix
app disney Launch Disney+
app prime Launch Prime Video
app <package.id> Launch any app by package
open <url> Open a deep link
apps List all app shortcuts
Input
key DPAD_UP Send raw remote key
keys List all key codes
Info
status Show device info
discover Re-scan for devices

Tab Completion

Press Tab to auto-complete:

  • Command names
  • App shortcut names (after app )
  • Raw key codes (after key )

One-Shot Commands

gtv-remote send --host 192.168.1.100 home
gtv-remote send --host 192.168.1.100 volup
gtv-remote send --host 192.168.1.100 playpause
gtv-remote send --host 192.168.1.100 app youtube
gtv-remote send --host 192.168.1.100 key POWER

Device Status

gtv-remote status --host 192.168.1.100

App Shortcuts

Shortcut App
youtube YouTube
netflix Netflix
disney Disney+
prime / amazon Prime Video
kodi Kodi
plex Plex
hbo HBO Max
hulu Hulu
spotify Spotify
twitch Twitch
appletv Apple TV
crunchyroll Crunchyroll
browser Web Browser

You can also launch any app by its package name: app com.example.myapp

Troubleshooting

  • No devices found: Make sure your TV is on and connected to the same Wi-Fi network
  • Authentication failed: Run pair to re-pair with the device
  • Connection refused: Ensure the Android TV Remote Service is installed (Settings > Apps > Show system apps)
  • Pairing code not appearing: Restart the Android TV Remote Service or reboot the TV

How It Works

This tool uses the androidtvremote2 Python library which implements the Android TV Remote Control protocol v2. This is the same TLS-encrypted protocol used by the official Google TV mobile app. Communication happens over TCP ports 6466 (pairing) and 6467 (remote control). Device discovery uses mDNS (Zeroconf) to find _androidtvremote2._tcp.local. services. Bluetooth LE scanning uses bleak to detect nearby Android TV devices by name patterns and manufacturer data.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

gtv_remote-0.2.1.tar.gz (18.0 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

gtv_remote-0.2.1-py3-none-any.whl (17.6 kB view details)

Uploaded Python 3

File details

Details for the file gtv_remote-0.2.1.tar.gz.

File metadata

  • Download URL: gtv_remote-0.2.1.tar.gz
  • Upload date:
  • Size: 18.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.9.6

File hashes

Hashes for gtv_remote-0.2.1.tar.gz
Algorithm Hash digest
SHA256 1b5525cd6623b427ba1e8cc4494fc8c0817e0874c6583d91c56b00536f81651e
MD5 881765c9eefad882c8c29de8b2e3287a
BLAKE2b-256 fb1803c809b2c9ab67c97ce862b6e2e28d277d32e5a096fe6d6c4358dbdf4105

See more details on using hashes here.

File details

Details for the file gtv_remote-0.2.1-py3-none-any.whl.

File metadata

  • Download URL: gtv_remote-0.2.1-py3-none-any.whl
  • Upload date:
  • Size: 17.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.9.6

File hashes

Hashes for gtv_remote-0.2.1-py3-none-any.whl
Algorithm Hash digest
SHA256 f006907af604ba258c464a07f08959a48a622c36754c6020a099acdaf6deb047
MD5 533da2bc3425fc5b764a226146ac755d
BLAKE2b-256 0d450b9eb2544bd79d5d488c36aabe815774af4bfd0ae69fb26887737a1e6819

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page