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

You have to send a “real” ADB command. The androidtv.adb_command service maps "SLEEP" (for example) to input keyevent 223. See here for more info: https://github.com/JeffLIrion/python-androidtv/blob/39c0c0a6710d21f941755dc063fd2244f4d8c9c3/androidtv/constants.py.

That was it, thanks!

Hi there all,
I have a Philips OLED Android TV that is work under my Home Assistance via ADB services.

The problem is that sometime is power on on my voice command
and some time is not work.

I realize that if I turn it on via remote control, then my voice command is work (via ADB)
…but if the TV stay some hour the the ADB is not find it anymore.
I so that also the ping is not answer on the Philips TV IP.

So then I stop it from WiFi connection and I cable it using LAN network (Cat6 cable)
But nothing change… after some hour the TV is go in some type of standby
that can’t answer on ping or on the ADB commands.

Maybe some had same problem and solve it…
Sorry if I don’t read near 400 messages :frowning:

Anybody can tel me how can I solve this problem please ?
Thanks all
Denis

Has anyone actually successfully setup their MiBox 3 to work with this?

Find below a working intent that starts Netflix on the latest episode of Paw Patrol. If you want something other than Paw Patrol: simply change the show code (80026226) to something else.

android.intent.action.VIEW -d http://www.netflix.com/watch/80026226 -f 
0x10808000 -e source 30 com.netflix.ninja/.MainActivity
1 Like

Hi,

is it working now ?

Gotta thank this whole community. This particular add-on was the final piece needed to recreate my home theatre master remote. I was hardcore iRule for years and never thought I’d find something to replace it. Never thought Home Assistant would be the answer.
These might not be as polished and sophisticated as some I’ve seen, but works great for these old eyes and fingers:


5 Likes

So now that this addon is deprecated, what do I need to do to migrate away from it?
I removed the adb_server_ip from the configuration.yaml but now my adroid tv no longer works.
It’s a Sony Bravia.

1 Like

Logs? Configuration? Crystal ball? Anything beside “no longer works” should do… :wink: :slight_smile:

OK, so I’ve just seen that this add-on is now deprecated. The reason for me installing it some months ago, was because HA was unable to read the status of my Google Chromecast w/GTV when watching Netflix (status shown as unknown), which killed some automations for me.

Does anyone know if this has this been fixed with the latest version of HA, or is it an ongoing issue?

1 Like

You’re right.
So this is my config with the adb_server_ip configured for the addon:

platform: androidtv
host: 192.168.2.50
name: Fernseher
adb_server_ip: 127.0.0.1
apps:
    tv.twitch.android.app: "Twitch"
    com.amazon.amazonvideo.livingroom: "Prime Video"
    com.disney.disneyplus: "Disney+"
    com.zdf.android.mediathek: "ZDF Mediathek"
    de.swr.avp.ard.tv: "ARD Mediathek"
exclude_unnamed_apps: true

When I remove the adb_server_ip the log says this:

Logger: homeassistant.components.media_player
Source: helpers/entity_platform.py:216
Integration: Mediaplayer (documentation, issues)
First occurred: 16:04:09 (3 occurrences)
Last logged: 16:04:39

Platform androidtv not ready yet. Retrying in 30 seconds.
Platform androidtv not ready yet. Retrying in 60 seconds.

and

Logger: androidtv.adb_manager.adb_manager_async
Source: /usr/local/lib/python3.8/site-packages/androidtv/adb_manager/adb_manager_async.py:193
First occurred: 16:04:29 (3 occurrences)
Last logged: 16:06:20

Couldn't connect to 192.168.2.50:5555. TcpTimeoutException: Reading from 192.168.2.50:5555 timed out (10.0 seconds)

and

Logger: homeassistant.components.androidtv.media_player
Source: components/androidtv/media_player.py:227
Integration: androidtv (documentation, issues)
First occurred: 16:04:08 (7 occurrences)
Last logged: 16:07:09

Could not connect to Glotze at 192.168.2.53:5555 using ADB server at 127.0.0.1:5037
Could not connect to Fernseher at 192.168.2.50:5555 using Python ADB implementation with adbkey='/config/.storage/androidtv_adbkey'

The second TV “Glotze” is powered off, so that error is ok. But the TV “Fernseher” is on standby and replies to ping.

Well, what do you know…
The problem was, that I had to click “Accept the new connection” on the TV screen. Which I didn’t see the first time because the TV was on standby. :roll_eyes:

I just switched mine back over to the Python Implementation… I had to make sure ADB Add-On was stopped, change YAML so no key listed… restart TVs then restart HA and I got the screen for allowing to connect… one tv connected right away, the other I had to restart HA again after checking the box to allow connection.

:slight_smile: Good it’s working! You could have taken the stored adbkeys, but a new one should do without problems, too. :slight_smile:

For everyone who is running into the same problems, here is the way to disable the addOn and change back to the built-in PythonADB:

  1. Look in your config folder (the one where your configuration.yaml resides) for a hidden folder named something like .androidkeys or .adbkeys. Notice the dot in front of the folder name! The dot means it is hidden from normal view. If you can’t find it, look downwards for a more detailed explanation.
  2. If you have found the folder, look in it for a file that is called adbkey with no file extension. Write down the file path starting with the config folder, should be something like /config/.androidkeys/adbkey. Notice the slash in front of config!
  3. Moving on to the next file. Locate and open the file, where you configured your ADB server, normally it is configuration.yaml. You should have something like this:
