Skip to content

Instantly share code, notes, and snippets.

@mcfrojd
Last active May 16, 2024 10:26
Show Gist options
  • Save mcfrojd/9e6875e1db5c089b1e3ddeb7dba0f304 to your computer and use it in GitHub Desktop.
Save mcfrojd/9e6875e1db5c089b1e3ddeb7dba0f304 to your computer and use it in GitHub Desktop.
Working INTENTS to use with Community Hass.io Add-ons: Android Debug Bridge for your Nvidia Shield TV

Latest Update 2021-03-06 : New image showing the new "Services" in Home Assistant and got some tips from the comments below.

Credits and thanks: Home Assistant Forum users & Github users: @ocso, @wiphye, @teachingbirds, @tboyce1, @simbesh, @JeffLIrion @ff12 @rebmemer @siaox @DiederikvandenB @Thebuz @clapbr @Finsterclown


Start apps on your android device (in the examples below, my Nvidia Shield TV) from Home Assistant

alt text

Starts Youtube App

entity_id: media_player.shield
command: >-
  am start -a android.intent.action.VIEW -n
  com.google.android.youtube.tv/com.google.android.apps.youtube.tv.activity.ShellActivity

Starts Kodi

entity_id: media_player.shield
command: >-
  am start -a android.intent.action.VIEW -n
  org.xbmc.kodi/.Splash

Starts Twitch

entity_id: media_player.shield
command: >-
  am start -a android.intent.action.VIEW -n
  tv.twitch.android.app/tv.twitch.android.apps.TwitchActivity

Starts Netflix (Shows profiles if its the first start.)


entity_id: media_player.shield
command: >-
  am start -a android.intent.action.VIEW -n
  android.intent.action.VIEW -d -n com.netflix.ninja/.MainActivity

Starts TV4 Play (swedish streaming)

entity_id: media_player.shield
command: >-
  am start -a android.intent.action.VIEW -n
  se.tv4.tv4playtab/se.tv4.tv4play.startup.SplashActivity

Starts SVT Play (swedish streaming)

entity_id: media_player.shield
command: >-
  am start -a android.intent.action.VIEW -n
  se.svt.android.svtplay/se.svt.svtplay.tv.ui.StartupActivity

Starts C More (swedish streaming)

entity_id: media_player.shield
command: >-
  am start -a android.intent.action.VIEW -n
  se.cmore.bonnier/.androidtv.splash.TvConfigurationActivity

Starts ViaPlay (swedish streaming)

entity_id: media_player.shield
command: >-
  am start -a android.intent.action.VIEW -n
  com.viaplay.android/.features.home.HomeActivity

Starts specific Twitch stream (If stream is live)

entity_id: media_player.shield
command: >-
  am start -a android.intent.action.VIEW -d
  twitch://stream/frenck
entity_id: media_player.shield
command: >-
  am start -a android.intent.action.VIEW -d
  twitch://stream/drzzs

KILL apps on your Shield from Home Assistant

Kills YOUTUBE App

entity_id: media_player.shield
command: >-
  am force-stop
  com.google.android.youtube.tv

Kills KODI App

entity_id: media_player.shield
command: >-
  am force-stop
  org.xbmc.kodi

Kills TWITCH App

entity_id: media_player.shield
command: >-
  am force-stop
  tv.twitch.android.app

Kills NETFLIX App

entity_id: media_player.shield
command: >-
  am force-stop
  com.netflix.ninja

Kills SVT PLAY App

entity_id: media_player.shield
command: >-
  am force-stop
  se.svt.android.svtplay

Kills TV4 PLAY App

entity_id: media_player.shield
command: >-
  am force-stop
  se.tv4.tv4playtab

Kills C MORE App

entity_id: media_player.shield
command: >-
  am force-stop
  se.cmore.bonnier

Install apps on your Android Device from Home Assistant

Not tested my self, but tips from https://gist.github.com/JeffLIrion

entity_id: media_player.fire_tv_living_room
command: >-
  pm install -r /sdcard/Download/something.apk

Shield navigation and controlling

RIGHT   {"entity_id" :"media_player.shield", "command": "RIGHT"}
LEFT    {"entity_id" :"media_player.shield", "command": "LEFT"}
UP      {"entity_id" :"media_player.shield", "command": "UP"}
DOWN    {"entity_id" :"media_player.shield", "command": "DOWN"}
WAKE    {"entity_id" :"media_player.shield", "command": "MENU"} # use to be the "WAKEUP" command
SLEEP   {"entity_id" :"media_player.shield", "command": "SLEEP"}
ENTER   {"entity_id" :"media_player.shield", "command": "ENTER"}
BACK    {"entity_id" :"media_player.shield", "command": "BACK"}
HOME    {"entity_id" :"media_player.shield", "command": "HOME"}
PLAY    {"entity_id" :"media_player.shield", "command": "input keyevent 126"}
PAUSE   {"entity_id" :"media_player.shield", "command": "input keyevent 127"}
STOP    {"entity_id" :"media_player.shield", "command": "input keyevent 86"}

