Community Hass.io Add-on: ADB - Android Debug Bridge

hassio-repository
hassio-addon
Tags: #<Tag:0x00007f20477da140> #<Tag:0x00007f20477d9b78>

#1

This add-on is provided by the Community Hass.io Add-ons project.

GitHub Release GitLab CI Project Stage Project Maintenance

Supports armhf Architecture Supports aarch64 Architecture Supports amd64 Architecture Supports i386 Architecture

20181002_125128_584062-400x340

The Android Debug Bridge server program.

About


The Android Debug Bridge (ADB) is a client-server program used in Android application development.

This add-on provides the server program and can be used to get full local control over your Android (TV) devices.

Installation


The installation of this add-on is pretty straightforward and not different in comparison to installing any other Hass.io add-on.

  1. Add our Hass.io add-ons repository to your Hass.io instance.
    Add the following URL: https://github.com/hassio-addons/repository
  2. Install the “ADB - Android Debug Bridge” add-on.
  3. Ensure that your Android device has developer mode and network debugging
    enabled.
  4. Add the IP addresses of your device(s) to the add-on configuration.
  5. Start the “ADB - Android Debug Bridge” add-on.
  6. Check the logs of the add-on to see if everything went well.
  7. Ready to go!

:books: Please read the documentation for more information about the use and configuration of this add-on.

Support


You can always try to get support from the community here at the Home Assistant community forums, join the conversation!

Questions? You have several options to get them answered:

You could also open an issue on GitHub, in case you ran into a bug, or maybe you have an idea on improving the addon:

:information_source: At this moment our Community Hass.io Add-ons Discord chat server and GitHub are our only official support channels. All others rely on community effort.

Repository on GitHub


Looking for more add-ons?


The primary goal of our add-ons project is to provide you (as an Hassio / Home Assistant user) with additional, high quality, add-ons that allow you to take your automated home to the next level.

Check out some of our other add-ons in our Community Hass.io Add-ons project.


Native support for Android TV / Android devices
Native support for Fire TV
New FireTV component wont work
#2

About the author of this add-on

Hi there!

I am Franck Nijhof, and I have 30 years of programming experience, in many languages. I am using this experience to work on the Home Assistant project by giving back my knowledge and time to the open source community.

The add-on you are currently looking at right now was developed/packaged by me. It is not the only add-on I have created; there are many many more :wink:

However, I have a problem… I am an addict. A :coffee: addict that is. Lucky for you, I turn that C8H10N4O2 (caffeine molecule) into code (and add-ons)!

If you want to show your appreciation, consider buying me a cup of high octane wakey juice by clicking on the “By me a coffee” image below! :heart:

Buy me a coffee

Or, become a Patron and support my work!

Support my work on Patreon

Enjoy your add-on, while I enjoy the brain juice. :coffee:

Thanks for all the :two_hearts:

…/Frenck

Join our Discord server Follow me on Twitter Flollow me on Instragram Follow me on GitHub Follow me on YouTube Follow me on Twitch patreon-icon

P.S.: In case you want to ask me a question: AMA (Ask Me Anything). Most of the time I am online at the Discord chat. (I go by @Frenck in there as well).


#3

In case you are interested in how this was built, what it does and the possibilities this could unlock.
The recording of the live stream is available on YouTube:


#4

Do you ever sleep? Sending coffee your way.


#5

Many thanks for this addon. Finally able now to add my Nvidia Shield TV to Home Assistant :grinning:


#6

Could this potentially replace the firetv addon in gollo’s repository then? / will the androidtv component be replacing the firetv one?


#7

Thanks for this addon. I was planning to go through setting up firetv using android platform tools but stumbled across this which seems say great way to setup adb based media player.

I am running into following error:

Traceback (most recent call last):                                                                                                       

File “/usr/local/lib/python3.6/site-packages/homeassistant/helpers/entity_platform.py”, line 128, in _async_setup_platform
SLOW_SETUP_MAX_WAIT, loop=hass.loop)
File “/usr/local/lib/python3.6/asyncio/tasks.py”, line 358, in wait_for
return fut.result()
File “/usr/local/lib/python3.6/concurrent/futures/thread.py”, line 56, in run
result = self.fn(*self.args, **self.kwargs)
File “/config/custom_components/media_player/androidtv.py”, line 166, in setup_platform
from androidtv import AndroidTV
ImportError: cannot import name ‘AndroidTV’


#8

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


#9

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


#10

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


#11

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.


New FireTV component wont work
#13

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


#14

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.


Native support for Fire TV
#15

@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


#16

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”.


#17

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?


#18

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:


#19

I cant get that one to work.


#20

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


#21

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