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

I noticed that the ADB code seems to provide return codes and statuses. Is there a way to tell, for example, that plex has finished loading? I’d like to issue some commands post load of the app, but don’t want to wait a fixed number of seconds before doing so, in the hope that the app has loaded.

I have exactly the same issue

Hi guys anyone able to assist a newbie with this. Trying to get my shield TV to work.
Log shows it’s connected on port 5555. I have turned on network debugging (had the trust window “add keys” come up on the shield which I accepted.

Here’s the config:

media_player:

  • platform: androidtv
    host: 192.168.2.13
    name: “Nvidia Shield”
    adb_server_ip: 127.0.0.1
    adb_server_port: 5037
    apps:
    com.google.android.tvlauncher: “Home”
    com.google.android.youtube.tv: “Youtube”
    com.amazon.amazonvideo.livingroom: “Amazon Prime Video”
    com.plexapp.android: “Plex”
    com.netflix.ninja: “Netflix”
    com.google.android.tv: “Live Channels”
    org.xbmc.kodi: “Kodi”

But whenever I try and send a call service to the Android TV I get the follow errors:

I FTP’d into the shield to see if i could find a place where keys were stored, but was unable to locate .android… (am clutching at straws here).

I am able to turn on and off the shield by pressing the power icon in the UI, so there is definitely some connection, but am at a loss from here how to get it controlled.

Anyone able to show a pointer?
thx

Oh, sorry nearly forgot:

Add-on version: 0.4.1
You are running the latest version of this add-on.
System: HassOS 2.11 (amd64 / intel-nuc)
Home Assistant version: 0.93.2
Supervisor version: 164


[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.
[16:24:45] INFO: Starting the Android Debug Bridge server…
[16:24:45] INFO: Connecting to device: 192.168.2.13…
connected to 192.168.2.13:5555

Same here

2019-05-29 20:21:30 INFO (MainThread) [homeassistant.components.media_player] Setting up media_player.androidtv
2019-05-29 20:21:30 ERROR (SyncWorker_3) [root] ADB device is unavailable; encountered an error when searching for device.
2019-05-29 20:21:30 WARNING (SyncWorker_3) [homeassistant.components.androidtv.media_player] Could not connect to FireTV at 10.0.20.61:5555 using ADB server at 127.0.0.1:5037
2019-05-29 20:21:30 WARNING (MainThread) [homeassistant.components.media_player] Platform androidtv not ready yet. Retrying in 60 seconds.

A recent pull request for the python-adb package might fix the issues that the Python ADB implementation had with newer devices. If you’d like to test it, please use this as a custom component and report back!

https://github.com/JeffLIrion/home-assistant/tree/patch-19/homeassistant/components/androidtv

You’ll need to follow the instructions for generating an adbkey file:

https://www.home-assistant.io/components/androidtv#2-python-adb-implementation

You’ll also need to stop the ADB server and restart your Android TV / Fire TV device.

There is no intent parameter. See here for examples:

https://gist.github.com/mcfrojd/9e6875e1db5c089b1e3ddeb7dba0f304

I’m using your branch to connect to two Shields using Python ADB. So far the connection is stable and basic commands work. I’m not at home so I can’t do too much testing, but I’ll update if I find problems.

Thanks!

I think a good stress test would be to send the “BACK” command repeatedly from the services tab (say, 10+ times in rapid succession):

{"entity_id": "media_player.YOUR_ANDROID_TV", "command": "BACK"}

If the media player doesn’t become unavailable (check the log for error messages), then the connection is solid!

Done, the only thing I saw in logs was

Data_length 3787 does not match actual number of bytes read: 2872
Data_length 4096 does not match actual number of bytes read: 1424

Not sure how well it worked since I’m not at home to monitor, but that seemed to be okay.

Jeff thanks for the reply. Can you tell me where i am supposed to actually add these intents? I mean do I create a script and run that or do I need to add a special configuration file somewhere? I tried the call service and pasted that into the relevant entity but it just wouldn’t show me anything.

Sorry for the basic question.

deleted: Misplaced release notes…

I think this is in the wrong subject?

addon unifi in adb debugging

I fixed my issue. Thanks for the assistance.

Oops, thanks!

1 Like

Hi guys, first of all I wanna thank you frenck for this fantastic addon! :slight_smile:

I’m using it on my Toshiba amazon fire tv edition, it’s a bit confusing still because technicly it’s based (like a normal fire tv stick) on android but when use some keys for androidtv not all are working. the thing I really wanna find out is how to get some app working, I can open netflix and other apps with no issues but I can’t go straight to the playng part of the video, For example I wanna start the news with my script alarm for the morning but when it turns on the tv doesn’t strart to play, if I do it from the fire tv remote app goes straight on to the streaming,what it can be? I tired to get the status of tv while is playing the news but If I copy and paste the whole string “com.corus.fire.amazon.amazonfirewrapper/com.corus.fire.amazon.amazonfirewrapper.ui.MediaPlayerActivity}” is not giving me the the JSON error but if I call the service doen’t work.
Hope somebody of you guys knows a fix, thank you!

Hi, I’m new to home assistant.
I’m trying to use this addon to control my nvidia shield but it’s not working

config:

{
“devices”: [
“192.168.1.25”
],
“reconnect_timeout”: 90,
“log_level”: “info”,
“keys_path”: “/config/androidkeys”
}

configuration.yaml

platform: androidtv
name: NVIDIA
device_class: androidtv
host: 192.168.1.25
adb_server_ip: 127.0.0.1

addon log:

Add-on version: 0.4.1
You are running the latest version of this add-on.
System: HassOS 2.12 (armv7 / raspberrypi3)
Home Assistant version: 0.94.2
Supervisor version: 166
[cont-init.d] 00-banner.sh: exited 0.
[cont-init.d] 01-log-level.sh: executing…
Log level is set to INFO
[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.
[10:37:49] INFO: Starting the Android Debug Bridge server…
[10:37:49] INFO: Connecting to device: 192.168.1.25…
connected to 192.168.1.25:5555
[10:39:20] INFO: Connecting to device: 192.168.1.25…
already connected to 192.168.1.25:5555
[10:40:50] INFO: Connecting to device: 192.168.1.25…
already connected to 192.168.1.25:5555

home assistant log:

2019-06-13 08:30:50 INFO (MainThread) [homeassistant.components.media_player] Setting up media_player.androidtv
2019-06-13 08:30:50 WARNING (SyncWorker_3) [homeassistant.components.androidtv.media_player] Could not connect to NVIDIA at 192.168.1.25:5555 using ADB server at 127.0.0.1:5037
2019-06-13 08:30:50 WARNING (MainThread) [homeassistant.components.media_player] Platform androidtv not ready yet. Retrying in 60 seconds.
2019-06-13 08:31:51 INFO (MainThread) [homeassistant.components.media_player] Setting up media_player.androidtv
2019-06-13 08:31:51 WARNING (SyncWorker_3) [homeassistant.components.androidtv.media_player] Could not connect to NVIDIA at 192.168.1.25:5555 using ADB server at 127.0.0.1:5037
2019-06-13 08:31:51 WARNING (MainThread) [homeassistant.components.media_player] Platform androidtv not ready yet. Retrying in 90 seconds.
2019-06-13 08:33:22 INFO (MainThread) [homeassistant.components.media_player] Setting up media_player.androidtv
2019-06-13 08:33:22 WARNING (SyncWorker_13) [homeassistant.components.androidtv.media_player] Could not connect to NVIDIA at 192.168.1.25:5555 using ADB server at 127.0.0.1:5037
2019-06-13 08:33:22 WARNING (MainThread) [homeassistant.components.media_player] Platform androidtv not ready yet. Retrying in 120 seconds.

can you please help me? :slight_smile:

:tada: Release v0.5.0

Full Changelog

This is a general maintenance release.

:hammer: Changes

  • :books: Removed outdated info regarding intents (#14)
  • :arrow_up: Upgrades add-on base image to v3.1.3
  • :pencil2: Maintaince -> Maintenance
  • :sparkles: Adds FUNDING.yml
  • :shirt: Fixes Markdownlint warnings

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

Could you elaborate on this a bit. I have been trying to get this function to work for some time now…

Command I use:


{

"entity_id":"media_player.shield_tv",

"command":"plex://IAmAServerID/movie//library/metadata/movieID"

}

If this is the url I get when playing the video through a web browser:


https://app.plex.tv/desktop#!/server/abcdefghijklmnopqrstuvwxyz0123456789ABCD/details?key=%2Flibrary%2Fmetadata%2F3742

Is the abcdefghijklmnopqrstuvwxyz0123456789ABCD the server and F3742 the movieID?

so the call would look like:


{

"entity_id":"media_player.shield_tv",

"command":"plex://abcdefghijklmnopqrstuvwxyz0123456789ABCD/movie//library/metadata/F3742"

}

Or is that incorrect?

I also tried sending with “intent” instead of command, but it seems that “intent” is no longer supported?