[Deprecated] Native support for Fire TV

You should also try restarting your Fire TV device(s). ADB can be kinda finicky about only connecting with one computer, and restarting the device seems to reset this.

Just tried the latest pure python adb firetv.py and got constant connection errors, went back to the debugging version and no problems.

That’s odd, I think the code is almost the same, minus the debugging log statements. Are you using get_sources: false in your configuration? I think that’s the only real difference – the “pure-python-adb” version will try to get the running apps unless you set get_sources: false, but the “pure-python-adb-debugging” version will not.

Thanks a lot for the pointers - I’ve tried all of these and am still struggling.

The full path to my config folder on my Ubuntu Hassio host is /usr/share/hassio/homeassistant/ and I have firetv.py in /custom_components/media_player under the homeassistant directory.

I get the same error messages re ADB no matter if the adbkey files are in the specified location or not and have tried the following variations in my config for the adbkey path:

/homeassistant/android/adbkey
/homeassistant/android/
/hassio//homeassistant/android/adbkey
hassio/homeassistant/android/
usr/share/hassio//homeassistant/android/adbkey
usr/share/hassio//homeassistant/android/

I think I may go and have a play with something else and will revisit this another time :slight_smile:

How about

/usr/share/hassio/homeassistant/android/adbkey

The full path should start with a /. And since it is supposed to be the path to the adbkey file, not folder, there should not be a trailing slash. There must also exist the file <your_adbkey_path>.pub. FYI, the reason why I’m focusing on the adbkey path is because HA checks to make sure that the two key files exist and won’t setup the component if they don’t. Since it tries to setup the component, my theory is that you are providing a relative path and HA is able to find the files, but the component expects a full path and does not find them.

Also, you’re not connecting to your Fire TV using the ADB binary via adb connect <ip_address>, right? Since you did that already and generated the key files, you do NOT want to do that again. The Fire TV only allows one connection, and you want that to be the one from the Python adb package used by this component.

@Picnic, did you try the latest “pure-python-adb” version with get_sources: false in your configuration? And did you remove firetv* folders from your /config/deps/** folders?

I think the latest “pure-python-adb” version is effectively equivalent to the debugging version, and I’d be perplexed if they behave differently.

Update for Hass.io users with ADB issues

I got the ADB server addon to install, and now it needs testers!

Step 1: the component

You’ll need to use this version of the component: firetv.py. The configuration should look like:

media_player:
  - platform: firetv
    name: Fire TV
    host: 192.168.0.111
    adb_server_ip: 127.0.0.1

Step 2: the addon

Install and configure the addon. All the necessary info can be found in the README.

Step 3: start the addon

Step 4: restart Home Assistant

I will test this. I will get it setup a little later. I have 3 fire devices. I can get 2 of the 3 working correctly most of the time. I have tweaked the component to send a home key press to power on from Idle. This triggers the HDMI CEC to power on the actual TV. Also I have also thought of this another way. And I have done a quick Qpython script running in the background on firetv. If someone could create a background service apk that runs in background of firetv and runs a local webserver with API. you can query for status and available sources, and launch apps…

That’s good to know about the Home command! I referenced your post in this GitHub issue.

The component can already launch apps, just use the media_player.select_source service and provide the app name. And with the latest version of the custom component from the “pure-python-adb” branch you can send custom commands via the media_player.firetv_adb_shell service; see the issue linked above for more info.

The addon doesn’t work in its current state, but if you’re able to fix it that would be much appreciated!

I’ll reply on the GitHub Issue. I’m aware it will launch apps via ADB.

My thought for the background app on the fire tv was to remedy the connection issues I have had keeping the FireTV’s online in HA. I am not well versed in JAVA to approach this. just a thought I have had in the past playing with python in android.

I misinterpreted your post – the Fire TV component used to work by sending REST commands to firetv-server, which is an http server that allows you to interact with a Python 2 environment running the firetv package. I thought that’s what you were referring to.

Once it works, I think the Hass.io ADB server addon will fix the connection issues that people encounter.

Tried latest pure python with the following config and no errors:
media_player:

  • platform: firetv
    name: Fire TV
    host: 192.168.1.97
    adbkey: “/config/adbkey”
    get_sources: false

Also tried the addon but it won’t install.

That’s good to hear!:+1:

Yeah, the addon doesn’t work… I need some help from someone who knows more about Docker/Hass.io addons than me!

Is there a way to disconnect the connection so that I can use adb from another source?
I’ve just been editing my config and restarting HA.

This is a great idea. @JeffLIrion i have been toying around with some ideas. Nothing put together yet. I have very little experience with Docker and hassio addons as well. @Picnic i want to add a feature like this to drop the adb connection from HA so it can be used else where. Also for current app state i use the aptoide api to return the friendly app names and icon png based off of package name. My though is the state to show the app instead of generic playing when in app… just thoughts i have come up with and trying to get time to make some process on it…

@Picnic and @chodyjones, the ability to disconnect and reconnect is an interesting idea, but I’m not sure how best to implement that. You’re welcome to submit a PR to either HA or my custom component!

@chodyjones, I don’t think HA would approve of using the app name as the status. But I believe the Android TV component (not yet merged) uses the app_id and app_name properties to do what you want.

My LG Web OS TV has the app names as the source, so i don’t see why they wouldn’t

source_list: AV,AVR,Accessibility,All 4,Amazon Prime Video,BBC iPlayer,Component,Demand5,Device Connector,Emby,Fire TV 4K,Freeview Explore,Gamestreams,HDMI3,HDMI4,ITV Hub,LG Content Store,Live TV,Music,Notifications,Photo & Video,Plex,Recordings,Screen Share,Search,Spotify Music - Listen free on LG TV,TV Guide,TV Scheduler,User Guide,Web Browser,XPlay,YouTube,screenplay

That was a typo on my part. I meant to say "using the app name as the status. I’ll edit my post now.

I’ve tried using this component for my Toshiba Fire TV, and I’ve seen partial success using the adb-server method, as well as without using it, but both are unsatisfactory.

When not using the server, I get the general problems where it becomes unavailable for a large percentage of the time after initially working after startup for a few minutes.
When using an adb-server, the issue is that a lot of things don’t match up.
It pretty much sees the ‘playing’ state exclusively as the ‘paused’ state. I dug through the code and did some testing and found that there are always at least 1 or 2 wake-locks.
This is especially bizarre because this would seem to imply that it should always be in the “playing” state.
I’ve found that it enters the ‘playing’ state if I browse the hulu menu, but that’s it. Haven’t had a chance to manually query the wake-locks in that instance though.

The turn-on command also has no effect, though pressing the home-key with my own remote IS a valid way of turning on the TV.

I’m willing to write a PR but I’m looking for insight into how the “wake lock” system works.
Is there an alternative way to detect the playing state that is less fragile?
Could I save some nominal wake-lock count, and consider additional wake-locks above that the ‘playing’ state?

The latest version of the custom component will use the home key to turn on the Fire TV. However, you might need to delete the existing firetv folder(s) in the deps folder of your configuration directory so that the latest version of the package gets installed.

First off, are you using the ADB server addon? I haven’t yet received feedback that it works with the Fire TV component.

Using the latest version of the custom component, you can send ADB commands to your device and the results are logged at the INFO level. To be honest, I don’t really know how best to determine the current state. You could look at the androidtv.py component for some other commands to try out. Here is an example of how to send such a command.

PRs are welcome!