IP / REST API for controlling Fire TV?

attunezero

Member
May 15, 2009
17
3
0
There does not seem to be an official documented API to send commands to the Fire TV via IP. The interface obviously exists and is used by the Fire TV Remote app. Does anybody know how to control the Fire TV via IP?
 

djsvetljo

Member
Oct 28, 2013
10
2
23
There does not seem to be an official documented API to send commands to the Fire TV via IP. The interface obviously exists and is used by the Fire TV Remote app. Does anybody know how to control the Fire TV via IP?
I need the same thing so I can control it via Tasker. Unfortunately, communication is encrypted and far from simple (I sniffed the traffic with IP captcher)
 

rbox

Recognized Developer
Apr 22, 2011
1,768
2,567
143
I need the same thing so I can control it via Tasker. Unfortunately, communication is encrypted and far from simple (I sniffed the traffic with IP captcher)
Well you could try decompiling the android apk and see if you can figure out what it's doing.
 

djsvetljo

Member
Oct 28, 2013
10
2
23
Well you could try decompiling the android apk and see if you can figure out what it's doing.
Unfortunately, my programming skills end with block diagrams, Tasker at most.

---------- Post added at 04:46 PM ---------- Previous post was at 04:42 PM ----------

BTW, do you know someone that knows SMALI? I need another app that needs a very simple change - doubling the output of one function. I was able to de-compile and find the function in .java but i can't compile it back to class/.smali (a friend of my helped me on this a bit).
 

despian

New member
Dec 12, 2017
2
1
0
If anyone is still interested it can be controlled by sending keyevents via adb. adb debugging must be enabled on the firetv and adb must be connected then you can send commands like so:

adb shell input keyevent KEYCODE_MEDIA_PLAY_PAUSE

A list of keycodes can be found here: developer dot amazon dot com/docs/fire-tv/remote-input.html#input-event-reference

I believe you can also find commands to start apps and things too.
 

djsvetljo

Member
Oct 28, 2013
10
2
23
If anyone is still interested it can be controlled by sending keyevents via adb. adb debugging must be enabled on the firetv and adb must be connected then you can send commands like so:

adb shell input keyevent KEYCODE_MEDIA_PLAY_PAUSE

A list of keycodes can be found here: developer dot amazon dot com/docs/fire-tv/remote-input.html#input-event-reference

I believe you can also find commands to start apps and things too.
Can you connect to ADB via network (wifi) ?
 

despian

New member
Dec 12, 2017
2
1
0
Can you connect to ADB via network (wifi) ?
Yes, that was my point. Sorry, thought that was implied.

I wrote this shell script to make sending the commands a bit easier. I use it in OpenHAB to control my FireTV via my home automation system Maybe somebody else might find it useful.

Code:
#!/bin/bash

# script to execute a comand on a fire tv via adb
# $1 : ip or hostname and connection port of firetv e.g. Snug-FireTV:5555
# $2 : command to execute

# array of available commands
declare -A COMMANDS=(
    ["UP"]="19"
    ["DOWN"]="20"
    ["LEFT"]="21"
    ["RIGHT"]="22"
    ["ENTER"]="66"
    ["BACK"]="4"
    ["HOME"]="3"
    ["MENU"]="KEYCODE_MENU"
    ["PLAYPAUSE"]="85"
    ["PREVIOUS"]="88"
    ["NEXT"]="87"
    ["WAKE"]="KEYCODE_POWER"
)

if [[ ! -z $1 && ${COMMANDS[$2]+_} ]]; then

    # check for existing connection and create new if none found
    CON=$(adb devices | grep $1 -c -i)
    if [ $CON -eq 0 ]; then
        adb connect $1
    fi

    # execute command
    adb -s "$1" shell input keyevent "${COMMANDS[$2]}"

fi
 
  • Like
Reactions: Chopperpilot