Native support for Android TV / Android devices

Hello, Please be gentle, 1st time post I think, Ihave been studying the adb commands and am trying to create a picture in picture element for a doorbell camera using tinycam pro I have the initial tap action working but it pops up in full screen opposed to a picture in picture. My card is as below


type: picture-glance
image: camera.doorbell
entities: []
camera_image: camera.doorbell
title: Porch
entity: media_player.fire_tv_cube
tap_action:
  action: call-service
  service: androidtv.adb_command
  service_data:
    entity_id: media_player.fire_tv_cube
    command: >-
      am start -n com.alexvas.dvr.pro/com.alexvas.dvr.activity.LiveViewActivity
      -a com.alexvas.dvr.pro/com.alexvas.dvr.activity.LiveViewActivity -d
      com.alexvas.dvr.intent.extra.PIP:true -f 0x10000020 -e
      "amzn_deeplink_data" "80092835"
  target: {}
camera_view: live

So I have been using ABD fine since the new Chromecast came out without issue with the ABD Server it stop working yesterday. Hereā€™s where things get weird. I did a fresh install and it shows certain apps like (Plex, Hulu and Netflix) but I havenā€™t added androidtv to my new config. Any other app it shows as off. It doesnā€™t show Google Launcher. If I stop playing one of the above mentioned apps it just says Hulu Idle no matter how many apps I open after Hulu. I changed the IP on the device as well. Any ideas where go to from here?

Sorry for reviving this issue, but I currently in the same situation, and would like to know if some work around was found, and thereā€™s an actual way to make this work, since because of the lack of TTS from the Android tv component I actually need to used both entities to use different aspects of the same device, which kinda of sucks.
Any news?

Hey, Iā€™m very sorry for the long delay in replying. I managed to resolve this by sideloading a wakelock app and using the options to keep alive the CPU and Wifi. I completely forget where I found the app, but it was this one: https://play.google.com/store/apps/details?id=eu.thedarken.wldonate&hl=en_US&gl=US

If anyone wants a bit more instaneous control, below is an example of what I did. It uses a combination of this integration as well as a USB device called IRUSB from VideoStorm. Iā€™m not using the IR functions on it, itā€™s main purpose is acting as an IP controllable HID input (keyboard) to the Nvidia Shield. I use the androidtv adb integration for power, status, and some input (app) switching, and then I use the IRUSB for remote control commands.

I had tried the adb integration even with the /sendevent commands set up, and it was still not to my liking in terms of responsiveness. This method of integration with the IRUSB gives you the responsiveness you would expect from a remote control.

Wonder if this is an official integration topic. Long story short - how to play a specific video from youtube via the service call command?

I believe this should work, but Iā€™ve only tested it on a phone and not on the shield:

adb shell am start -a android.intent.action.VIEW "https://www.youtube.com/watch?v=BvRibG_w0hM"

edit: This does work, although the first time you run this you might be asked which app you want to use to open the video. This only appears to work if the shield is already on.

Iā€™m having trouble to launch some, but not all, Android Apps on my Nvidia Shield TV Pro.
Method used is described here: Android TV - Home Assistant

Not all apps ids found in the developer tools work as expected.

For e.g. Netflix the below configuration works just fine.

- id: 'Shield switchen naar Netflix'
  alias: 'Shield switchen naar Netflix'
  description: Shield switchen naar Netflix
  trigger:
    - platform: state
      entity_id: select.afstandsbediening_activities
      to: 'Netflix'
  action:
    - wait_template: "{{ states('media_player.shield_3') != 'unavailable' }}"
    - service: media_player.select_source
      target:
        entity_id: media_player.shield_3
      data:
        source: '"com.netflix.ninja"'

but for e.g. F1TV app id found in developer tools doesnā€™t work in the automation

- id: 'Shield switchen naar F1TV'
  alias: 'Shield switchen naar F1TV'
  description: Shield switchen naar F1TV
  trigger:
    - platform: state
      entity_id: select.afstandsbediening_activities
      to: 'F1TV'
  action:
    - wait_template: "{{ states('media_player.shield_3') != 'unavailable' }}"
    - service: media_player.select_source
      target:
        entity_id: media_player.shield_3
      data:
        source: '"com.formulaone.production"'

Testing via developer tools - services gives me the same result

This works

This doesnā€™t

Any ideas on what Iā€™m doing wrong?

Can you try this instead?

com.formulaone.production/com.avs.f1.ui.splash.SplashActivity

Thx for the suggestion. Unfortunately that doesnā€™t work either

