Fire TV (androidtv) Media Player not working stays on Standby

I have a number of Fire TV sticks, they have all had the IP address reserved in the DHCP scope, i have installed the ADB - Android Debug Bridge and have setup the configuration to see all the Fire TV Stciks.

{
  "devices": [
    "192.168.1.56",
    "192.168.1.99",
    "192.168.1.160"
  ],
  "reconnect_timeout": 90,
  "log_level": "info",
  "keys_path": "/config/configuration/.androidkeys"
}

The devices are all appearing on my HA as media_player devices, however no matter what the Fire TV stick is doing it always shows as standby.

firetv

I think i have added it the configuaryion.yaml correctly … below is what is in there;

  - platform: androidtv
    name: 'Living Room Fire TV Stick'
    device_class: firetv    
    host: 192.168.1.99
    adb_server_ip: 127.0.0.1
    adb_server_port: 5037      
    get_sources: false

I have also checked the path specified in the ADB folder and it appears to be creating files;

adbkeys

Not sure what the problem is here but if anyone can give me pointers it would be greatly appreciated.

Thanks in advance

anyone ? any pointers would be greatly appreciated.

Thanks

Update on this … the Fire TV on the standby was actually picked up by the Alexa Integration, i have now excluded my Fire Tvs from being picked up on the Alexa integration and they are now gone.

I am now not seeing any of them at all.

They are getting connected too by the ADB server integration so no idea what is going on

Try pointing to the actual adbkey file. Change:
"keys_path": "/config/configuration/.androidkeys"
to
"keys_path": "/config/configuration/.androidkeys/adbkey"

@Dixey thats it changed, will reboot my controller and see what happens.

I am afraid that doesn’t work @Dixey, this causes the ADB integration to stop after being started.

Changing it back to the original path lets it start up again.

I have been in the same place and my only solution was to turn off the Android Debug Bridge unless I needed it for something. (don’t auto-boot it)

Below is what appears in the log files

020-01-18 17:36:26 INFO (SyncWorker_3) [homeassistant.loader] Loaded nfandroidtv from homeassistant.components.nfandroidtv
2020-01-18 17:36:29 INFO (MainThread) [homeassistant.components.notify] Setting up notify.nfandroidtv
2020-01-18 17:36:29 INFO (MainThread) [homeassistant.components.notify] Setting up notify.nfandroidtv
2020-01-18 17:36:29 INFO (MainThread) [homeassistant.components.notify] Setting up notify.nfandroidtv
2020-01-18 17:36:34 INFO (SyncWorker_10) [homeassistant.loader] Loaded androidtv from homeassistant.components.androidtv
2020-01-18 17:36:37 INFO (MainThread) [homeassistant.components.media_player] Setting up media_player.androidtv
2020-01-18 17:36:37 INFO (MainThread) [homeassistant.components.media_player] Setting up media_player.androidtv
2020-01-18 17:36:37 INFO (MainThread) [homeassistant.components.media_player] Setting up media_player.androidtv
2020-01-18 17:36:37 DEBUG (SyncWorker_4) [androidtv.adb_manager] ADB connection to 192.168.1.56:5555 via ADB server 127.0.0.1:5037 successfully established
2020-01-18 17:36:37 WARNING (SyncWorker_5) [androidtv.adb_manager] Couldn't connect to 192.168.1.99:5555 via ADB server 127.0.0.1:5037
2020-01-18 17:36:37 WARNING (SyncWorker_3) [androidtv.adb_manager] Couldn't connect to 192.168.1.160:5555 via ADB server 192.168.1.161:5037
2020-01-18 17:36:37 DEBUG (SyncWorker_4) [androidtv.adb_manager] Sending command to 192.168.1.56:5555 via ADB server 127.0.0.1:5037: 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
2020-01-18 17:36:37 DEBUG (SyncWorker_5) [androidtv.adb_manager] ADB command not sent to 192.168.1.99:5555 via ADB server 127.0.0.1:5037 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
2020-01-18 17:36:37 DEBUG (SyncWorker_3) [androidtv.adb_manager] ADB command not sent to 192.168.1.160:5555 via ADB server 192.168.1.161:5037 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
2020-01-18 17:36:37 DEBUG (SyncWorker_5) [androidtv.basetv] 192.168.1.99:5555 `get_device_properties` response: None
2020-01-18 17:36:37 DEBUG (SyncWorker_3) [androidtv.basetv] 192.168.1.160:5555 `get_device_properties` response: None
2020-01-18 17:36:37 WARNING (SyncWorker_3) [homeassistant.components.androidtv.media_player] Could not connect to Katies Fire TV at 192.168.1.160:5555 using ADB server at 192.168.1.161:5037
2020-01-18 17:36:37 WARNING (SyncWorker_5) [homeassistant.components.androidtv.media_player] Could not connect to Living Room Fire TV at 192.168.1.99:5555 using ADB server at 127.0.0.1:5037
2020-01-18 17:36:39 ERROR (MainThread) [homeassistant.components.media_player] Error while setting up platform androidtv
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/helpers/entity_platform.py", line 158, 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 207, in setup_platform
    state_detection_rules=config[CONF_STATE_DETECTION_RULES],
  File "/usr/local/lib/python3.7/site-packages/androidtv/__init__.py", line 47, in setup
    return FireTV(host, port, adbkey, adb_server_ip, adb_server_port, state_detection_rules, auth_timeout_s)
  File "/usr/local/lib/python3.7/site-packages/androidtv/firetv.py", line 40, in __init__
    BaseTV.__init__(self, 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)
  File "/usr/local/lib/python3.7/site-packages/ppadb/command/transport/__init__.py", line 20, in shell
    conn = self.create_connection(timeout=timeout)
  File "/usr/local/lib/python3.7/site-packages/ppadb/device.py", line 45, in create_connection
    self.transport(conn)
  File "/usr/local/lib/python3.7/site-packages/ppadb/command/transport/__init__.py", line 15, in transport
    connection.send(cmd)
  File "/usr/local/lib/python3.7/site-packages/ppadb/connection.py", line 77, in send
    return self._check_status()
  File "/usr/local/lib/python3.7/site-packages/ppadb/connection.py", line 83, in _check_status
    raise RuntimeError("ERROR: {} {}".format(repr(recv), error))
