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
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
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
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
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
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"}
(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
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
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
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
(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
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
(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
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
You find all info and code here https://github.com/mcfrojd/hassio_lovelace_multiremote
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
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.
Well, I have tried removing and adding the device by de authorizing devices on my Sony TV and deleting the keys from the HA directory they are stored it allows me to add the integration but then fails to actually run. Kind of odd. One question, are you using the python implementation or are you running the ADB server add on still as that is what I was using? Regardless after reading up more on the Android TV remote integration added in the latest update I'm probably going to just move to do that as it appears to allow you to do most of what ADB does although based on their examples I'm unsure about some more obscure apps because it uses URL's instead of ADB commands but need to mess around with it first. Just odd that the ADB server connects but get the error below everytime I add the AndroidTV device. Especially since it adds the keys back once I authorize it.
File "/usr/src/homeassistant/homeassistant/config_entries.py", line 387, in async_setup
result = await component.async_setup_entry(hass, self)
File "/config/custom_components/androidtv/init.py", line 162, in async_setup_entry
hass.config_entries.async_setup_platforms(entry, PLATFORMS)
AttributeError: 'ConfigEntries' object has no attribute 'async_setup_platforms'
EDIT: confirmed and works just as fast as ADB. Just posting this in case anyone else runs into this issue because of the ADB server add on being deprecated and it works in essentially the same way using the below script.
alias: Sony YouTube
sequence:
service: remote.turn_on
data:
activity: https://www.youtube.com
target:
entity_id: remote.bedroom_tv
mode: single
LAST EDIT: So, at some point I think I had manually tried to setup the python implementation. I noticed that folder referenced above under custom_components had a date of January 2022 which I believe is right around the time ADB Server was deprecated and removed from add ons. That folder was messing everything up. I honestly think that is the only reason it was there because I can't think of any other reason it should exist as I noticed it was not being deleted when I deleted the AndroidTV instance from devices. Removed that folder, rebooted and everything works now so huge user error on my end but leaving this up in case anyone else runs into something stupid like this. There is no folder created under custom_components when adding the AndroidTV device when using the deprecated ADB Server add on so that was messing everything up. Not sure why this core update broke everything but it shouldn't exist anyways and all is working as it was which is good because the remote integration isn't nearly as powerful as ADB granted it was just introduced.