Native support for Android TV / Android devices

Hi there all,
I just want to ask you all if it’s possible to link the Google Home Assistant to my
Android TV… I have a Philips Android TV.

The Google Home Assistens allready work on my Hassio with other commands.

This thread it’s about a lot of procedure and a lot of problems.
Is there any simple plugin in order to just have “Hey Google… turn on the TV”
Or maybe a step-by-step link on some web page.

Thanks in advance
Denis

I’ve got a problem retrieving the current state of my FireTV Stick. Getting states (playing, paused) for Netflix works very reliable (just with a little delay sometimes). But for prime video it’s going to paused very often though I’m still playing.

image
The reddish color is playing, green is paused. I’ve been playing a movie without pausing, though. the last part (saying “Spielt”) is played using netflix. As you can see, there are no false states.

Did anyone else experience this?

I also experience this with Prime Video on my Nvidia Shield. From what I saw it’s reporting different values for the wake_lock_size. Sometimes it’s 4 when it’s playing and then 2 when it’s paused then other times it’s 3 when it’s playing an 1 when it’s paused. Not sure why that app in particular reports different values. Those are used to detect the state of the app. I haven’t looked closely at the custom state detection to see if you can specify 2 different values for play/pause or not.

1 Like

You can use multiple values.

EDIT

This configuration is incorrect. See here: Native support for Android TV / Android devices

media_player:
  - platform: androidtv
    name: Android TV
    host: 192.168.0.222
    state_detection_rules:
      'com.amazon.tv.launcher':
        - 'playing':
            'wake_lock_size': 4  # this indentation is important!
            'wake_lock_size': 3  # this indentation is important!
        - 'paused':
            'wake_lock_size': 2  # this indentation is important!
            'wake_lock_size': 1  # this indentation is important!
        - 'standby'
2 Likes

Thanks @JeffLIrion! Will give this a try tonight to see if I can get Prime Video to report state better.

It’s giving me an error ‘duplicate entry for wake_lock_size’. So I’m trying

  - platform: androidtv
    host: 192.168.178.7
    name: "FireTV"
    adb_server_ip: 127.0.0.1
    state_detection_rules:
      'com.amazon.tv.launcher':
        - 'wake_lock_size':
            4: 'playing'  # this indentation is important!
            3: 'playing'   # this indentation is important!
            2: 'paused'   # this indentation is important!
            1: 'paused'   # this indentation is important!
        - 'standby'

as described in your thread here
Let’s see how this works out

2 Likes

You’re right. I edited my post to link to yours.

1 Like

I’m having an issue trying to find the correct name for the BBC app - iPlayer, when I pull the app list from my shieldTV it doesn’t show though:

com.nvidia.gfn_100030011/.Launch
com.nvidia.gfn_100182111/.Launch
com.ted.android.tv/.view.MainActivity
com.nvidia.gs_10534111/.Launch
com.plexapp.android/com.plexapp.plex.activities.SplashActivity
com.nvidia.remotelocator/.RemoteLocatorActivity
com.nvidia.tegrazone3/com.nvidia.tegrazone.MainActivity
com.android.documentsui/.LauncherActivity
de.cyberdream.androidtv.notifications.google/de.cyberdream.androidtv.notifications.StartActivity
com.silicondust.view/.App
com.plexapp.mediaserver.smb/com.plexapp.mediaserver.ui.main.MainActivity
com.android.vending/com.google.android.finsky.tvmainactivity.TvMainActivity
com.flipps.fitetv/com.bianor.ams.MainActivity
com.vevo/.MainActivity
com.google.android.tv/com.android.tv.TvActivity
com.nvidia.inputviewer/.AccessorySelectionActivity
com.nvidia.gfn_7785111/.Launch
com.nvidia.gs_17932211/.Launch
com.nvidia.gs_17939611/.Launch
com.nvidia.gs_17941411/.Launch
com.android.gallery3d/.app.GalleryActivity
tv.twitch.android.app/tv.twitch.android.apps.TwitchActivity
com.nvidia.ota/.ui.LauncherActivity
org.xbmc.kodi/.Splash
com.nvidia.gs_100005511/.Launch
com.nvidia.gs_100010811/.Launch
com.nvidia.gs_100030011/.Launch
com.nvidia.gs_100061111/.Launch
com.nvidia.gs_100075911/.Launch
com.nvidia.gfn_11154111/.Launch
com.limelight/.PcView
com.blade.shadowcloudgaming/com.blade.shadow.register.LoginActivity
com.google.android.youtube.tv/com.google.android.apps.youtube.tv.activity.ShellActivity
com.google.android.tv.remote.service/.settings.SettingsActivity
com.netflix.ninja/.MainActivity

Any UK users here have any idea?

“GET_PROPERTIES” seems to fail when I try…probably a formatting issue as I wanted to see if I could pull data when the actual BBC app was playing but not sure how to achieve this.

