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

Will do. It’s been running for ~30 minutes now without any disconnects, so it seems to be a significant improvement at least.

Awesome! A good stress test would be to send a lot of commands rapidly. Volume up/down might cause your device to do a power cycle (I don’t know why), but the back button should be safe. You can use the androidtv.adb_command service with "BACK".

Thanks for testing!

I’m not in front of the device to verify, but I did spam the hell out of the device using the service and didn’t see any errors pop up. Still looking pretty solid.

Good to hear! If you don’t experience any issues, I’ll create a new release and submit a pull request to HA later today.

1 Like

Any issues to report? If not, I’ll go ahead and release a new version.

Nope, all good here. Tried with both my Shields and haven’t seen any problems yet.

Pull request submitted! https://github.com/home-assistant/home-assistant/pull/27108

I’d love to start playing with indents but I’m stuck getting this working - help please!

I’ve got adb setup on my shield, and I get an on-screen prompt to accept connection and the adb logs say connected but I can’t see new android media_player in my developers_tools sections e.g. if I open an op

What am I doing wrong? What aim aiming for to be able to see what’s open on each device like in this video from 11m onwards https://www.youtube.com/watch?v=m4kDsy36x5U

{
  "devices": [
    "192.168.30.20"
  ],
  "reconnect_timeout": 90
}
media_player:
  - platform: androidtv
    name: Living Room
    host: 192.168.30.20
    adb_server_ip: 127.0.0.1
[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.
[17:26:19] INFO: Starting the Android Debug Bridge server...
[17:26:19] INFO: Connecting to device: 192.168.30.20...
connected to 192.168.30.20:5555

You only posted the ADB server log, not the Home Assistant log, so I can’t tell what the problem is.

Regardless, I’m trying to push toward the Python ADB implementation approach and away from the ADB server approach because it’s easier to debug and handle errors, disconnects, and re-connect attempts. Follow the instructions in this post: https://community.home-assistant.io/t/androidtv-adb-manager-adb-device-is-unavailable-encountered-an-error-when-searching-for-device/140522/2.

You’ll also need to add the adbkey entry to your configuration. The ADB server add-on should have saved a key somewhere, so use that.

1 Like

Thanks. I’ve setup the python method and I’m connected and I can add the (nvidia) media_player but it just says paused all the time.

I’ve tried sending ‘GET_PROPERTIES’ but I must be doing something wrong e.g. for the prime video app I tried sending the command whilst playing but I get:

volume_level: 0.13333333333333333
is_volume_muted: false
app_id: com.amazon.amazonvideo.livingroom
app_name: com.amazon.amazonvideo.livingroom
source: hdmi
adb_response: null
friendly_name: Living Room
supported_features: 21945

I think it’s all working now, as there’s no android errors in my ha logs, I think I just don’t know how to detect the states correctly.

I think you’re doing something wrong regarding the “GET_PROPERTIES” call. Or maybe you just need to refresh the page.

The service call should look like this:

And the result should look like this (note the adb_response attribute):

You can then use that info to define state detection rules that work for your apps and your device, as in this thread: [Testers needed!] Custom state detection rules for Android TV / Fire TV

2 Likes

Sorted - thanks. What was happening was I was selecting the right media_player but when I clicked ‘fill example data’ it was changing the player to the wrong one!

I was having this problem with my android phone. couldn’t find a solution anywhere until i saw your entry. disconnecting adb was my issue. Thank you so much. :slight_smile:

Did you find the cause of the data length messages?

Hi, my issue was a lack of understanding on how the intents were working. I sorted it when someone sent me an example of one in action. Once I had the basics, it was easy to amend it to my own entities and get it up and running. I can control the Shield direct via HA or via node-red now depending on what I am trying to do.

Hi there all,
and sorry if I reopen this already long thread.

I have already set the ADB component and it’s work if I call it from Tools>Services
using POWER and SLEEP data.

Now, in order to use it with google home assistance, I need to make a switch (at last I believe)

I try a lot of combination but this yaml language I’ll never understand :frowning:

So the last think is to ask your help…
Here is what I want to correct if it’s possible to help me:

switch 6:
  - platform: template
    switches:
      tv:   ### TV PHILIPS (192.168.1.157)
        turn_on:
          service: androidtv.adb_command
          data:
            entity_id: 'media_player.philips_tv'
            command: 'POWER'
        turn_off:
          service: androidtv.adb_command
          data:
            entity_id: 'media_player.philips_tv'
            command: 'SLEEP'

I need to name the switch: tv
This in order to ask “hey google… turn on the tv”
Please help me to finish thes script.

Thasks a lot all
Denis

Dear all,
I finally find how to make a switch in order to use it with google home mini
Here is my actual config:

switch 6:
  - platform: template
    switches:
      tv:
        value_template: 'off'
        turn_on:
          - service: androidtv.adb_command
            data:
              entity_id: 'media_player.philips_tv'
              command: 'POWER'
          - service: androidtv.adb_command
            data:
              entity_id: 'media_player.philips_tv'
              command: 'HDMI1'
        turn_off:
          - service: androidtv.adb_command
            data:
              entity_id: 'media_player.philips_tv'
              command: 'SLEEP'

The problem now is that I can’t understand how to make the HDMI1
always activate when I power on the TV.
I put 2 times the service and activate HDMI1, but is not work.

Anybody can help me please ?
Thanks in advance
Denis

Hi,

I am trying to control my NVIDIA TV Shield with HA, but I am a little bit lost with the configuration. I would like to control the play / pause, volume and previous next button in order to change music on my shield for example.

Is there is a tutorial avalaible to to that, and the code that should be paste in the configuration.yaml file ?

Which is the easiest way to use ADB, python or ADB server ? I have HACS installed.

Thanks for your help!

I’m using HA to control a 2017 and 2019 Pro Shield TV without any issues, so it is possible :wink:

If you’re using Hassio, you’ll need to install the “ADB - Android Debug Bridge” add-on. In the config of that add-in, enter the IP address of your Shield TV and start it up.

You’ll also need to enable the Developer options on the Shield TV to support this. Here are some generic Android instructions, but you should be able to follow this for your Shield TV (the menu options are the same name).

:tada: Release v0.5.4

Full Changelog

This is a general maintenance release.

:hammer: Changes

  • :books: Component > Integration (#18)
  • :arrow_up: Upgrades add-on base image to v4.0.2
  • :books: Update add-on installation instructions
  • :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