Intents i'm not using, but someone could have interest in.

(Not tested by me, but tested by people in the Home Assistant Forum.)

Starts Hulu App

entity_id: media_player.shield
command: >-
  am start -a android.intent.action.VIEW -n
  com.hulu.livingroomplus/.MainActivity

Starts Live Channels App

entity_id: media_player.shield
command: >-
  am start -a android.intent.action.VIEW -n
  com.google.android.tv/com.android.tv.MainActivity

Starts Amazon App

entity_id: media_player.shield
command: >-
  am start -a android.intent.action.VIEW -n
  com.amazon.amazonvideo.livingroom/com.amazon.ignition.IgnitionActivity

Starts SPMC App

entity_id: media_player.shield
command: >-
  am start -a android.intent.action.VIEW -n
  com.semperpax.spmc17/.Splash

Starts Haystack App

entity_id: media_player.shield
command: >-
  am start -a android.intent.action.VIEW -n
  com.haystack.android/.tv.ui.LoadingActivity

Starts PBS App

entity_id: media_player.shield
command: >-
  am start -a android.intent.action.VIEW -n
  com.pbs.video/.ui.main.activities.StartupActivity

Starts Pluto TV App

entity_id: media_player.shield
command: >-
  am start -a android.intent.action.VIEW -n
  tv.pluto.android/.leanback.controller.LeanbackSplashOnboardActivity

Starts Spotify App

entity_id: media_player.shield
command: >-
  am start -a android.intent.action.VIEW -n
  com.spotify.tv.android/.SpotifyTVActivity

Starts HBO Go App

entity_id: media_player.shield
command: >-
  am start -a android.intent.action.VIEW -n
  eu.hbogo.androidtv.production/eu.hbogo.androidtv.MainActivity

Starts Plex App

entity_id: media_player.shield
command: >-
  am start -a android.intent.action.VIEW -n
  com.plexapp.android/com.plexapp.plex.activities.SplashActivity

Starts Perfect Player App

entity_id: media_player.shield
command: >-
  am start -a android.intent.action.VIEW -n
  com.niklabs.pp/com.niklabs.perfectplayer.MainActivity

Starts S0undTV (twtich) App

entity_id: media_player.shield
command: >-
  am start -a android.intent.action.VIEW -n
  com.s0und.s0undtv/com.s0und.s0undtv.activities.MainActivity

Starts SmartYoutubeTV App

entity_id: media_player.shield
command: >-
  am start -a android.intent.action.VIEW -n
  com.liskovsoft.videomanager/com.liskovsoft.smartyoutubetv.bootstrap.BootstrapActivity

Starts Steam Link App

entity_id: media_player.shield
command: >-
  am start -a android.intent.action.VIEW -n
  com.valvesoftware.steamlink/com.valvesoftware.steamlink.SteamShellActivity

Starts Ziggo TV App

entity_id: media_player.shield
command: >-
  am start -a android.intent.action.VIEW -n
  com.ziggo.tv/com.lgi.horizongo.core.activity.splash.SplashActivity

Starts Tivimate/ImPlayer App

entity_id: media_player.shield
command: >-
  am start -a android.intent.action.VIEW -n
  ar.tvplayer.tv/.ui.MainActivity

Show local video with KODI

entity_id: media_player.shield
command: >-
  am start -a android.intent.action.VIEW -d
  file:///storage/emulated/0/Android/data/files/sunrise.mp4 -n
  org.xbmc.kodi/.Splash

RTSP stream with VLC

entity_id: media_player.shield
command: >-
  am start -a android.intent.action.VIEW -d
  rtsp://user:password@192.168.1.X:XXX/Streaming/Channels/301 -n
  org.videolan.vlc/.gui.video.VideoPlayerActivity

Intents to change the HDMI input on TVs with Android TV built in (@Thebuz)

HW1-9 Represent various inputs, 1-4 maybe for composite etc. depending on the model of TV

HDMI 1

adb shell am start -a android.intent.action.VIEW -d content://android.media.tv/passthrough/com.mediatek.tvinput%2F.hdmi.HDMIInputService%2FHW5 -n org.droidtv.playtv/.PlayTvActivity -f 0x10000000