@JeffLIrion
This also doesn’t work, as the validator only allows one of these states as the key if the value is a dict. https://github.com/JeffLIrion/python-androidtv/blob/2c2e14021fc1bbea5e452e661bb57eaab78114bc/androidtv/basetv.py#L1160

Which causes a validation error on startup

Invalid config for [media_player.androidtv]: 'wake_lock_size' is not a valid state for the 'state_detection_rules' parameter for dictionary value @ data['state_detection_rules']['com.amazon.amazonvideo.livingroom']. Got [OrderedDict([('wake_lock_size', OrderedDict([(4, 'playing'), (3, 'playing'), (2, 'paused'), (1, 'paused')]))]), 'standby']. (See /config/configuration.yaml, line 164). Please check the docs at https://home-assistant.io/integrations/media_player.androidtv/
    state_detection_rules:
      "com.amazon.amazonvideo.livingroom":
        - "wake_lock_size":
            4: "playing"
            3: "playing"
            2: "paused"
            1: "paused"
        - "standby"

I think this is the way to do it.

media_player:
  - platform: androidtv
    name: Android TV
    host: 192.168.0.222
    state_detection_rules:
      'com.amazon.tv.launcher':
        - 'playing':
            'wake_lock_size': 4  # this indentation is important!
        - 'playing':
            'wake_lock_size': 3  # this indentation is important!
        - 'paused':
            'wake_lock_size': 2  # this indentation is important!
        - 'paused':
            'wake_lock_size': 1  # this indentation is important!
        - 'standby'
2 Likes

Look at the app_id attribute on the States page when the app is open.

I don’t know why "GET_PROPERTIES" would fail…

Thanks! That did the trick.

Hi,

Could someone help me what is wrong with my configuration, particularly, with state_detection_rules that I actually copied from docs example:

media_player:
  - platform: androidtv
    host: 192.168.1.100
    name: Android TV
    adb_server_ip: 127.0.0.1
    adb_server_port: 5037
    apps:
      org.droidtv.playtv: "TV"
      com.google.android.youtube.tv: "YouTube"
      com.netflix.ninja: "Netflix"
      org.droidtv.tvsystemui: "Screensaver"
      com.plexapp.android: "Plex"
      com.google.android.tvlauncher: "Menu"
      com.opera.sdk.example: "Browser"
      org.xbmc.kodi: "Kodi"
    state_detection_rules:
      'com.plexapp.android':
        - 'paused':
            'media_session_state': 3  # this indentation is important!
            'wake_lock_size': 1       # this indentation is important!
        - 'playing':
            'media_session_state': 3  # this indentation is important!
        - 'standby'

Unfortunately, validator doesn’t accept it:

Configuration invalid

Invalid config for [media_player.androidtv]: [state_detection_rules] is an invalid option for [media_player.androidtv]. Check: media_player.androidtv->state_detection_rules. (See ?, line ?). Please check the docs at https://home-assistant.io/integrations/media_player.androidtv/

Why i am getting this inside HACS?

I reinstalled three times the component and always got it.
Running 0.100.3

Configuration is:

  - platform: androidtv
    name: Fire TV
    host: 192.168.1.33
    device_class: firetv
    get_sources: false
    apps:
      com.netflix.ninja: "Netflix"
      com.amazon.avod: "Amazon Prime Video"
      com.dazn: "DAZN"
      com.amazon.firetv.youtube: "Youtube"
      it.rainet.androidtv: "RAI Play"
      com.amazon.tv.launcher: "Home"
      com.spotify.tv.android/.SpotifyTVActivity: "Spotify"
      com.esaba.downloader: "Downloader"
      tv.arte.plus7: "Arte"

adb is correctly connected:

pi@hassbian:~$ adb connect 192.168.1.33

connected to 192.168.1.33:5555

But i cannot see the media_player.fire_tv inside my entities…

You’re probably using an old version of HA or an old custom component. Use the latest HA and the built-in component and it should work just fine.

https://www.home-assistant.io/integrations/androidtv#adb-troubleshooting

  1. You are already connected to the Android TV / Fire TV via ADB from another device. Only one device can be connected, so disconnect the other device, restart the Android TV / Fire TV (for good measure), and then restart Home Assistant.

I am using 0.100.3 as i am having BIG problems installing and running 0.101.3.
Is there a release that will work with 0.100.3 as custom component?
I was always connected only with my fire tv… i discovered it changed ip address also if i set it as static IP
Must i restart FireTV again and connect with adb again?

How disconnect the device?

I disconnected (deleting the adb keys) and restarted my fire tv.
Got the request for adb, the two adb keys were created again, clicked ok, restarted HA but still got the same advice !!!
So i need (in the meantime i solve the problem with the 0.101.3 release) of the previous release of the component that was working great…

Why did you delete the keys? You should NOT be running adb connect <IP address>. Read the documentation thoroughly and follow it exactly.

If the device does not get setup in HA, check the log.