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

So Disney+: com.disney.disneyplus/com.bamtechmedia.dominguez.main.MainActivity

Not seeing Android debug in the HA services drop down? I searched for ABD and Android. Any ideas? I made sure it was running and config right.Capture

I had the ADB server and AndroidTV working fine, but after upgrading to the latest versions of HassOS and Home Assistant, it no longer is working and the ADB service calls don’t exist in Developer Tools. Does anyone have any ideas? Details below:

Device: Raspberry Pi 3B+
Hass.io Supervisor: v193
OS: HassOS 3.7
HA Version: 0.103.4
ADB Server: 0.5.4

Devices: All are Amazon Fire TV STICK 4K

Core Configuration

media_player:
  - platform: androidtv
    name: Master Bedroom Fire TV 4K
    device_class: firetv
    host: 192.168.1.158
    adb_server_ip: 127.0.0.1
    adb_server_port: 5087

  - platform: androidtv
    name: Great Room Fire TV 4K
    device_class: firetv    
    host: 192.168.1.157
    adb_server_ip: 127.0.0.1
    adb_server_port: 5087
  
  - platform: androidtv
    name: Dining Room Fire TV 4K
    device_class: firetv    
    host: 192.168.1.156
    adb_server_ip: 127.0.0.1
    adb_server_port: 5087  

ADB Config

{
  "devices": [
    "192.168.1.156",
    "192.168.1.157",
    "192.168.1.158"
  ],
  "reconnect_timeout": 90
}

Portion of ADB Log

[10:54:33] INFO: Connecting to device: 192.168.1.158...
connected to 192.168.1.158:5555
[10:56:04] INFO: Connecting to device: 192.168.1.156...
connected to 192.168.1.156:5555
[10:56:04] INFO: Connecting to device: 192.168.1.157...
connected to 192.168.1.157:5555
[10:56:04] INFO: Connecting to device: 192.168.1.158...
connected to 192.168.1.158:5555
[10:57:34] INFO: Connecting to device: 192.168.1.156...
connected to 192.168.1.156:5555
[10:57:34] INFO: Connecting to device: 192.168.1.157...
connected to 192.168.1.157:5555
[10:57:34] INFO: Connecting to device: 192.168.1.158...
connected to 192.168.1.158:5555
[10:59:05] INFO: Connecting to device: 192.168.1.156...
connected to 192.168.1.156:5555
[10:59:05] INFO: Connecting to device: 192.168.1.157...
connected to 192.168.1.157:5555
[10:59:05] INFO: Connecting to device: 192.168.1.158...
connected to 192.168.1.158:5555

Portion of Home Assistant Log

