Skip to content

About

No description, website, or topics provided.

Resources

Stars

1 star

Watchers

0 watching

Forks

Latest commit

 

History

1 Commit

Folders and files

Repository files navigation

Fire TV Remote (Django)

A local web app that turns any phone, tablet, or laptop browser into a touch remote for a Fire TV Stick. Button taps hit a Django endpoint on your machine, which runs the matching adb command against the Fire TV over Wi-Fi.

Architecture

browser (phone/tablet/laptop)
    |  HTTP (fetch / POST)
    v
Django server (this project, runs on your machine)
    |  subprocess -> adb
    v
adb (Android Debug Bridge, over Wi-Fi, port 5555)
    |
    v
Fire TV Stick

There is no database, no accounts, and no build step. The frontend is a single Django template (HTML, CSS, and vanilla JavaScript in one file), and the backend is a small set of Django views that shell out to adb.

Tech stack

  • Python 3, Django 4.2 (see requirements.txt)
  • adb (Android Debug Bridge), invoked via subprocess, for all device control (key events, app launches, text input, network discovery)
  • Vanilla HTML, CSS, and JS frontend, no framework, no build tooling
  • Web Speech API (SpeechRecognition) in the browser for voice input
  • Python socket and concurrent.futures for LAN device discovery, no external scanning library

Project structure

manage.py
requirements.txt
firetv_remote/
    settings.py       Django settings, including the fallback FIRETV_ADDRESS
    urls.py           root URL config
remote/
    apps.py
    urls.py           API routes
    views.py          adb command logic, device discovery, all endpoints
    templates/remote/index.html   the entire UI
    static/remote/

One-time setup

On the Fire TV Stick:

  • Settings, My Fire TV, About, click the device name repeatedly until Developer Options unlocks
  • Settings, My Fire TV, Developer Options, turn on ADB Debugging

On the machine that will run the server:

sudo apt install adb
pip install -r requirements.txt --break-system-packages

Finding and selecting your Fire TV

You do not need to know the Fire TV's IP address ahead of time. In the app, tap Devices to open the device picker:

  • Scan this network probes every address on your current subnet for an open adb port and, where possible, reads the device model so you can tell Fire TV Sticks apart from other devices.
  • Tap Connect next to a result to select it. The choice is saved to device_state.json (created next to manage.py) so it persists across server restarts.
  • If scanning does not find it, you can also type an IP address in manually.

This means the same app works on any network. Take your ThinkPad to a different house, scan, and pick that house's Fire TV.

firetv_remote/settings.py still has a FIRETV_ADDRESS value. That is only used the very first time the server runs, before any device has been selected through the UI.

Running the server

python manage.py runserver 0.0.0.0:8000

0.0.0.0 makes it reachable from other devices on the network, not just the machine running the server.

Opening the remote

On any device on the same Wi-Fi network:

http://<server-machine-IP>:8000

For example: http://192.168.12.184:8000

Add it to your phone's home screen (Share, Add to Home Screen on iOS; browser menu, Add to Home Screen on Android) so it opens full screen.

Features

  • D-pad with center select, back, home, and menu
  • Playback controls: rewind, play/pause, fast forward
  • Volume up, mute, and down, plus a media session fallback command since Fire TV forwards volume to the TV over HDMI CEC and does not always accept a plain key event from third party apps
  • Voice input using the browser's own microphone (Web Speech API). Speech is transcribed locally in the browser and only the resulting text is sent to the server, which types it into Fire TV's search. Falls back to a remote key event if the browser or connection does not support it.
  • App shortcuts, configurable in the APPS dictionary in remote/views.py
  • Live connection status with automatic reconnect and retry when the adb connection to the Fire TV drops
  • Network scan and device picker, described above

API endpoints

Method Path Purpose
GET / Renders the remote UI
POST /api/press// Sends a key event (up, down, select, etc.)
POST /api/launch/<app_name>/ Launches an app from the APPS dictionary
POST /api/voice-text/ Types transcribed voice text into Fire TV
POST /api/connect/ Reconnects adb to the selected device
GET /api/devices/scan/ Scans the LAN for adb reachable devices
POST /api/devices/select/ Selects and connects to a device
GET /api/devices/current/ Returns the currently selected device

Reliability notes

  • adb over Wi-Fi drops occasionally, for example on idle timeouts or when the TV sleeps. The server detects connection related errors and retries once after reconnecting, so most button presses recover on their own.
  • The UI debounces rapid repeat taps on the same button and guards against piling up duplicate in-flight requests.
  • Requests time out client side after 8 seconds so a stuck command never leaves a button looking unresponsive indefinitely.

Security notes

This project is meant for a home network only.

  • DEBUG = True and ALLOWED_HOSTS = ["*"] are acceptable for local use but this should not be exposed to the public internet as is. There is no login, no HTTPS, and no rate limiting.
  • Anyone on the same Wi-Fi network can control the Fire TV, and can scan the local subnet for other devices, while the server is running. That is normally fine for a household but worth knowing on a shared network.
  • Voice input requires a secure browsing context, HTTPS or localhost, for the browser to prompt for microphone access. Loading the app over plain HTTP at a LAN IP address will not show a microphone prompt. This is a browser restriction, not a bug in this app.

Troubleshooting

  • Status stays disconnected: confirm ADB Debugging is still on in the Fire TV's Developer Options, then use Devices, Scan to reselect it, since its IP can change if the router reassigns it.
  • "adb is not installed" error: run sudo apt install adb on the machine running the Django server, not the Fire TV.
  • Volume does nothing: check Settings, Display and Sounds, HDMI CEC on the Fire TV. Volume is forwarded to the TV over CEC and cannot be intercepted directly by third party apps if CEC is off.
  • Voice button does not prompt for microphone access: the app is most likely being loaded over plain HTTP at a LAN IP. Use HTTPS, or on the client browser enable chrome://flags/#unsafely-treat-insecure-origin-as-secure and add the app's URL as a trusted origin.
  • Buttons work but app launches fail: the package name in views.py may be out of date, since Fire TV app package names occasionally change between updates. List installed packages with:
    adb -s <fire-tv-ip>:5555 shell pm list packages

About

No description, website, or topics provided.

Resources

Stars

1 star

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages