Skip to content

Instantly share code, notes, and snippets.

@thiagoalmeidasa
Forked from mcfrojd/Shield_Intents.MD
Created April 26, 2023 15:38
Show Gist options
  • Save thiagoalmeidasa/0ed1e508832d4b212bd2859de52d659b to your computer and use it in GitHub Desktop.
Save thiagoalmeidasa/0ed1e508832d4b212bd2859de52d659b 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-02-15 : Markdown cleanup and added 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


Start apps on your Shield 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.)

Hulu                {"entity_id" :"media_player.shield", "command": "am start -a android.intent.action.VIEW -d -n com.hulu.livingroomplus/.MainActivity"}
Live Channels       {"entity_id" :"media_player.shield", "command": "am start -a android.intent.action.VIEW -d -n com.google.android.tv/com.android.tv.MainActivity"}
Amazon              {"entity_id" :"media_player.shield", "command": "am start -a android.intent.action.VIEW -d -n com.amazon.amazonvideo.livingroom/com.amazon.ignition.IgnitionActivity"}
SPMC                {"entity_id" :"media_player.shield", "command": "am start -a android.intent.action.VIEW -d -n com.semperpax.spmc17/.Splash"}
Haystack            {"entity_id" :"media_player.shield", "command": "am start -a android.intent.action.VIEW -d -n com.haystack.android/.tv.ui.LoadingActivity"}
PBS                 {"entity_id" :"media_player.shield", "command": "am start -a android.intent.action.VIEW -d -n com.pbs.video/.ui.main.activities.StartupActivity"}
Pluto TV            {"entity_id" :"media_player.shield", "command": "am start -a android.intent.action.VIEW -d -n tv.pluto.android/.leanback.controller.LeanbackSplashOnboardActivity"}
Spotify             {"entity_id" :"media_player.shield", "command": "am start -a android.intent.action.VIEW -d -n com.spotify.tv.android/.SpotifyTVActivity" }
HBO Go              {"entity_id" :"media_player.shield", "command": "am start -a android.intent.action.VIEW -d -n eu.hbogo.androidtv.production/eu.hbogo.androidtv.MainActivity" }
Plex                {"entity_id" :"media_player.shield", "command": "am start -a android.intent.action.VIEW -d -n com.plexapp.android/com.plexapp.plex.activities.SplashActivity" }
Perfect Player      {"entity_id" :"media_player.shield", "command": "am start -a android.intent.action.VIEW -d -n com.niklabs.pp/com.niklabs.perfectplayer.MainActivity" }
S0undTV (twtich)    {"entity_id" :"media_player.shield", "command": "am start -a android.intent.action.VIEW -d -n com.s0und.s0undtv/com.s0und.s0undtv.activities.MainActivity" }
SmartYoutubeTV:     {"entity_id" :"media_player.shield", "command": "am start -a android.intent.action.VIEW -d -n com.liskovsoft.videomanager/com.liskovsoft.smartyoutubetv.bootstrap.BootstrapActivity" }
Steam Link (start): {"entity_id" :"media_player.shield", "command": "am start -a android.intent.action.VIEW -d -n com.valvesoftware.steamlink/com.valvesoftware.steamlink.SteamShellActivity" }
Steam Link (stop):  {"entity_id" :"media_player.shield", "command": "am force-stop com.valvesoftware.steamlink" }
Ziggo TV:           {"entity_id" :"media_player.shield", "command": "am start -a android.intent.action.VIEW -d -n com.ziggo.tv/com.lgi.horizongo.core.activity.splash.SplashActivity" }
Tivimate/ImPlayer:  {"entity_id" :"media_player.shield", "command": "am start -a android.intent.action.VIEW -d -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:[email protected]: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:[email protected]/live"

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


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