Home Assistant Community Add-on: ADB - Android Debug Bridge

thanks Frenck, Shield tv works with HA. Where can I find the list of action, Intent?

With this does the app works shows playing while playing anything on video,
In status does it shows what’s current status on your device

This is freaking awesome! Not having my Shield as an integrated part of the smart home have been a big issue for me.

2 Likes

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.

1 Like

I am not so familiar with adb,
But can someone help, how to grab logs from android tv box in order to see what’s going in

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.

@JeffLIrion
Looking at the documentation for the FireTV component after your updates, it doesn’t look like adb_server_ip is listed as a configurable option.
Is it or is it planned to be in a future update?

EDIT: apologies, looks like I didn’t properly read your reply doh

For others that are trying to figure this out, I followed the code a bit for the custom component and realized you can add arguments in the “intent” data that get passed to am start. With that, I was finally able to start Hulu with the following:

{
    "entity_id": "media_player.shield_tv",
    "intent": "-n com.hulu.livingroomplus/.MainActivity"
}

For reference, the ADB command that gets sent by the service call is

"am start -a android.intent.action.VIEW -d {}".format(uri)

where “{}” gets replaced by whatever is in the “intent” field. That means, without specifying any flags, the input is treated as a “data_uri”. By putting “-n” first, it changes whatever follows to be treated as the “component”.

1 Like

I have this intents working and im using them with the new add-on.

Working intents

Starts Netflix (Shows profiles)
{"entity_id": "media_player.shield", "intent": "netflix://"}

Starts Twitch (Starts to play the stream)

{"entity_id" :"media_player.shield", "intent": "twitch://stream/frenck"}
{"entity_id" :"media_player.shield", "intent": "twitch://stream/drzzs"}

Starts Youtube App
{"entity_id" :"media_player.shield", "intent": "https://www.youtube.com"}

Remote key press

{"entity_id" :"media_player.shield", "key": "KEYCODE_DPAD_RIGHT"}
{"entity_id" :"media_player.shield", "key": "KEYCODE_DPAD_LEFT"}
{"entity_id" :"media_player.shield", "key": "KEYCODE_DPAD_UP"}
{"entity_id" :"media_player.shield", "key": "KEYCODE_DPAD_DOWN"}
{"entity_id" :"media_player.shield", "key": "KEYCODE_WAKEUP"}
{"entity_id" :"media_player.shield", "key": "KEYCODE_SLEEP"}
{"entity_id" :"media_player.shield", "key": "KEYCODE_ENTER"}
{"entity_id" :"media_player.shield", "key": "KEYCODE_BACK"}
{"entity_id" :"media_player.shield", "key": "KEYCODE_HOME"}
{"entity_id" :"media_player.shield", "key": "KEYCODE_MEDIA_PLAY"}
{"entity_id" :"media_player.shield", "key": "KEYCODE_MEDIA_PAUSE"}
{"entity_id" :"media_player.shield", "key": "KEYCODE_MEDIA_STOP"}

Missing intens

  1. Netflix that opens with a pre selected profile.
  2. Kodi
  3. Twitch that opens just the app, not a pre selected stream.
  4. TV4Play (swedish streaming service) Can be started with “adb shell monkey -p se.tv4.tv4playtab -v 1” from CLI but i want the intent.

Maybe someone have these working?

3 Likes

twitch:// as intent will open just Twitch. Also want the tv4-one, so if you figure something out please share and I will do the same :slight_smile:

1 Like

I cant get that one to work.

Here are my intents:

{ "entity_id": "media_player.android_mibox", "intent": "-n com.google.android.youtube.tv/com.google.android.apps.youtube.tv.activity.ShellActivity" }
{ "entity_id": "media_player.android_mibox", "intent": "-n com.spotify.tv.android/.SpotifyTVActivity" }
{ "entity_id": "media_player.android_mibox", "intent": "-n eu.hbogo.androidtv.production/eu.hbogo.androidtv.MainActivity" }
{ "entity_id": "media_player.android_mibox", "intent": "-n org.xbmc.kodi/.Splash" }
{ "entity_id": "media_player.android_mibox", "intent": "-n com.plexapp.android/com.plexapp.plex.activities.SplashActivity" }

I extracted the “main” intent from the packages by using this command:

adb shell pm dump $package | grep -A 1 "MAIN" | grep $package | awk '{print $2}' | grep $package

ie.:

