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

Hi HA team

I have a new Amazon FireTV Cube and have successfully installed the ADB add-on. Configuration looks good and I am able to connect without issue. I looked through the documentation for ADB but was unable to find the answer:

Is there a way to launch a specific youtube URL or video using the service? Say if I wanted to stream a live channel on youtube on the device.

Thank you team!

Yes , use this script , change with your enitiy name and youtube URL

scriptname:
  alias: scriptname
  sequence:
  - data:
      command: am start -a android.intent.action.VIEW "https://www.youtube.com/watch?v=ZFjfK8piBbQ"
      entity_id: media_player.nvidia_shield
    entity_id: media_player.nvidia_shield
    service: androidtv.adb_command

:tada: Release v0.6.0

Full Changelog

This is a small bugfix/improvement release.

:hammer: Changes

  • :books: Update add-on documentation to use new YAML configuration format
  • :hammer: Update add-on config with new password & list features
  • :hammer: Re-branding
  • :arrow_up: Upgrades add-on base image to v5.0.1
  • :hammer: Update community forum link

Questions? Join our Discord server! https://discord.me/hassioaddons
Enjoying my add-ons? Consider supporting my work:
https://github.com/sponsors/frenck or https://patreon.com/frenck

I have install ADB addon and setup androidtv plateform in configutation.yaml. But I can’t find the adb command in service. What did I miss? Thanks!

Having the same issue, did you ever figure this out?

Try this!
I have followed this component and worked fine.

Hello,

I can’t get the mediaplayer to work in hassio.
There isn’t a mediaplayer created after a reboot.
The addon is installed fine and it is connected to my android tvbox (mibox).
What am i doing wrong?

My settings in the addon:

devices:
  - 192.168.1.80
reconnect_timeout: 90
log_level: info

My configuration.yaml settings:

media_player:
  - platform: androidtv
    host: 192.168.1.80
    name: "MiBox"
    adb_server_ip: 127.0.0.1
    adb_server_port: 5037

Do i have to open a port or something?

The logfiles from the app is all good, connected to 192…

Tnx in advance!

It’s working!
Something stupid from my side!
Did not gave hassio acces on the mibox when adb asked for it…
Screen was off…

Tnx!

OK so I took the service image example on github and under developer tools tested it out with my NVidia Shield.

Put in androidtv.adb_command for the service

Put in media_player.family_room_nvidia_shield for the entity

For Service Data put in the whole block: {“entity_id” :“media_player.shield”, “command”: “am start -a android.intent.action.VIEW -d -n com.google.android.youtube.tv/com.google.android.apps.youtube.tv.activity.ShellActivity”}

Sure enough my NVidia Shield Pro TV changed to YouTube.

Trying to duplicate that in my Lovelace code.

So when I do:

                tap_action:
                  action: call-service
                  service: androidtv.adb_command
                  service_data:
                    command: 'am start -a android.intent.action.VIEW -d -n com.google.android.youtube.tv/com.google.android.apps.youtube.tv.activity.ShellActivity'

OR even the full intent with the entity_id and all if that’s the right term it keeps telling me data missing.

Thoughts?

JR

You are missing the “entity_id:”

tap_action:
  action: call-service
  service: androidtv.adb_command
  service_data:
    entity_id: media_player.shield
    command: "am start -a android.intent.action.VIEW -d -n com.google.android.youtube.tv/com.google.android.apps.youtube.tv.activity.ShellActivity"

Cool thanks. I think I had it and failed to copy it right into the forum or this was my 50th attempt to format it to work but working now so thank you.

For intents like this:

{ “entity_id”: “media_player.android_mibox”, “intent”: “-n com.plexapp.android/com.plexapp.plex.activities.SplashActivity” }

How do you determine the com.plexapp.android part which I guess is the app bundle, but more specifically the com.plexapp.plex part? So right now I am looking at the ABC and NBC apps and don’t see those anywhere so going to try and figure them out but looking at things not always sure how the SplashActivity part gets figured out.

I can’t remember exactly what I did, but I can remember that I figured out how to find that out with help from info on this page

I think it involved downloading an adb tool on my PC and connecting to the shield to run the commands listed on the page above.

https://developer.android.com/studio/command-line/adb