RuntimeError: ERROR: 'FAIL' 00a7device unauthorized.
This adb server's $ADB_VENDOR_KEYS is not set
Try 'adb kill-server' if that seems wrong.
Otherwise check for a confirmation dialog on your device.
2020-01-18 17:36:39 WARNING (MainThread) [homeassistant.components.media_player] Platform androidtv not ready yet. Retrying in 30 seconds.
2020-01-18 17:36:39 WARNING (MainThread) [homeassistant.components.media_player] Platform androidtv not ready yet. Retrying in 30 seconds.

2020-01-18 17:38:04 INFO (MainThread) [homeassistant.components.media_player] Setting up media_player.androidtv
2020-01-18 17:38:04 INFO (MainThread) [homeassistant.components.media_player] Setting up media_player.androidtv
2020-01-18 17:38:04 WARNING (SyncWorker_17) [androidtv.adb_manager] Couldn't connect to 192.168.1.160:5555 via ADB server 192.168.1.161:5037
2020-01-18 17:38:04 WARNING (SyncWorker_11) [androidtv.adb_manager] Couldn't connect to 192.168.1.99:5555 via ADB server 127.0.0.1:5037
2020-01-18 17:38:05 DEBUG (SyncWorker_17) [androidtv.adb_manager] ADB command not sent to 192.168.1.160:5555 via ADB server 192.168.1.161:5037 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
2020-01-18 17:38:05 DEBUG (SyncWorker_11) [androidtv.adb_manager] ADB command not sent to 192.168.1.99:5555 via ADB server 127.0.0.1:5037 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
2020-01-18 17:38:05 DEBUG (SyncWorker_17) [androidtv.basetv] 192.168.1.160:5555 `get_device_properties` response: None
2020-01-18 17:38:05 DEBUG (SyncWorker_11) [androidtv.basetv] 192.168.1.99:5555 `get_device_properties` response: None

There is a LOT of information in the documentation, including how to deal with state detection issues.

https://www.home-assistant.io/integrations/androidtv/

I also updated the documentation to indicate that you should try the Python ADB implementation first and only use the ADB server approach if you experience issues. With that said, here’s what you should do.

  1. Delete the ADB add-on.
  2. Restart the Fire TVs.
  3. Remove adb_server_ip (and adb_server_port) from your config.
  4. Restart HA.
  5. For each Fire TV device, you should see a notification about a new connection. Check the box that says “always allow connections from this computer” and hit OK.

Unrelated to above post… (and not actually a firetv/Android tv issue) but we got a second Toshiba Fire TV… connected fine, but was getting daily disconnects after being off for any length… this tv uses Wi-Fi only and my main tv is on Ethernet… so I thought maybe that was why, I enabled adb server, all is well but I cannot for the life of me get the adb server to start on boot… running Ubuntu 19.10, created a shell script in init.d per some instructions I found… no log messages to be found anywhere (I think it would need to be added to said script for it to log anything, but kind of over my head )… but anyway when I manually start adb server, I seem to be all good until I reboot whole system… does anyone have their adb server starting on boot and connecting successfully? And if so can you share your setup please?

Or should I move back to the adb key method and start debugging further? Does anyone else use Wi-Fi only and have solid connection all the time?

https://www.home-assistant.io/integrations/androidtv#adb-troubleshooting

#6 might apply.

  1. If your device drops off WiFi, breaking the ADB connection and causing the entity to become unavailable in Home Assistant, you could install a wake lock utility (such as Wakelock) to prevent this from happening. Some users have reported this problem with Xiaomi Mi Box devices.

Also, if your device drops off WiFi then it should be unavailable, regardless of which ADB connection method you’re using. But it should reconnect once the device gets back on WiFi.

Stupid question from me then, is there a guide somewhere on the Python ADB implementation ?

Please read the integration page that I linked.

Please tell me that’s a recent edit cuz I swear I’ve read those troubleshooting steps multiple times and never noticed that part… sorry and thanks I’ll look into it.

Yeah, it’s recent. No problem. Please report back whether it works!

Good day. Reaching out to xiaomi television users for experience/guidance.
So mitv is connected via ethernet and android component works. When the television is switched off, after approx 5 minutes it becomes unavailable in HA. I can then turn it on with wakeon lan and it becomes available again.
Problem is if you restart HA while the TV is off, it will not be picked by HA later on even if started. So effectively every time you restart HA the TV needs to be on to retain the connection.

So I tried using WiFi and removed ethernet. It works and the TV will remain connected as its connected via WiFi continuously.
The problem is that when you turn it off, it will reboot after 10 minutes and stay on. Turn it off, 10 minutes later same thing.

Anyone has any suggestions?

Thank you

You may want to look into Wakelock it is referenced in the troubleshooting section here:

Thank you for your reply. Much appreciated.
I do have it installed.
It doesn’t work when ethernet connected.
As I mentioned wifi seems to remain connected but the TV reboots every 10 minutes

Question: How does one install Wakelock on Toshiba (Amazon) FireTV?