adb shell pm dump org.xbmc.kodi | grep -A 1 "MAIN" | grep org.xbmc.kodi | awk '{print $2}' | grep org.xbmc.kodi

3 Likes

Thanks to @ocso
Ping @teachingbirds

Here are some updated intents:

Starts Twitch
{"entity_id" :"media_player.shield", "intent": "-n tv.twitch.android.app/tv.twitch.android.apps.TVLandingActivity"}

Starts TV4 Paly (swedish streaming)
{"entity_id" :"media_player.shield", "intent": "-n se.tv4.tv4playtab/se.tv4.tv4play.startup.SplashActivity"}

Starts SVT Play (swedish streaming)
{“entity_id” :“media_player.shield”, “intent”: “-n se.svt.android.svtplay/se.svt.svtplay.tv.ui.StartupActivity”}

Starts Youtube App
{"entity_id" :"media_player.shield", "intent": "-n com.google.android.youtube.tv/com.google.android.apps.youtube.tv.activity.ShellActivity"}

Starts Kodi
{"entity_id" :"media_player.shield", "intent": "-n org.xbmc.kodi/.Splash"}

Starts Netflix (Shows profiles if its the first start.)
{"entity_id" :"media_player.shield", "intent": "-n com.netflix.ninja/.MainActivity"}

Will update this Gist if i find more intents that works with the shield

1 Like

Just to help out here are some additional intents. These were tested on a Nvidia Shield TV:

 Hulu  { "entity_id": "media_player.shield", "intent": "-n com.hulu.livingroomplus/.MainActivity"}
 Netflix { "entity_id": "media_player.shield", "intent": "-n com.netflix.ninja/.MainActivity"}
 Live Channels { "entity_id": "media_player.shield", "intent": "-n com.google.android.tv/com.android.tv.MainActivity"}
 Amazon { "entity_id": "media_player.shield", "intent": "-n com.amazon.amazonvideo.livingroom/com.amazon.ignition.IgnitionActivity"}
 Youtube { "entity_id": "media_player.shield", "intent": "-n com.google.android.youtube.tv/com.google.android.apps.youtube.tv.activity.ShellActivity"}
 SPMC { "entity_id": "media_player.shield", "intent": "-n com.semperpax.spmc17/.Splash"}
 Haystack { "entity_id": "media_player.shield", "intent": "-n com.haystack.android/.tv.ui.LoadingActivity"}
 PBS { "entity_id": "media_player.shield", "intent": "-n com.pbs.video/.ui.main.activities.StartupActivity"}
 Twitch { "entity_id": "media_player.shield", "intent": "-n tv.twitch.android.app/tv.twitch.android.apps.TVLandingActivity"}
 Pluto TV  { "entity_id": "media_player.shield", "intent": "-n tv.pluto.android/.leanback.controller.LeanbackSplashOnboardActivity"}
 SlingTV { "entity_id": "media_player.shield", "intent": "-n com.sling/com.movenetworks.StartupActivity"}
 Philo { "entity_id": "media_player.shield", "intent": "-n com.philo.philo.google/com.philo.philo.login.LoginActivity"}
3 Likes

Here’s a command I came up with to get a list of activities to pass to the “intent” data with the “-n” flag:

pm list packages | sed -e "s/package://" | while read x; do cmd package resolve-activity --brief $x | tail -n 1 | grep -v "No activity found"; done

You’ll need to run that on the device itself via ADB shell.

1 Like

Hi guy’s,
with this add-on would it be possible to when I launch an activity called youtube or Netflix on my harmony remote. HA could then send a command launch said app on my shield.

if so, could someone please show me how the action would look in a yaml file?

Can you explain that command?
All i get is an error.

You need to run the command on the device itself. I did it on my Shield TV. If you’re in the ADB addon container and it’s already connected to the device, just run adb shell first. If you’re on a Windows PC or something, assuming you have ADB installed:

adb tcpip 5555
adb connect <device_ip_address>
# accept the connection on the device
adb shell

Edited my previous post for clarification.

Look at the Emulated Roku component.

Use it in an automation as a trigger and the Android TV intent service as the action.
Then create an activity for the app on your Harmony and add the corresponding Roku button press to the activity (you’ll probably have to do this in the MyHarmony program)

I am working on making this (though just as onscreen buttons for apps in my Shield TV activity) so I’ll share the code later when it’s finished.

2 Likes

I think my issue how to convert the service call as an action in yaml. Ive never seen intent used before.