2019-12-27 11:00:01 WARNING (SyncWorker_3) [androidtv.adb_manager] Couldn't connect to host 192.168.1.158:5555 via ADB server 127.0.0.1:5087, error: ERROR: connecting to 127.0.0.1:5087 [Errno 111] Connection refused.
Is adb running on your computer?
2019-12-27 11:00:01 WARNING (SyncWorker_13) [androidtv.adb_manager] Couldn't connect to host 192.168.1.157:5555 via ADB server 127.0.0.1:5087, error: ERROR: connecting to 127.0.0.1:5087 [Errno 111] Connection refused.
Is adb running on your computer?
2019-12-27 11:00:01 WARNING (SyncWorker_15) [androidtv.adb_manager] Couldn't connect to host 192.168.1.156:5555 via ADB server 127.0.0.1:5087, error: ERROR: connecting to 127.0.0.1:5087 [Errno 111] Connection refused.
Is adb running on your computer?
2019-12-27 11:00:01 WARNING (SyncWorker_3) [homeassistant.components.androidtv.media_player] Could not connect to Master Bedroom Fire TV 4K at 192.168.1.158:5555 using ADB server at 127.0.0.1:5087
2019-12-27 11:00:01 WARNING (SyncWorker_13) [homeassistant.components.androidtv.media_player] Could not connect to Great Room Fire TV 4K at 192.168.1.157:5555 using ADB server at 127.0.0.1:5087
2019-12-27 11:00:01 WARNING (SyncWorker_15) [homeassistant.components.androidtv.media_player] Could not connect to Dining Room Fire TV 4K at 192.168.1.156:5555 using ADB server at 127.0.0.1:5087
2019-12-27 11:00:01 WARNING (MainThread) [homeassistant.components.media_player] Platform androidtv not ready yet. Retrying in 180 seconds.
2019-12-27 11:00:01 WARNING (MainThread) [homeassistant.components.media_player] Platform androidtv not ready yet. Retrying in 180 seconds.
2019-12-27 11:00:01 WARNING (MainThread) [homeassistant.components.media_player] Platform androidtv not ready yet. Retrying in 180 seconds.
2019-12-27 11:03:02 WARNING (SyncWorker_3) [androidtv.adb_manager] Couldn't connect to host 192.168.1.158:5555 via ADB server 127.0.0.1:5087, error: ERROR: connecting to 127.0.0.1:5087 [Errno 111] Connection refused.
Is adb running on your computer?
2019-12-27 11:03:02 WARNING (SyncWorker_7) [androidtv.adb_manager] Couldn't connect to host 192.168.1.157:5555 via ADB server 127.0.0.1:5087, error: ERROR: connecting to 127.0.0.1:5087 [Errno 111] Connection refused.
Is adb running on your computer?
2019-12-27 11:03:02 WARNING (SyncWorker_4) [androidtv.adb_manager] Couldn't connect to host 192.168.1.156:5555 via ADB server 127.0.0.1:5087, error: ERROR: connecting to 127.0.0.1:5087 [Errno 111] Connection refused.
Is adb running on your computer?
2019-12-27 11:03:02 WARNING (SyncWorker_3) [homeassistant.components.androidtv.media_player] Could not connect to Master Bedroom Fire TV 4K at 192.168.1.158:5555 using ADB server at 127.0.0.1:5087
2019-12-27 11:03:02 WARNING (SyncWorker_7) [homeassistant.components.androidtv.media_player] Could not connect to Great Room Fire TV 4K at 192.168.1.157:5555 using ADB server at 127.0.0.1:5087
2019-12-27 11:03:02 WARNING (SyncWorker_4) [homeassistant.components.androidtv.media_player] Could not connect to Dining Room Fire TV 4K at 192.168.1.156:5555 using ADB server at 127.0.0.1:5087
2019-12-27 11:03:02 WARNING (MainThread) [homeassistant.components.media_player] Platform androidtv not ready yet. Retrying in 180 seconds.
2019-12-27 11:03:02 WARNING (MainThread) [homeassistant.components.media_player] Platform androidtv not ready yet. Retrying in 180 seconds.
2019-12-27 11:03:02 WARNING (MainThread) [homeassistant.components.media_player] Platform androidtv not ready yet. Retrying in 180 seconds.

Background
I originally setup ADB on my Mac and generated the keys and then used the Python add-on, and that worked, but when the TVs were off, the state constantly toggled between unknown and unavailable. I then deleted the key and switched to the ADB server. I let it self-generate the key and setup the Fire TV sticks to use the new key. That worked more reliably for me. When the TV was off, the Fire Stick 4K showed as OFF.

However, after upgrading the underlying HassOS from 2.#.# (don’t remember exact version) to 3.7, my media player devices no longer showed up, and the ADB server commands no longer existed in Services in Developers Tools.

I’ve tried everything I can think of including uninstalling and re-installing, turning off ADB on the FireTV Stiick 4K, rebooting, turning ADB back on, rebooting HA, re-accepting the certificate on the Fire TV Stick 4K and telling it to remember the computer, but still it doesn’t show up in HA. I have hit a wall. :frowning:

Any help is much appreciated!

I turned off the ADB server and went back to the pythod method, and everything is working OK for now under that version. I still wonder why the ADB server isn’t working, but at least I have control back for now.

I’ve recently acquired a new Sony Android |TV and have just been trying to set up the AndroidTV component on and off over the last few days.