# Example configuration.yaml entry
# Based on adding my NVidia Shield, which has IP 192.168.1.34.
media_player:
  - platform: androidtv
    host: 192.168.1.34
    name: "NVidia Shield"
    adb_server_ip: 127.0.0.1
    adb_server_port: 5037
  1. Remove both lines adb_server_ip and adb_server_port completely.
  2. Add the following line at the place, where you deleted the previous lines, like so (adjust to the folder address you wrote down earlier):
adbkey: "/config/.androidkeys/adbkey"
  1. Should look like this in the above example:
# Example configuration.yaml entry
# Based on adding my NVidia Shield, which has IP 192.168.1.34.
media_player:
  - platform: androidtv
    host: 192.168.1.34
    name: "NVidia Shield"
    adbkey: "/config/.androidkeys/adbkey"
  1. Save the file.
  2. Go to Supervisor and open the ADB server page.
  3. Stop the ADB server addOn. Disable both “Start at boot” and “Watchdog”.
  4. Restart HA.
  5. After the restart you shuld be up and running with the new PythonADB.
  6. Check if everything is working, send some commands, try to turn it on and off, these things. Check also the HA log, if any warnings or errors come up.
  7. After checking that everything is working, you can uninstall the ADB server addOn in Supervisor. This is not time relevant, you can leave it for a few days to see if everything is ok. When you feel you are good to go, then move over to Supervisor and uninstall the ADB server addOn.

What if you can’t find the file adbkey?
If not already done, install the addOn Samba from the addOn-store in Supervisor. Follow the directions from the addOn how to get this up and running.

  1. Go to your config folder with Windows Explorer and enable the setting to “show hidden files” in Windows. You should find it under “folder settings” in Windows.
  2. Refresh Windows Explorer window by pressing “F5”. If at least the folder .storage shows up, the “show hidden files” is working.
  3. You should now see the folder .androidkeys as well. Check, if the file adbkey is in that folder.
  4. See above how to proceed.

Still no luck in finding the file?
Don’t worry, just turn on your TV(s). Start with step 3 from above and skip step 5 and step 6.
After the restart of HA (step 10), a key pair will automatically be generated, but you will have to confirm this new key pair on all of your TV(s). That’s why you should have them on, before doing this change. In case of automatically generated keys, you don’t need to add the line adbkey: "/config/.androidkeys/adbkey".

Have fun with the PythonADB server. :slight_smile:

12 Likes

Now thats a detailed manual to my liking! That should have been in the release notes right below the deprecation warning! :star_struck:

4 Likes

Thanks, that full guide was great, i had to use the short version as no adb files existed on my setup but just commenting out the server ip and port in config.yaml and restarting with the player turned on worked :slight_smile:

1 Like

Yup same for me, just removing the server IP and restarting worked without issues. Great writeup!

1 Like

So I have been using ABD fine since the new Chromecast came out without issue with the ABD Server it stop working yesterday and I have tired everything above with no luck. Here’s where things get weird. I did a fresh install and it shows certain apps like (Plex, Hulu and Netflix) but I haven’t added androidtv to my new config. Any other app it shows as off. It doesn’t show Google Launcher. If I stop playing one of the above mentioned apps it just says Hulu Idle no matter how many apps I open after Hulu. I changed the IP on the device as well. Any ideas where go to from here?

I am trying to add my fireTV to control via the native python adb. I have followed the procedure (on the FireTV stick, debug mode, allow remote connexions)
NOTE: I am not moving from the adb_server install, this is a fresh attempt to add my FireTV to homeassistant.

my configure.yaml looks like:

# FireTV 
  - platform: androidtv
    name: FireTV
    device_class: firetv
    host: 192.168.1.84

I have tried and delete the adbkey automatically generated several times then restarted but I still do not see a new media player entity created upon restart with my fireTV. I have confirmed a key is created in /config/.storage/androidtv_adbkey

The FireTV does not either ask to confirm any inbound connexion .

The logs show the following:

2021-05-16 23:07:50 WARNING (MainThread) [homeassistant.components.media_player] Setup of media_player platform androidtv is taking over 10 seconds.
2021-05-16 23:08:39 ERROR (MainThread) [homeassistant.components.media_player] Setup of platform androidtv is taking longer than 60 seconds. Startup will proceed without waiting any longer.
2021-05-16 23:09:53 WARNING (MainThread) [androidtv.adb_manager.adb_manager_async] Couldn’t connect to 192.168.1.84:5555. TimeoutError: Connect call failed (‘192.168.1.84’, 5555)
2021-05-16 23:09:53 WARNING (MainThread) [homeassistant.components.androidtv.media_player] Could not connect to FireTV at 192.168.1.84:5555 using Python ADB implementation with adbkey=‘/config/.storage/androidtv_adbkey’
2021-05-16 23:09:53 ERROR (MainThread) [homeassistant] Error doing job: Task exception was never retrieved
Traceback (most recent call last):
File “/usr/src/homeassistant/homeassistant/components/androidtv/media_player.py”, line 230, in async_setup_platform raise PlatformNotReady
homeassistant.exceptions.PlatformNotReady: None

Any idea what I am missing?

Thanks

fixed above… only took me a day to realise I had the wrong IP…