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

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.

Iā€™m on my phone right now but i think it would look something like this: (using Netflix as an example)

action
  - service: android_tv.call_intent [or whatever it is, can't remember]
    data:
      entity_id: media_player.android_tv
      intent: "-n com.netflix.ninja/.MainActivity"
1 Like

media_player.androidtv_intent

2 Likes

Ok here it is:

- alias: Android TV Apps on Harmony
  trigger:
  - platform: event
    event_type: roku_command
  action:
  - service: media_player.androidtv_intent
    entity_id: media_player.android_tv_adb
    data_template:
        intent: > 
          {% if trigger.event.data.key == 'Select' %}
            -n com.google.android.youtube.tv/com.google.android.apps.youtube.tv.activity.ShellActivity
          {% elif trigger.event.data.key == 'InstantReplay' %}
            -n tv.twitch.android.app/tv.twitch.android.apps.TVLandingActivity
          {% endif %}

I managed to make 1 automation that can handle multiple apps instead of making an automation for each app. Less lines of code :slight_smile: .

Just add more else ifs (elif) if you need more than 2 apps and then change the key.
I used ā€œSelectā€ and ā€œInstantReplayā€ because they donā€™t have icons next to them on the Harmony elite touchscreen, but you can use any command that isnā€™t named after an app name. (Here is a list of the exact names to use for each key)
Donā€™t forget to change the enitiy_id to the entity_id of your android tv.

EDIT: Looks like Rokuā€™s docs say the wrong key value for the command ā€œBack Spaceā€.
ā€œBackspaceā€ doesnā€™t work but ā€œBackSpaceā€ does.

1 Like

Is this add-on is suitable for using with cellphones?

1 Like

Hi, Iā€™m trying to understand how to implement this add-on in hassio. Iā€™ve managed to get the add-on working, Iā€™ve got a media_player entity that can turn off my android tv box but thatā€™s all it can do at the moment. This adb business is well above my current level of understanding, so Iā€™m starting with a basic switch to trigger an automation/intent. However, nothing happens. Hereā€™s my automation

- alias: Android TV Auto
  trigger:
  - platform: state
    entity_id: input_boolean.androidtv
    from: 'off'
    to: 'on'
  action:
  - service: media_player.androidtv_intent
    data:
      entity_id: media_player.androidtv
      intent: "-n com.google.android.youtube.tv/com.google.android.apps.youtube.tv.activity.ShellActivity"

Am I heading in the right direction? Sometimes itā€™s worth posting because the more eagle-eyed of you can spot an obvious mistake. Otherwise, is there something else I need to do to be able to use these ā€˜intentā€™ services?

Any pointers would be very much appreciated.

Maybe this could inspire some.

2 Likes

My biggest problem is I can see the format of the intents but I just donā€™t understand where that code goes. Is that Shield_Intents.MD file something that is being referenced, or is that just the format of the service call you are using in automations?

Would you mind posting some of the code that relates to the action from your input_boolean triggers please?

ā€“ edit ā€“
Updated the gist with better lovelace code for some buttons, i had some buttons that activated some node-red flows, the new code should work for anyone without my custom node-red flows.
ā€“ edit ā€“

The input_booleans trigger a node-red flow, (they are a advanced combination of looking if tv is on, set correct input via IR, set soundlevel depending on time and if wife is home, and then starting the right application on the shield) so they are not a good example, but if you look further down you see a typical example.
(the input_boolean.shield_dummy is only there because you have to have a entity for the button card to work.)

            card:
              type: entity-button
              icon: mdi:stop
              name: STOP
              entity: input_boolean.shield_dummy
              hold_action: none
              tap_action:
                action: call-service
                service: media_player.androidtv_key
                service_data:
                  entity_id: media_player.shield
                  key: KEYCODE_MEDIA_STOP

The intent examples you use on the /dev-service page.
(you test them there and the you implement them in a automation, lovelace or node-red or other)

2 Likes

Thank you so much for this mcfrojd!! Thatā€™s really helpful. :+1:

Found a few more intents for some (highly recommended) apps I use.

S0undTV for twitch:
"intent":"-n com.s0und.s0undtv/com.s0und.s0undtv.activities.MainActivity"

SmartYoutubeTV:
"intent":"-n com.liskovsoft.videomanager/com.liskovsoft.smartyoutubetv.bootstrap.BootstrapActivity"

Perfect Player:
"intent":"-n com.niklabs.pp/com.niklabs.perfectplayer.MainActivity"

Thank you @simbesh
I updated my gist with your intents.

1 Like

Not an issue of the add-on, but my nVidia Shield TV doesnā€™t turn off when pressing the power button the media card. Turning it on with the power button works and also the state gets correctly updated when I turn off the Shield TV with the remote control.

Anyone else noticing this as well?

1 Like

Yes (though I use the mini media player). If I open the more info panel I can turn on and off with the toggle there.

1 Like