Control your FireTv / AndroidTv over WiFi without ADB

Hi all,

I wanted a way to control my Fire TV and Chromecast with Google TV (here on I’ll just reference this as Fire TV) over WiFi/Ethernet so I could send commands to navigate the screen.

I tried ADB as an option but it was too slow and laggy. I wanted to make it feel as close to using the actual remote as I could but also ensure it was reliable and consistent.

So using a Pi Zero W/Pi Zero W2 I’ve created a way to control these media devices (and it should work for other media devices) which is fast and responsive.

We use the pi to emulate a USB Media Remote control and plug it into the Fire TV

The pi runs software to listen to commands and send them on to the Fire TV. At the moment the standard controls you’d find on a FireTV remote are supported. I’ve tried to make it as easy as possible to send commands so there are the following options:

  1. A WebSocket API
  2. A REST API
  3. A pure socket API (in theory this should be the most responsive)

The pi will also show a remote control web page that you can use from your phone.

The project can be found here: GitHub - foxy82/pi-usb-gadget-controller
and there are in depth instructions on how to set this up.

There is a roadmap in the README but one of the first things I want to do is be able to send all keyboard commands.

This is part of a bigger project that I’m still working on. In my house all of the Fire TV are in the loft where as the TVs are around the house. As such I’m also working on a (currently unpublished) companion app to capture commands from a USB remote and transmit them to the pi connected to the Fire TV so that the remote is as responsive as if the Fire TV wasn’t in the loft.

I’d be interested in your feedback.

2 Likes

I have just upgraded this to v0.3.0 which adds support for holding down keys.

When I use this in combination with another pi which is taking input from a USB remote and transmitting it over wifi to this receiver it feels as fast as if I was using the remote natively on the AndroidTV box.

Are there any plans for a Pico W Version?

Funny you should ask…I completed an early early alpha version last night based on the 8.0 circuit python release candidate.

Currently sitting in a private git repo and only supporting Consumer Control device (remote controls). I’m really excited to get a Pico w version out.

I’ll look to publish in a bit but need to figure a way to get log details back to make it robust.

I’ve made the repo public here - but this is a real alpha version and currently only works with Remote Controls.

Got it running on my Pico W. You going to keep using secrets.py or go to the new .env in the future?

I’ve not fully looked at .env but will probably use that if it is the best practice.

What did you connect it to? Connected to my android TV I was getting some disconnects that I need to look into. Also I’ll make it so that storage can be turned off as it showing as a usb drive as well and that is annoying.

Tried testing on My FireTV Cube V3, found out it turns off power to it’s usb Port when off.
Plugged in USB Keyboard. Key presses woke it up so running Kyyboard/Mouse Modes may keep it powered up. Might be a good Idea to enable the LED for now so show when its powered on.

I added Keyboard and Mouse yesterday. LED should be easy to add I’ll try to do that later today.

USB_OFF Doesn’t appear to remove flag.usb. I just get: "Cannot remount ‘/’ when visible via USB.
"
So far it seems the FireTV Cube V3 likes to turn off the usb port power when you press the power button on the remote. doesn’t seem to power back on with the power button either but does when pressing home key on the FTV Remote. I’ll have to try with a powered USB Hub.

You could add something like this to the code.py to set the hostname. later on you may add MDNS Hostname as well.

wifi.radio.hostname = "HARC"
print(f"Hostname: {wifi.radio.hostname}")

Yeah - if you can eject the drive on a PC it will work - not tried that on a FireTV yet. Otherwise if there is a file explorer on the FireTV you can delete it that way. It only really works if you have USB_OFF, do a USB_ON and then change your mind before restarting.

Good idea i’ll add that in.

In theory when they enable the Bluetooth on the picow (no eta) then you could connect the bluetooth to the Fire TV and it might work… although i’m unlikely to code that up as things currently stand I prefer the usb connection.

With more research, Amazon in all there wisdom decided to have the USB Port turn off when the FireTV Cube 3.0 goes to sleep. So people who use usb media keyboards, Gigabit ethernet adapters are having issues with it turning off. Hopefully there will be enough complaints that they’ll upgrade the firmware with an option to keep the USB port powered. I imagine they may have done it to make sure a usb camera can’t be accessed when its sleeping… Tested with a powered usb hub. the pico boots up about 10 seconds and then shuts down. And of course a lot of TV brands also turn off the port.
some of the newer TV’s can also use Wake on Lan. I Just wish the developers of these devices gave us options too keep ports active like USB and Wired Networks etc…

I do have 2 Gen 1 ,and 1 Gen 2 FireTV Cubes and A Chromcast W/Googe TV I can test this out on.

I hope they get bluetooth working on the pico soon. I’d like to get bluetooth midi working on one
for my Zynthian.

This is added - I’ve also split out the admin commands to a separate port so that they can be disabled if you want to. Finally I added a small html webpage to allow basic control. It has all been pretty rock solid for me - other than the Pico W can be a little fussy on USB cables - using some cables they just never started up.