Native support for Fire TV


#223

I’m not suing the ADB server addon, I’m rolling my own container solution with a home assistant instance and added an adb server container.

I’ll do research in trying to find the current state. Thanks for the insight.


#224

There’s a service known as “media_session” which has attributes for each running app.

One of them is PlaybackState, which has a state attribute which is 3 only while playing.

I don’t really have any firesticks to test on but I’ll make a PR which uses this to detect if its playing, with no other alterations


#225

I probably should have written up my previous investigation on this already, but this is indeed the proper way to handle the states (I was thinking about having a simple app to track the states and do push updates to homeassistant). The problem at that point was (it may have been a year since I looked at it last time) that many of the apps do not use the media session (my experiences on Kindle FireTV stick) for controlling even when the API has been there since Android 4.0.

The description and the integers for states can be found from https://developer.android.com/reference/android/support/v4/media/session/PlaybackStateCompat#getState() and more documentati on media session here https://developer.android.com/guide/topics/media-apps/working-with-a-media-session .


#226

Thanks for the info! I recall reading something similar, perhaps for the Android TV component: there is an API for determining playback state, but many apps don’t adhere to it.

I believe the Android TV component tries to accomplish this task of state detection by using info about the audio output. If you’re interested, you could look at the component that I’ve previously linked to or the thread in this forum.

My opinion is that it’s not reasonable to expect the component to always detect the correct state. (But if someone wants to try to achieve that, their efforts are certainly welcome!) I also don’t think that differentiating between playing, paused, and idle states is a big deal, at least not for my use cases. The component can detect whether it’s on/off, send basic commands (most importantly power on/off and play/pause), and launch apps. That’s good enough for me :grinning:


#227

Basic support is fine, I’m not arguing on that, however, having the ability to, e.g., control the lights based on the play state is somewhat popular application :slight_smile: I just wanted to leave the note behind in case someone is digging already on the topic or wants to improve it, unfortunately I have personally no time to further it at this point.


#228

Is it possible to add HDMI switching? Running it with the adb shell command wont work.


#229

I have latest version of Fire TV stick and did not get pop-up “always allow connections from this device.”

And I also do not have it as Media control entity in my HA


#230

Is it possible to integrate this with the new official adb hassio addon by @frenck

I am using the androidtv custom_component with official adb addon by Frenck (Community Hass.io Add-on: ADB - Android Debug Bridge)
Stability of connection is amazing.

The official FireTV component didn’t work for me. Always showed Unavailable (with one or two state changes in b/w)

AndroidTV custom_component doesn’t seem to be recognizing play/pause/idle or the current track playing on FireTV cube.

Would be amazing if stability of adb addon can be combined with firetv specific code?

Thanks


#231

@JeffLIrion Is there any functional difference between the firetv and the androidtv custom component?


#232

I just posted this in two other threads, but here it is again.

Regarding the Fire TV component, this is already implemented in my custom component. I’m working on getting it integrated into the official component.

Configuration example:

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

Comparing the Fire TV and Android TV components, I haven’t tried the Android TV component, but there are some device-specific tweaks and so I expect that each component will work better for its intended devices.


#233

Reposting here for others. Original comment: Community Hass.io Add-on: ADB - Android Debug Bridge

Awesome. Working well with new addon.

Will keep testing and report back.

recognizes Home as Standby so that’s good. On opening Netflix recognized app as Netflix, and showed Paused. However on playing, state remained Paused.

Will try out with other apps as well. Thanks a lot for the amazing work.


#234

@JeffLIrion
I’m getting the same as @forums2012 above.
Remains in paused state when app is open and playing, though it doesn’t seem to recognise Plex, nor does it pull a list of apps.


#235

State detection has its limitations. It can’t always determine playback status accurately.

As for the list of running apps, please delete any firetv and firetv* folders in the deps folder in your configuration directory and then restart Home Assistant. This will cause it to install the latest version of the package from GitHub. Please let me know if that fixes the running apps!


#236

Ahhh cheers.
Well, after doing that it picked up the Plex app, so that’s progress.
Can select Plex, play, pause, forward, back.
Can’t power on though. Ah well. May require a little more figuring out on my end.


#237

I just updated my firetv fork, so if you repeat the same steps from earlier the turn_on function should work.


#238

I may be looking at the wrong repo but this one is showing last push was 2 months ago?


#239
  1. You’re looking at the wrong branch. This is more current: firetv.py
  2. I didn’t update the component, I updated my forked firetv repo.

#240

Gotcha. That worked. Can now turn on via the component.

Looks like it’s just picking up whatever app it first detects.
Eg
if the firetv is off when I restart hass, when it turns it on it detects the home.
If the firetv is on with an app open when I restart hass, it just detects that app in sources.

Deps were cleared after updating the component

Edit: sorry for using the forum for issues


#241

It should get a list of whatever apps are running, which it will show as sources. Does it not do that?


#242

Afraid not.
tested with no apps running, restarted hass, and it just saw the launcher.
Tried with multiple apples running, restarted hass, and it only had plex in the list (though multiple were running but i was at the launcher)

I am running using an adb server rather than built in if that helps