Active TopicsActive Topics  Display List of Forum MembersMemberlist  Search The ForumSearch  HelpHelp
  RegisterRegister  LoginLogin
PowerHome Programming
 PowerHome Messageboard : PowerHome Programming
Subject Topic: Fire TV control via PH Post ReplyPost New Topic
Message << Prev Topic | Next Topic >>
Super User
Super User

Joined: May 21 2006
Location: United States
Online Status: Offline
Posts: 701
Posted: June 18 2018 at 20:02 | IP Logged Quote smarty

I am starting this thread to document my efforts towards getting PH to control the Fire TV boxes that I have attached to each of my TV's.

I am doing this for a number of reasons, including:
1) I have recently gotten rid of my cable boxes and fully rely upon the internet for all media content.

2) I have Echo Dot's in all rooms of the house. From these, I can issue voice commands to natively control some aspects of the Fire TV (app launching, pause/play, and the "home" command). Additionally, I use other voice commands through a Hue Bridge Emulator (that points back to PH via the PH web server) to turn "on/off" or "set" anything else that I have controllable from PowerHome.

Since all of my TV's are controllable via two-way serial control, I can tell Alexa to "Turn on the Bedroom TV", and a PH macro will turn on the TV, set it to the right input and even adjust the volume; but if the Fire TV box is sleeping, the TV screen is dark and it looks like the TV isn't on (until you send the Fire TV a signal to wake it up or lunch an app). So that it why I starting looking into Fire TV control.

After some Google searching, this is what I have come up with so far.

Step 1 - Download and install ADB - "Android Debug Bridge". I used the 15_Second ADB installer here:
(use at your own risk - I hope it's not malware).

Step 2 - Enable ADB Debugging on your Fire TV device.

Step 3 - ph_run("c:\adb\adb start-server")
This starts an "adb.exe" process

Step 4 - ph_run("c:\adb\adb.exe connect 192.168.0.XXX")
This connects to the Fire TV you want to control

You can verify the connection via a DOS command window by typing: "c:\adb\adb.exe devices"

Once connected, there are a number of commands you can run, including app launching:
ph_run("adb shell monkey -p org.xbmc.kodi 1")
ph_run("adb shell monkey -p 1")
ph_run("adb shell monkey -p 1")
ph_run("adb shell monkey -p com.silicondust.view 1")
Above are the four are what I most use.

There is keypad and alpha keyevent like:
"c:\adb\adb.exe shell input keyevent 62"<=space key
"c:\adb\adb.exe shell input keyevent 51"<= w key
"c:\adb\adb.exe shell input keyevent 3" <= Home key
"c:\adb\adb.exe shell input keyevent 26" <=sleep toggle

Once your done, you can disconnect from the Fire TV by:
"c:\adb\adb.exe disconnect 192.168.0.XXX"

and then you can stop the "ADB.exe" server process by:
"c:\adb\adb.exe kill-server"

Note - I wrap most of my commands with the ph_run("") function. This works OK if there is no command feedback. But there are a number of ADB commands that could give very useful feedback to PowerHome (if there was a way to pass the information back into PH - this is what I need help with).

ADB commands like:   
"adb shell pm list packages -f" <= lists all the installed packages on your Fire TV device.
Parsing this list lets you launch individual apps

The "c:\adb\adb.exe devices" command could also tell PH which Fire TV devices you are presently connected to.

Any help here would be appreciated.

Here are some links as footnotes/resources I found useful:
"15 Sec ADB Installer" Ver 1.4.3 ost48915118 re-tv-or-fire-tv-stick-via-adb/ .html tv-stick-via-adb/

Elk - Insteon - BlueIris - DMC1 - PowerHome - XLobby - HA_Bridge w/Dots - Brultech
Back to Top View smarty's Profile Search for other posts by smarty
Admin Group
Admin Group

Joined: June 29 2001
Location: United States
Online Status: Offline
Posts: 4335
Posted: June 20 2018 at 07:11 | IP Logged Quote dhoward


It looks like a lot of what you've posted here is what Ive got in the ADB Fire TV plugin (nearly the same code just wrapped up as a plugin). I have not
yet worked on receiving data (just sending like you've done). If you do make any headway into that arena, let me know and I'll update the plugin code
(or you can when I release the source ).

I'll be curious how reliable the code above is for you and if you experience any hanging. The plugin will work all right for awhile and then just quit
requiring the Fire TV to be reset and/or ADB to be reset. Not sure if this is a problem with ADB or the way Ive coded the plugin so interested in the
mileage you get.

Back to Top View dhoward's Profile Search for other posts by dhoward Visit dhoward's Homepage

If you wish to post a reply to this topic you must first login
If you are not already registered you must first register

  Post ReplyPost New Topic
Printable version Printable version

Forum Jump
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot delete your posts in this forum
You cannot edit your posts in this forum
You cannot create polls in this forum
You cannot vote in polls in this forum