HDMI 2

adb shell am start -a android.intent.action.VIEW -d content://android.media.tv/passthrough/com.mediatek.tvinput%2F.hdmi.HDMIInputService%2FHW6 -n org.droidtv.playtv/.PlayTvActivity -f 0x10000000

HDMI 3

adb shell am start -a android.intent.action.VIEW -d content://android.media.tv/passthrough/com.mediatek.tvinput%2F.hdmi.HDMIInputService%2FHW7 -n org.droidtv.playtv/.PlayTvActivity -f 0x10000000

HDMI 4

adb shell am start -a android.intent.action.VIEW -d content://android.media.tv/passthrough/com.mediatek.tvinput%2F.hdmi.HDMIInputService%2FHW8 -n org.droidtv.playtv/.PlayTvActivity -f 0x10000000

ADB commands to find out the intent from diffrent apps:

(what is the command to use to start the app?)

I got a lot of help from people in this thread: https://community.home-assistant.io/t/android-tv-hdmi/234411/28

Use SSH & Web Terminal add-on in Home Assistant with "protection mode" off

alt text

First access the adb container:

docker exec -it addon_a0d7b954_adb /bin/bash

And the run the command:

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

(Replace $package with the app ID.)

Some pre filled commands for some popular apps

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

adb shell pm dump tv.twitch.android.app | grep -A 1 "MAIN" | grep tv.twitch.android.app | awk '{print $2}' | grep tv.twitch.android.app

adb shell pm dump se.tv4.tv4playtab | grep -A 1 "MAIN" | grep se.tv4.tv4playtab | awk '{print $2}' | grep se.tv4.tv4playtab

adb shell pm dump se.svt.android.svtplay | grep -A 1 "MAIN" | grep se.svt.android.svtplay | awk '{print $2}' | grep se.svt.android.svtplay

adb shell pm dump com.google.android.youtube.tv | grep -A 1 "MAIN" | grep com.google.android.youtube.tv | awk '{print $2}' | grep com.google.android.youtube.tv

adb shell pm dump com.netflix.ninja | grep -A 1 "MAIN" | grep com.netflix.ninja | awk '{print $2}' | grep com.netflix.ninja

adb shell pm dump se.cmore.bonnier | grep -A 1 "MAIN" | grep se.cmore.bonnier | awk '{print $2}' | grep se.cmore.bonnier

adb shell pm dump com.viaplay.android | grep -A 1 "MAIN" | grep com.viaplay.android | awk '{print $2}' | grep com.viaplay.android


Tested @tboyce1 command on my Shield and this is what i came up with:

(command to list some of the intents thats running on your device)

Source: https://community.home-assistant.io/t/community-hass-io-add-on-adb-android-debug-bridge/96375/23

Use SSH & Web Terminal add-on in Home Assistant with "protection mode" off

alt text

First access the adb container:

docker exec -it addon_a0d7b954_adb /bin/bash

And the run the command:

adb shell
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

And got this:

  • de.blinkt.openvpn/.activities.MainActivity
  • com.plexapp.android/com.plexapp.plex.activities.SplashActivity
  • com.nvidia.tegrazone3/.LaunchActivity
  • com.android.documentsui/.LauncherActivity
  • com.plexapp.mediaserver.smb/com.plexapp.mediaserver.ui.main.MainActivity
  • com.spotify.tv.android/.SpotifyTVActivity
  • com.android.vending/com.google.android.finsky.tvmainactivity.TvMainActivity
  • se.viafree.android/com.viafree.android.SplashActivity
  • com.nvidia.inputviewer/.MainActivity
  • tv.emby.embyatv/.startup.StartupActivity
  • se.tv4.tv4playtab/se.tv4.tv4play.startup.SplashActivity
  • com.android.gallery3d/.app.GalleryActivity
  • tv.twitch.android.app/tv.twitch.android.apps.TVLandingActivity
  • com.nvidia.ota/.ui.LauncherActivity
  • org.xbmc.kodi/.Splash
  • pl.solidexplorer2/pl.solidexplorer.SolidExplorer
  • com.google.android.youtube.tv/com.google.android.apps.youtube.tv.activity.ShellActivity
  • com.joaomgcd.join/.activity.ActivityMain
  • com.google.android.tv.remote.service/.settings.SettingsActivity
  • com.netflix.ninja/.MainActivity

My LoveLace Remote Card

alt text

You find all info and code here https://github.com/mcfrojd/hassio_lovelace_multiremote


Credit to @clapbr