So here’s an example I put together but not sure if it’s valid yet, making dinner so not in the mood to verify until after.

adb shell pm dump com.google.android.youtube.tv > save.txt
Or whatever the bundle is and save to file
am start -a android.intent.action.VIEW -d -n com.google.android.youtube.tv / com.google.android.apps.youtube.tv.activity.ShellActivity```

Not sure if that will work but what I got so far.
1 Like

Ive been trying to get this to work.

I had to get a new SD card for my pi, and I figured I would do this from scratch- knowing that it is possible to throw on one of my snapshots. That said, I set up the ADB on HA, I included the IPs for the 2 Shields I wanted to use, on one ( the most pressing one) I accepted the connection on the Shield, and of course put them in my config.

Any help, or advice would be helpful. THANK YOU.

The configuration. yaml looks like:

Copy to clipboard

media_player:
  - platform: androidtv
    host: 192.168.86.57
    name: "Second NVidia Shield"
    adb_server_ip: 127.0.0.1
    adb_server_port: 5037
  - platform: androidtv
    host: 192.168.86.56
    name: "Livingroom NVidia Shield"
    adb_server_ip: 127.0.0.1
    adb_server_port: 5037

The Config in the add-on ADB looks like:

Copy to clipboard

devices:
  - 192.168.8x.5x
  - 192.168.8x.5x
reconnect_timeout: 90

The log for the ADB, insists that it is connected to the devices:

Copy to clipboard

[cont-init.d] 00-banner.sh: exited 0.
[cont-init.d] 01-log-level.sh: executing... 
[cont-init.d] 01-log-level.sh: exited 0.
[cont-init.d] adb.sh: executing... 
[cont-init.d] adb.sh: exited 0.
[cont-init.d] done.
[services.d] starting services
[services.d] done.
[22:41:13] INFO: Starting the Android Debug Bridge server...
[22:41:14] INFO: Connecting to device: 192.168.86.57...
connected to 192.168.86.57:5555
[22:41:14] INFO: Connecting to device: 192.168.86.56...
connected to 192.168.86.56:5555
[22:42:44] INFO: Connecting to device: 192.168.86.57...
already connected to 192.168.86.57:5555
[22:42:44] INFO: Connecting to device: 192.168.86.56...
already connected to 192.168.86.56:5555
[22:44:15] INFO: Connecting to device: 192.168.86.57...
already connected to 192.168.86.57:5555
[22:44:15] INFO: Connecting to device: 192.168.86.56...
already connected to 192.168.86.56:5555
[22:45:45] INFO: Connecting to device: 192.168.86.57...
already connected to 192.168.86.57:5555
[22:45:45] INFO: Connecting to device: 192.168.86.56...
already connected to 192.168.86.56:5555
[22:47:16] INFO: Connecting to device: 192.168.86.57...
already connected to 192.168.86.57:5555
[22:47:16] INFO: Connecting to device: 192.168.86.56...
already connected to 192.168.86.56:5555
[22:48:46] INFO: Connecting to device: 192.168.86.57...
already connected to 192.168.86.57:5555
[22:48:46] INFO: Connecting to device: 192.168.86.56...
already connected to 192.168.86.56:5555
[22:50:17] INFO: Connecting to device: 192.168.86.57...
already connected to 192.168.86.57:5555
[22:50:17] INFO: Connecting to device: 192.168.86.56...
already connected to 192.168.86.56:5555
[22:51:47] INFO: Connecting to device: 192.168.86.57...
already connected to 192.168.86.57:5555
[22:51:47] INFO: Connecting to device: 192.168.86.56...
already connected to 192.168.86.56:5555
[22:53:17] INFO: Connecting to device: 192.168.86.57...
already connected to 192.168.86.57:5555
[22:53:18] INFO: Connecting to device: 192.168.86.56...
already connected to 192.168.86.56:5555
[22:54:48] INFO: Connecting to device: 192.168.86.57...
already connected to 192.168.86.57:5555
[22:54:50] INFO: Connecting to device: 192.168.86.56...
already connected to 192.168.86.56:5555
[22:56:21] INFO: Connecting to device: 192.168.86.57...
already connected to 192.168.86.57:5555
[22:56:21] INFO: Connecting to device: 192.168.86.56...
already connected to 192.168.86.56:5555
[22:57:51] INFO: Connecting to device: 192.168.86.57...
already connected to 192.168.86.57:5555
[22:57:53] INFO: Connecting to device: 192.168.86.56...
already connected to 192.168.86.56:5555

And these are the errors I get:

Copy to clipboard

Log Details (WARNING)
Logger: homeassistant.components.media_player
Source: helpers/entity_platform.py:202
Integration: Media player (documentation, issues)
First occurred: 10:42:44 PM (6 occurrences)
Last logged: 10:52:50 PM

Platform androidtv not ready yet. Retrying in 60 seconds.
Platform androidtv not ready yet. Retrying in 90 seconds.
Platform androidtv not ready yet. Retrying in 120 seconds.
Platform androidtv not ready yet. Retrying in 150 seconds.
Platform androidtv not ready yet. Retrying in 180 seconds.

Copy to clipboard

Log Details (ERROR)
Logger: androidtv.adb_manager
Source: components/androidtv/media_player.py:218
First occurred: 10:42:13 PM (7 occurrences)
Last logged: 10:52:50 PM

ADB device is unavailable; encountered an error when searching for device.

Copy to clipboard

Log Details (ERROR)
Logger: homeassistant.components.media_player
Source: components/androidtv/media_player.py:215
Integration: Media player (documentation, issues)
First occurred: 10:42:13 PM (1 occurrences)
Last logged: 10:42:13 PM

Error while setting up androidtv platform for media_player
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/helpers/entity_platform.py", line 178, in _async_setup_platform
    await asyncio.wait_for(asyncio.shield(task), SLOW_SETUP_MAX_WAIT)
  File "/usr/local/lib/python3.7/asyncio/tasks.py", line 442, in wait_for
    return fut.result()
  File "/usr/local/lib/python3.7/concurrent/futures/thread.py", line 57, in run
    result = self.fn(*self.args, **self.kwargs)
  File "/usr/src/homeassistant/homeassistant/components/androidtv/media_player.py", line 215, in setup_platform
    state_detection_rules=config[CONF_STATE_DETECTION_RULES],
  File "/usr/local/lib/python3.7/site-packages/androidtv/__init__.py", line 52, in setup
    aftv = BaseTV(host, port, adbkey, adb_server_ip, adb_server_port, state_detection_rules, auth_timeout_s)
  File "/usr/local/lib/python3.7/site-packages/androidtv/basetv.py", line 100, in __init__
    self.device_properties = self.get_device_properties()
  File "/usr/local/lib/python3.7/site-packages/androidtv/basetv.py", line 206, in get_device_properties
    constants.CMD_MAC_ETH0)
  File "/usr/local/lib/python3.7/site-packages/androidtv/adb_manager.py", line 435, in shell
    return self._adb_device.shell(cmd)

I am having the same exact issue as lawsuitup. One day the shield and adb was all working, now there is the error setting the media player, yet the adb_server add-on says it is connected to the shield.

Unfortunately, I do not know when this broke, so I do not know if it was after an ADB add-on update, HA update or a shield firmware update.

I too am having the same issues as Lawsuitup… Saw his post here and a similar note on reddit. Similar config, same symptoms, same error. Tried multiple restarts and orders of setup/restarts.

I initially had this working (old version) but lost it with a SD card failure. After a fresh install, seeing the issues above.

Important Note: I can get this working when I only implement a single AndroidTV. But upon implementing a second AndroidTV I see the failures.

@lawsuitup - Can you try to update your config to only include a single AndroidTV? Does that fix it?

Similarly, you can see here (Late January), someone had a similar issue (on a supervised docker implementation).

@lawsuitup @asubpargamer @rzarobbie

Stop using the add-on, the Python ADB implementation should work just fine.

  1. Stop the add-on
  2. Remove adb_server_ip from your config
  3. Restart the device
  4. Restart HA
  5. Click the check box on the TV and approve connections from this device
1 Like

I had to reauthorize the second tv. Without the second tv, it would not set up either one.

Thank you for this answer. I finally got this to work… well kind of. I have 3 Fire TV 4K’s, 1 connected to a Sony and the other 2 are on LG TV’s. When I call the SLEEP service only the one (the Sony) executes the command but the other 2 do not. Do you have any idea why this is happening?