Hi all,
Many releases ago, I (FireTV Stick) was able to use the UI to select a source from a list of several apps. At some point, this stopped working as there is only one and only source in the list, and this one item in the list corresponds to the app that is currently running.
I never pursued a fix for this until today, and still not having much luck. Any suggestions:

  - platform: androidtv  
    name: Fire TV
    host: MY_FIRE_TV_ADDRESS
    device_class: firetv 
    adbkey: ADB_KEY_DIRECTORY
    get_sources: true #default true. 
    apps:
      com.amazon.device.controllermanager: "FireTV Controller"
      com.amazon.tv.settings.v2: "FireTV Settings Menu"
      com.amazon.tv.launcher: "FireTV Home" 
      com.hulu.plus: "Hulu"
      com.att.tv: "DirecTV Stream"
      com.netflix.ninja: "Netflix"
      com.pbs.video: "PBS"
      com.amazon.firetv.youtube: "YouTube"
      com.hbo.hbonow: "HBO Now"

EDIT/UPDATE:
After digging around in the code I think I see what the problem is.
First some background on how I think the source list is built and used.
When it comes to building a list of sources, the HA AndroidTV Integration code will periodically ask what I will call the lower level device dependent driver code to get a list of running apps (which it will do if get_sources is true).

This device dependent driver code uses various adb shell commands to talk directly with the device to perform various things, including getting a list of running apps. It is basically getting a list of app_ids, i.e. com.xxx.yyy. When the HA AndroidTV Integration receives the running app list, it essentially will do a look up into the config parameter apps (as well as another list that resides embedded in the code) so that it can change the app id to a more user friendly string. For example: com.hulu.plus will be shown as ā€œHuluā€ in the source list. If it can not find a matching appid in the look up, it will simply show the appid in the source list.

There may be cases, where there are lots of appids that are showing up and they are more or less internal apps, and if you donā€™t want these showing up in your sources list, you can set the config exclude_unnamed_apps to true to eliminate them. Finally, there appears to be a separate flow of code that is retrieving the current running app, and this is the one of course that shows as currently selected.

So I found that the problem is in the retrieving of the running apps. The adb shell command that is used for the Fire device is not retrieving any any running apps, and so the HA AndroidTV Integration gets an empty list of running apps so the source list is empty and all that is left to show is the current running app and no more. The solution I found is to use the same adb shell command that is used for Android devices. Iā€™ve submitted an issue on this, so weā€™ll see where it goes.

Hello,

I`m having a similar issue as described above with my Shield TV, only I donā€™t see any sources (apps) at all. The rest of the media_player is working as expected (I can turn it on/off, change volume and see the album art).

Here is my config:

  - platform: androidtv
    name: Shield (Android TV)
    host: 192.168.1.XXX
    device_class: androidtv

I can check its state (mostly ā€˜idleā€™) and here are the attributes of the entity:

adb_response: null
hdmi_input: null
entity_picture: >-
  /api/media_player_proxy/media_player.shield_android_tv?token=XXXXXX&cache=XXXX
friendly_name: Shield (Android TV)
supported_features: 23997

Any help?

1 Like

@kirpat @Molodax hi guys, have you resole it? i have the same issue on my new smart tv philips android tv 65pus8556, appid dont show in the attributes, and the state doesnt change, thanks :slight_smile:

i have stopped using this. so cant say does it still works.

1 Like

I noticed today (since thereā€™s now a proper integration page) that the attributes do show the apps installed on my shield however, this integration does (up till now) not support Android TV 11. See Alerts ā€“ Home Assistant

Hello.

I have a 2 server landscape (TST/PRD), in which I run the ā€˜ADB - Android Debug Bridgeā€™ add-on in PRD and connect the TST server to send the ADB commands through it.

As this add-on is now deprecated for a while, I am considering changing the setup to Python-adb instead.

Still then, considering that I can only have a single ADB connection at a time per device, is there a way to move it to Python-adb and still be able to send ADB commands from the 2 servers ā€œat the same timeā€?

Thanks in advance for any insights.

Iā€™m having the same issue with my Shield TV. I just installed the integration after I upgraded to the latest 2022.2 release.

I can stop and start apps using ADB directly. Good enough for me. I have the latest Shield update and latest HA release.

service: androidtv.adb_command
entity_id: media_player.android_xxxxxxxxxxxxxxx
data:
command: >-
am force-stop
com.google.android.youtube.tvunplugged

1 Like

Wow, this was driving me insaneā€¦ it thought it had something to do with other integrationsā€¦

But this clearly makes the issue clear