Sharing the method I've been using to use the search function on Shield directly from HA/Lovelace. Works well for a bunch of stuff, including Netflix (search example: "Vikings on Netflix")

configuration.yaml

input_text:
  androidtv_search_input:
    name: Android Search

scripts.yaml

'atvsearchscript':
  alias: Android TV Search
  sequence:
  - data_template:
      command: am start -a "android.search.action.GLOBAL_SEARCH" --es query "{{ states('input_text.androidtv_search_input')}}"
      entity_id: media_player.shield
    service: androidtv.adb_command

Lovelace raw

      - entities:
          - entity: input_text.androidtv_search_input
            type: 'custom:text-input-row'
          - action_name: Search Android TV
            icon: 'mdi:television-classic'
            name: ' '
            service: script.atvsearchscript
            type: call-service

Credit to @JeffLIrion

How to start a Wyze cam RTSP stream in VLC:

"dumpsys power | grep mWakefulness | grep -qv Awake && input keyevent 4; CURRENT_APP=$(dumpsys window windows | grep mCurrentFocus) && CURRENT_APP=${CURRENT_APP#*{* * } && CURRENT_APP=${CURRENT_APP%%/*} && if [ $CURRENT_APP != 'org.videolan.vlc' ]; then monkey -p org.videolan.vlc -c android.intent.category.LAUNCHER 1 && sleep 3; fi; am start -a android.intent.action.VIEW  -d  rtsp://USER:PASSWORD@192.168.0.42/live"

Change the user, password, and IP address in the last part of that command.


@kaijk
Copy link

kaijk commented May 26, 2023

Is there a new Intent now for MAX to replace hbonow? My HBO intent has stopped working. I see the com.hbo.hbonow intent is still there, and which has been working, but it now returns:

$ cmd package resolve-activity  com.hbo.hbonow
No activity found

even when I have the new MAX app running and am logged into it

@GinAndBacon
Copy link

Is there a new Intent now for MAX to replace hbonow? My HBO intent has stopped working. I see the com.hbo.hbonow intent is still there, and which has been working, but it now returns:

$ cmd package resolve-activity  com.hbo.hbonow
No activity found

even when I have the new MAX app running and am logged into it

Have you tried using the Android Debug Bridge: Learn sendevent service under development tools? Super useful for finding the commands for more obscure apps. Go to dev tools then services and choose the service above and Android device in UI mode. Call the service and hit the button to launch the app. If there isn't a dedicated hardware button download button mapper as it allows you to reassign apps to hardware keys on any Android remote. After that you will get a notification with the ADB command used to launch the app. You may have to side load the button mapper APK. I don't remember if it's in the Android TV store or not.

@kaijk
Copy link

kaijk commented May 26, 2023

I connected directly to my firestick with adb tools and listed all the packages, not even just 3rd party ones. The only one that looks even close is com.hbo.hbonow, the one I've been using prior to the HBO-MAX > MAX changeover this week. This intent no longer works, but the intent is still there in the firestick
"am start -a android.intent.action.VIEW -n com.hbo.hbonow/com.hbo.max.HboMaxActivity"

@GinAndBacon
Copy link

Do you see anything close to the name "com.wbd.stream" in the list, I just installed it as I never had it installed and when looking in the Android>Data folder in Solid Explorer that's the name of the folder it was installed in, it's the part after that I can't figure out as it always starts with that name. For example Plex is named com.plexapp.android in that folder and Kodi is org.xmbc.kodi. it's always the part after the / that's different and I just tried and the learnsendevent service and it still outputs a notification but it no longer works as documented so I guess that got broken somewhere along the way and those commands were always much longer anyways.

Hopefully there is something close to that name in the list If you pulled from your FireTV because the part after the / is usually the tricky part, especially now that the learnsendevent service notification doesn't work anymore. I'm also wondering how they did the switchover and if they created a new folder or installed it under the same one. Might be worth looking in the Android> Data folder with a file browser to see if there is a com.wbd.stream" folder now. At least that's what it's named on my Sony Android TV and those folder names are typically universal between devices.

@GinAndBacon
Copy link

GinAndBacon commented May 26, 2023

I connected directly to my firestick with adb tools and listed all the packages, not even just 3rd party ones. The only one that looks even close is com.hbo.hbonow, the one I've been using prior to the HBO-MAX > MAX changeover this week. This intent no longer works, but the intent is still there in the firestick am start -a android.intent.action.VIEW -n com.hbo.hbonow/com.hbo.max.HboMaxActivity

