The Android TV component in HA 0.100 contains some fixes in the backend package that handles the Python ADB implementation. If youâre having any issues with the ADB server approach, or youâd rather run an ADB server container, I suggest trying the Python ADB implementation approach.
Stop the ADB server
Copy the key(s) from the ADB server to your HA config directory and add adbkey to your config
Restart your Android TV / Fire TV device
Restart HA
If you experience any issues with the HA media player becoming unavailable, you can capture debug logs for the adb_shell package by using the logger.set_level service with the parameters
With the python implementation I get the following log:
2019-10-29 10:13:34 DEBUG (SyncWorker_7) [adb_shell.adb_device] bulk_write: b'CNXN\x00\x00\x00\x01\x00\x10\x00\x00"\x00\x00\x00\xd1\x0c\x00\x00\xbc\xb1\xa7\xb1'
2019-10-29 10:13:34 DEBUG (SyncWorker_7) [adb_shell.adb_device] bulk_write: b'host::homeassistant.local.hass.io\x00'
2019-10-29 10:13:34 WARNING (SyncWorker_7) [androidtv.adb_manager] Couldn't connect to host 192.168.178.27:5555, error: Broken pipe
2019-10-29 10:13:35 DEBUG (SyncWorker_7) [androidtv.adb_manager] ADB command not sent to 192.168.178.27:5555 because 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-10-29 10:13:35 WARNING (SyncWorker_7) [homeassistant.components.androidtv.media_player] Could not connect to Fire TV at 192.168.178.27:5555 using Python ADB implementation without adbkey authentication
2019-10-29 10:14:06 DEBUG (SyncWorker_8) [adb_shell.adb_device] bulk_write: b'CNXN\x00\x00\x00\x01\x00\x10\x00\x00"\x00\x00\x00\xd1\x0c\x00\x00\xbc\xb1\xa7\xb1'
2019-10-29 10:14:06 DEBUG (SyncWorker_8) [adb_shell.adb_device] bulk_write: b'host::homeassistant.local.hass.io\x00'
2019-10-29 10:14:06 WARNING (SyncWorker_8) [androidtv.adb_manager] Couldn't connect to host 192.168.178.27:5555, error: Broken pipe
2019-10-29 10:14:06 DEBUG (SyncWorker_8) [androidtv.adb_manager] ADB command not sent to 192.168.178.27:5555 because 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-10-29 10:14:06 WARNING (SyncWorker_8) [homeassistant.components.androidtv.media_player] Could not connect to Fire TV at 192.168.178.27:5555 using Python ADB implementation without adbkey authentication
There shows no entity up with the python implementation.
Using the server addon this is the log:
2019-10-29 10:10:46 DEBUG (SyncWorker_12) [androidtv.adb_manager] ADB connection to 192.168.178.27:5555 via ADB server 127.0.0.1:5037 successfully established
2019-10-29 10:10:46 DEBUG (SyncWorker_12) [androidtv.adb_manager] Sending command to 192.168.178.27: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
2019-10-29 10:10:47 DEBUG (SyncWorker_12) [homeassistant.components.androidtv.media_player] Setup Fire TV at 192.168.178.27:5555 using ADB server at 127.0.0.1:5037
2019-10-29 10:10:59 DEBUG (SyncWorker_6) [androidtv.adb_manager] Sending command to 192.168.178.27:5555 via ADB server 127.0.0.1:5037: dumpsys power | grep 'Display Power' | grep -q 'state=ON' && echo -e '1\c' && dumpsys power | grep mWakefulness | grep -q Awake && echo -e '1\c' && dumpsys power | grep Locks | grep 'size=' && CURRENT_APP=$(dumpsys window windows | grep mCurrentFocus) && CURRENT_APP=${CURRENT_APP#*{* * } && CURRENT_APP=${CURRENT_APP%%/*} && echo $CURRENT_APP && (dumpsys media_session | grep -A 100 'Sessions Stack' | grep -A 100 $CURRENT_APP | grep -m 1 'state=PlaybackState {' || echo) && ps | grep u0_a
2019-10-29 10:11:00 DEBUG (SyncWorker_6) [androidtv.firetv] Fire TV 192.168.178.27:5555 update response:
2019-10-29 10:11:10 DEBUG (SyncWorker_8) [androidtv.adb_manager] Sending command to 192.168.178.27:5555 via ADB server 127.0.0.1:5037: dumpsys power | grep 'Display Power' | grep -q 'state=ON' && echo -e '1\c' && dumpsys power | grep mWakefulness | grep -q Awake && echo -e '1\c' && dumpsys power | grep Locks | grep 'size=' && CURRENT_APP=$(dumpsys window windows | grep mCurrentFocus) && CURRENT_APP=${CURRENT_APP#*{* * } && CURRENT_APP=${CURRENT_APP%%/*} && echo $CURRENT_APP && (dumpsys media_session | grep -A 100 'Sessions Stack' | grep -A 100 $CURRENT_APP | grep -m 1 'state=PlaybackState {' || echo) && ps | grep u0_a
2019-10-29 10:11:10 DEBUG (SyncWorker_8) [androidtv.firetv] Fire TV 192.168.178.27:5555 update response:
2019-10-29 10:11:21 DEBUG (SyncWorker_5) [androidtv.adb_manager] Sending command to 192.168.178.27:5555 via ADB server 127.0.0.1:5037: dumpsys power | grep 'Display Power' | grep -q 'state=ON' && echo -e '1\c' && dumpsys power | grep mWakefulness | grep -q Awake && echo -e '1\c' && dumpsys power | grep Locks | grep 'size=' && CURRENT_APP=$(dumpsys window windows | grep mCurrentFocus) && CURRENT_APP=${CURRENT_APP#*{* * } && CURRENT_APP=${CURRENT_APP%%/*} && echo $CURRENT_APP && (dumpsys media_session | grep -A 100 'Sessions Stack' | grep -A 100 $CURRENT_APP | grep -m 1 'state=PlaybackState {' || echo) && ps | grep u0_a
2019-10-29 10:11:21 DEBUG (SyncWorker_5) [androidtv.firetv] Fire TV 192.168.178.27:5555 update response:
2019-10-29 10:11:32 DEBUG (SyncWorker_1) [androidtv.adb_manager] Sending command to 192.168.178.27:5555 via ADB server 127.0.0.1:5037: dumpsys power | grep 'Display Power' | grep -q 'state=ON' && echo -e '1\c' && dumpsys power | grep mWakefulness | grep -q Awake && echo -e '1\c' && dumpsys power | grep Locks | grep 'size=' && CURRENT_APP=$(dumpsys window windows | grep mCurrentFocus) && CURRENT_APP=${CURRENT_APP#*{* * } && CURRENT_APP=${CURRENT_APP%%/*} && echo $CURRENT_APP && (dumpsys media_session | grep -A 100 'Sessions Stack' | grep -A 100 $CURRENT_APP | grep -m 1 'state=PlaybackState {' || echo) && ps | grep u0_a
2019-10-29 10:11:32 DEBUG (SyncWorker_1) [androidtv.firetv] Fire TV 192.168.178.27:5555 update response:
In this case there is an entity for the media_player.fire_tv with the following state:
adb_response: null
friendly_name: Fire TV
supported_features: 22961
But the entity is not working and not showing up in the lovelace UI.
I would be very happy if someone here is able to help me. Thanks a lot!
The Python ADB implementation fails because you didnât provide a key; in the next HA version (released tomorrow), HA will generate a key for you if you do not provide one and so your config should work.
It looks like the ADB server approach worked. If the entity isnât showing up in the UI, then you need to add it to the UI. Based on your logs, it should be in the âoffâ state.
You are right, it was not showing up in the UI because the automatic control of Lovelace was disabled and I didnât know that. Now it shows up again as it did when I startet investigating this issue⌠The card has the following content using the ADB server approach:
No state available for media_player.fire_tv
{
"type": "media-control",
"entity": "media_player.fire_tv"
}
And there is no entity showing up anymore in the developer options. Config is still the same as above with the added server ip.
If thereâs no entity on the States page, then it failed to setup the component. The log should confirm this.
I suggest waiting until later today when HA 0.101 is released and using the Python ADB approach. Read the documentation (which will be updated when 0.101 is released), especially the ADB Troubleshooting section. In particular, youâll need to stop your ADB server and restart your Fire TV device, otherwise the Python ADB connection wonât work.
Yesterday evening it worked suddenly again with the adb server approach. I didnât change anything.
But after the update I switched to the new python approach and it works great so far. But I still have a question: Is there some possibility to list custom apps with custom names in the Sources? The sources sometimes show all apps, sometimes only some and Iâd like to rename them.
Hi there all,
I just want to ask you all if itâs possible to link the Google Home Assistant to my
Android TV⌠I have a Philips Android TV.
The Google Home Assistens allready work on my Hassio with other commands.
This thread itâs about a lot of procedure and a lot of problems.
Is there any simple plugin in order to just have âHey Google⌠turn on the TVâ
Or maybe a step-by-step link on some web page.
Iâve got a problem retrieving the current state of my FireTV Stick. Getting states (playing, paused) for Netflix works very reliable (just with a little delay sometimes). But for prime video itâs going to paused very often though Iâm still playing.
The reddish color is playing, green is paused. Iâve been playing a movie without pausing, though. the last part (saying âSpieltâ) is played using netflix. As you can see, there are no false states.
I also experience this with Prime Video on my Nvidia Shield. From what I saw itâs reporting different values for the wake_lock_size. Sometimes itâs 4 when itâs playing and then 2 when itâs paused then other times itâs 3 when itâs playing an 1 when itâs paused. Not sure why that app in particular reports different values. Those are used to detect the state of the app. I havenât looked closely at the custom state detection to see if you can specify 2 different values for play/pause or not.
media_player:
- platform: androidtv
name: Android TV
host: 192.168.0.222
state_detection_rules:
'com.amazon.tv.launcher':
- 'playing':
'wake_lock_size': 4 # this indentation is important!
'wake_lock_size': 3 # this indentation is important!
- 'paused':
'wake_lock_size': 2 # this indentation is important!
'wake_lock_size': 1 # this indentation is important!
- 'standby'
âGET_PROPERTIESâ seems to fail when I tryâŚprobably a formatting issue as I wanted to see if I could pull data when the actual BBC app was playing but not sure how to achieve this.
Invalid config for [media_player.androidtv]: 'wake_lock_size' is not a valid state for the 'state_detection_rules' parameter for dictionary value @ data['state_detection_rules']['com.amazon.amazonvideo.livingroom']. Got [OrderedDict([('wake_lock_size', OrderedDict([(4, 'playing'), (3, 'playing'), (2, 'paused'), (1, 'paused')]))]), 'standby']. (See /config/configuration.yaml, line 164). Please check the docs at https://home-assistant.io/integrations/media_player.androidtv/