I can report that I’m getting the same symptoms as reported by @Salty. The ADB Server component has connected to the TV and I’ve accepted the key etc. Logs from the the ADB Server show it connecting but HA logs are showing the same problems as Salty. I only just upgraded HassOS to 3.7 tonight and was getting the problem yesterday too, so not specific to 3.7

I hope there’s a solution to this soon,as I’ve not had any joy as yet connecting via Python method, but I’ll give it another go.

EDIT: I just turned up the debug on HA and captured the following in the logs:

2019-12-29 22:53:34 INFO (MainThread) [homeassistant.components.media_player] Setting up media_player.androidtv
2019-12-29 22:53:34 WARNING (SyncWorker_7) [androidtv.adb_manager] Couldn't connect to host 192.168.0.111:5555 via ADB server 127.0.0.1:5087, error: ERROR: connecting to 127.0.0.1:5087 [Errno 111] Connection refused.
Is adb running on your computer?
2019-12-29 22:53:34 DEBUG (SyncWorker_7) [androidtv.adb_manager] ADB command not sent to 192.168.0.111:5555 via ADB server 127.0.0.1:5087 because pure-python-adb connection is not established: getprop ro.product.manufacturer && getprop ro.product.model && getprop ro.serialno && getprop ro.build.version.release && ip addr show wlan0 | grep -m 1 ether && ip addr show eth0 | grep -m 1 ether
2019-12-29 22:53:34 WARNING (SyncWorker_7) [homeassistant.components.androidtv.media_player] Could not connect to Sony TV at 192.168.0.111:5555 using ADB server at 127.0.0.1:5087

Besides your ADB problems, you should try this custom component. Since I use this one, I don’t have any problems with my Sony TV and the python adb connection. :wink:

Thanks for the pointer, I’ll give it a try when I’m back home in a few days.

:tada: Release v0.5.5

Full Changelog

This is a general maintenance release.

:hammer: Changes

  • :fireworks: Updates maintenance/license year to 2020
  • :arrow_up: Upgrades add-on base image to v4.0.3
  • :pencil2: Funding adjustments
  • :pencil2: Fixes some spelling and grammar

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

Hello all,

This is great work, some awesome tutorials. Thanks to all.

I can get all my apps to launch except when I read my shield or Sony android tv with adb I am missing two. Nhl live and dazn

Any help would be appreciated.

Thanks

:tada: Release v0.5.6

Full Changelog

This is a small bugfix/improvement release.

:hammer: Changes

  • :hammer: Change adb-connect to wait on port (#20)

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

Hi all, I installed the ADB debug bridge, and it connects to my Shield. The ADB log says it’s connected:

[22:17:01] INFO: Connecting to device: 192.168.178.133...
already connected to 192.168.178.133:5555

When I try to send any command to my nVidia Shield, like this:

action:
  service: androidtv.adb_command
  data:
    entity_id: media_player.shield
    command: "HOME"

I find an error in the log:

Error while executing automation automation.control_shield. Service not found for call_service at pos 1: Unable to find service androidtv/adb_command

And indeed in the services tool in the Developer Tools, I don’t seem to have androidtv.adb_command.

Did I miss a step in the install?

The add-on provides the service, you still need to configure the integration in Home Assistant.

So 2 things to set up. Home Assistant integration, and the add-on.

Hi Frenck,

In the configuration.yaml I had set up this:

# nVidia Shield TV in cinema
media_player:
  - platform: androidtv
    host: 192.168.178.133
    name: "shieldcinema"
    adb_server_ip: 127.0.0.1
    adb_server_port: 5037

And in the ADB addon config I have this:

{
  "devices": [
    "192.168.178.133"
  ],
  "reconnect_timeout": 90,
  "log_level": "info"
}

But I’m obviously missing something. Could you give me a hint where to look?

Settings look good, anything in the Home Assistant logs?

The system log you mean? There’s nothing inthere that says androidtv.

I did notice an error:

20-01-09 15:52:48 ERROR (MainThread) [hassio.api.ingress] Ingress error: Cannot connect to host 172.30.33.1:8099 ssl:None [Connection refused]

But don’t know what that means.

And this is what’s in the developer tools log:

020-01-09 16:52:33 WARNING (SyncWorker_0) [homeassistant.util.yaml.loader] YAML file /config/configuration.yaml contains duplicate key "media_player". Check lines 18 and 27.
2020-01-09 16:52:33 WARNING (SyncWorker_0) [homeassistant.util.yaml.loader] YAML file /config/configuration.yaml contains duplicate key "input_boolean". Check lines 36 and 43.
2020-01-09 16:52:41 ERROR (Thread-3) [pychromecast.socket_client] [Rune:8009] Failed to connect to service Chromecast-Audio-a31d3a50b071a26c87a6297830728be0._googlecast._tcp.local., retrying in 5.0s
2020-01-09 16:52:41 ERROR (Thread-4) [pychromecast.socket_client] [Dagmar:8009] Failed to connect to service Chromecast-Audio-0c2e204fa1ec05636860d4f2155173fe._googlecast._tcp.local., retrying in 5.0s
2020-01-09 16:59:53 WARNING (SyncWorker_8) [homeassistant.util.yaml.loader] YAML file /config/configuration.yaml contains duplicate key "media_player". Check lines 18 and 27.
2020-01-09 16:59:53 WARNING (SyncWorker_8) [homeassistant.util.yaml.loader] YAML file /config/configuration.yaml contains duplicate key "input_boolean". Check lines 36 and 43.
2020-01-09 17:00:23 ERROR (MainThread) [homeassistant.components.automation] Error while executing automation automation.control_shield. Service not found for call_service at pos 1: Unable to find service androidtv/adb_command
2020-01-09 17:00:30 ERROR (MainThread) [homeassistant.components.automation] Error while executing automation automation.control_shield. Service not found for call_service at pos 1: Unable to find service androidtv/adb_command
2020-01-09 17:00:52 ERROR (MainThread) [homeassistant.components.automation] Error while executing automation automation.control_shield. Service not found for call_service at pos 1: Unable to find service androidtv/adb_command
2020-01-09 17:04:06 ERROR (MainThread) [homeassistant.components.automation] Error while executing automation automation.control_shield. Service not found for call_service at pos 1: Unable to find service androidtv/adb_command
2020-01-09 17:04:10 ERROR (MainThread) [homeassistant.components.automation] Error while executing automation automation.control_shield. Service not found for call_service at pos 1: Unable to find service androidtv/adb_command
2020-01-09 20:18:07 ERROR (SyncWorker_9) [DenonAVR] No connection to /goform/AppCommand.xml end point on host 192.168.178.34
2020-01-09 20:18:07 ERROR (SyncWorker_9) [DenonAVR] Update failed.
2020-01-09 20:43:56 ERROR (SyncWorker_3) [DenonAVR] No connection to /goform/AppCommand.xml end point on host 192.168.178.34
2020-01-09 20:43:56 ERROR (SyncWorker_3) [DenonAVR] Update failed.
2020-01-09 21:44:27 ERROR (Thread-2) [pychromecast.socket_client] [SHIELD:8009] Error reading from socket.
2020-01-09 21:44:27 WARNING (Thread-2) [pychromecast.socket_client] [SHIELD:8009] Error communicating with socket, resetting connection
2020-01-09 22:01:22 ERROR (SyncWorker_4) [DenonAVR] No connection to /goform/AppCommand.xml end point on host 192.168.178.34
2020-01-09 22:01:22 ERROR (SyncWorker_4) [DenonAVR] Update failed.
2020-01-09 22:50:55 ERROR (MainThread) [homeassistant.components.automation] Error while executing automation automation.control_shield. Service not found for call_service at pos 1: Unable to find service androidtv/adb_command
2020-01-09 22:54:06 ERROR (MainThread) [homeassistant.components.automation] Error while executing automation automation.control_shield. Service not found for call_service at pos 1: Unable to find service androidtv/adb_command
2020-01-09 22:57:49 ERROR (MainThread) [homeassistant.components.automation] Error while executing automation automation.control_shield. Service not found for call_service at pos 1: Unable to find service androidtv/adb_command

I cleaned up my configuration.yaml to fix many of the above errors, but there’s now this error:

Platform androidtv not ready yet. Retrying in 90 seconds.

And just like that… the androidtv.adb_command services appeared in my services menu. No idea what did it though. Apologies for cluttering the list.

1 Like

I’m not sure if this is possible with this setup. But I had it setup with my smarttv so I’d love for it to work with the shield. Is this possible. I turn on netflix and while its on standby my light strip lights up, when I press play it dims and then when I press stop or pause it lights up all the way again? I cant figure out how to specify if its netflix vs hulu or another app. Any help would be greatly appreciated

I’m pleased to be able to report that I’ve managed to get my Sony TV integrated using the PSK plugin. Still looking for a way to see what App is running and to select Apps to run rather than just the channels. I got Netflix to work, but not Spotify or Amazon Prime video

You have to get the ìds for the apps. Take a close and long look at this page, it’s a lot of useful information! :slight_smile:

This is my unfinished media_player.yaml and I’m not using the apps on the TV but on my AndroidTV-Stick, but it doesn’t matter, what androidTV you are using.

- platform: braviatv_psk
  host: !secret host_sony-bravia
  name: Sony Bravia TV
  psk: sony
  mac: !secret mac_sony-bravia
  amp: True
  android: True
- platform: androidtv
  name: MagentaTV Stick
  host: !secret host_magentatv-stick
  adb_server_ip: 127.0.0.1
  adb_server_port: 5037
  apps:
    de.telekom.magentatv.androidtv: "MagentaTV"
    de.swr.avp.ard.tv: "ARD Mediathek"
    com.zdf.android.mediathek: "ZDF Mediathek"
    com.amazon.amazonvideo.livingroom: "AmazonPrimeVideo"
    com.netflix.ninja: "Netflix"
    # YouTube 
    de.rtli.tvnow: "TVNow"
    de.prosiebensat1digital.seventv: "Joyn"
    com.google.android.apps.mediashell: "Chromecast MagentaTV"
    com.android.tv.settings: "AndroidTV Einstellungen"
  state_detection_rules:
    'de.telekom.magentatv.androidtv':
      - 'playing':
          'wake_lock_size': 3
      - 'playing':
          'wake_lock_size': 2
      - 'paused':
          'wake_lock_size': 1
      - 'idle'
    'de.swr.avp.ard.tv':
      - 'playing':
          'wake_lock_size': 2
          'media_session_state': 3
      - 'paused':
          'wake_lock_size': 1
          'media_session_state': 2
      - 'idle':
          'wake_lock_size': 0
    'com.zdf.android.mediathek':
      - 'playing':
          'wake_lock_size': 3
      - 'paused':
          'wake_lock_size': 1
      - 'idle'
    'com.amazon.amazonvideo.livingroom':
      - 'playing':
          'wake_lock_size': 4
      - 'paused':
          'wake_lock_size': 2
      - 'idle':
          'wake_lock_size': 1
    'com.netflix.ninja':
      - 'playing':
          'wake_lock_size': 4
          'media_session_state': 3
      - 'paused':
          'wake_lock_size': 2
          'media_session_state': 2
      - 'idle':
          'wake_lock_size': 2
          'media_session_state': 3
    'de.rtli.tvnow':
      - 'playing':
          'wake_lock_size': 4
      - 'playing':
          'wake_lock_size': 3
      - 'paused':
          'wake_lock_size': 2
      - 'idle'
    'de.prosiebensat1digital.seventv':
      - 'playing':
          'wake_lock_size': 3
      - 'paused':
          'wake_lock_size': 2
      - 'idle':
          'wake_lock_size': 1

The part under apps is for the friendly name, and the state_detection_rules are for the state (idle, playing, pause). As I said, not finished and not 100% accurate, as I still get pause when Joyn is playing… But that’s for another evening to catch! :slight_smile:

1 Like