Figured it out. Came across an older thread on the HA forums. I knew there was an easier way of doing this, just had been a while. If you are running Windows install the WSL or if you are running Linux then you are obviously good to go. Install ADB sudo apt install adb then connect to the device via IP adb connect 192.168.0.xx:5555 after that run the below, replacing the package name with the one in the android/data folder. You will get a prompt on the Android device so you have to confirm to connect if you haven't already done so from your PC. Sorry if I am repeating some stuff you have already done, just wanted to be document all steps taken. ADB in Windows won't work because it can't do grep (at least that I am aware of) so Windows Subsystem for Linux is needed in order to run the below commands to get the intent.

Kodi (obviously documented already but was a copy/paste from the link above
me@R2D2:/usr$ adb shell pm dump org.xbmc.kodi | grep -A 1 "MAIN" | grep org.xbmc.kodi | awk '{print $2}' | grep org.xbmc.kodi

org.xbmc.kodi/.Splash

After that I simply changed the name to com.wbd.stream which is the name in the Android/data folder and it immediately launched
me@R2D2:/usr$ adb shell pm dump com.wbd.stream | grep -A 1 "MAIN" | grep com.wbd.stream | awk '{print $2}' | grep com.wbd.stream

com.wbd.stream/com.wbd.beam.BeamActivity

So created a script with the above as the intent command and it launched instantly. Thought I would post the details in case it comes in handy for future use if other apps change names or just need to find a particular one that isn't documented already. Just replace the name with whatever is in the Android/data folder to whatever app it is you want to find the intent to.

am start -a android.intent.action.VIEW -n com.wbd.stream/com.wbd.beam.BeamActivity

@kaijk
Copy link

kaijk commented May 27, 2023

Thank you! I'll check out "wbd" when I get a bit of alone time with the firestick.

I don't recall seeing wbd in any listings I've produced, though. Thanks for the thought to install adb on my linux box.

I have android studio installed on windows for just this purpose so I have adb tools there. I run adb connect <ip of firestick> from a windows command prompt after disconnecting HA from the firestick. Then, running adb shell gets a command prompt on the firestick. pm and other commands are now available in the firestick shell. Just have to remember to do an adb disconnect or HA can't reconnect to the device.

@kaijk
Copy link

kaijk commented May 28, 2023

I've got the new MAX intent working -

After disconnecting HA, connecting to the FIreStick with adb connect <IP address> and getting a Shell in the device adb shell, I ran the following:

pm dump com.hbo.hbonow | grep wbd

Among a bunch of other stuff was this:

intent={act=android.intent.action.MAIN cat=[android.intent.category.LEANBACK_LAUNCHER] flg=0x10000000 pkg=com.hbo.hbonow cmp=com.hbo.hbonow/com.wbd.beam.BeamActivity}

Now, this opens MAX for me in HA:

"am start -a android.intent.action.VIEW -n com.hbo.hbonow/com.wbd.beam.BeamActivity"

Interesting how WBD mixed the two bits together to create the new intent.

Note, run adb disconnect before trying to reconnect HA to the device.

@GinAndBacon
Copy link

I'm speculating it was because you more than likely did an update and I did a new install as that the folder in Android/data was named com.wbd.stream when I did a new install. If you already had it installed it may have not changed the folder name in that directory and just updated the files in that folder but that's just speculation by me as the first part always matches up with the folder name in that directory (at least for me it does on my Sony Android TV). You could check with a file explorer and see if the folder is still named com.hbo.hbonow but if it's working it's working and that's all that matters. Might be worth remembering if you ever do a new install on another Android device and the above doesn't work for the new install (if that even ever happens).

@AfonsoFGarcia
Copy link

Working intents for switching HDMI inputs on 2023 Philips TVs (tested on OLED818):

HDMI1:

adb shell am start -a android.intent.action.VIEW -d content://android.media.tv/passthrough/com.mediatek.tis%2F.HdmiInputService%2FHW2 -n org.droidtv.playtv/.PlayTvActivity -f 0x10000000

HDMI2:

adb shell am start -a android.intent.action.VIEW -d content://android.media.tv/passthrough/com.mediatek.tis%2F.HdmiInputService%2FHW3 -n org.droidtv.playtv/.PlayTvActivity -f 0x10000000

HDMI3:

adb shell am start -a android.intent.action.VIEW -d content://android.media.tv/passthrough/com.mediatek.tis%2F.HdmiInputService%2FHW4 -n org.droidtv.playtv/.PlayTvActivity -f 0x10000000

HDMI4:

adb shell am start -a android.intent.action.VIEW -d content://android.media.tv/passthrough/com.mediatek.tis%2F.HdmiInputService%2FHW5 -n org.droidtv.playtv/.PlayTvActivity -f 0x10000000

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment