Thanks, will this fix eventually be rolled out in the regular HA updates so that a custom component is no longer required?
Exact same issue I am having! I am on .99.2
Yes. I submitted the pull request yesterday, it should be in the next release.
You rock! By the way, your code works perfect!
@JeffLIrion Did anything change recently with the androidtv
component? I am not able to connect with FireTV. It works fine with Shield.
Nothing that should break it. If it works for an Android TV device, it should work for a Fire TV device. Got a log?
I suggest trying this custom component with the Python ADB approach (HACS compatible): https://github.com/JeffLIrion/ha-androidtv
More info: [TESTERS NEEDED] Android TV / Fire TV key generation
(If you have an existing ADB key and don’t want to test the key generation functionality, you can include adbkey
in your config.)
I am seeing a lot of the following in the logs:
Log Details (WARNING)
Thu Oct 10 2019 13:30:02 GMT-0400 (Eastern Daylight Time)
Platform androidtv not ready yet. Retrying in 180 seconds.
BTW, I have the hassio addon running on another HA instance and I am accessing the devices through that addon. I will try the custom component
Announcement
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
adb_shell: debug
Posting them here is OK, but it would be ideal if you could open a GitHub issue and post them in there: https://github.com/JeffLIrion/adb_shell
Without these debug logs, there is no way to diagnose and fix issues.
Hello,
somehow my integration of the Fire TV is broken. It worked fine but shortly after the update to 0.100.3 it broke.
It’s neither working via the ADB Server Addon nor via the python implementation.
This is my config:
- platform: androidtv
device_class: firetv
name: Fire TV
host: 192.168.178.27
apps:
com.amazon.tv.launcher: "Fire TV"
com.netflix.ninja: "Netflix"
turn_on_command: "input keyevent 3"
turn_off_command: "input keyevent 223"
state_detection_rules:
'com.amazon.tv.launcher':
- 'standby'
'com.netflix.ninja':
- 'media_session_state'
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.
Thanks for your help.
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.
Thanks!
The sources list shows the running apps.
This pull request will use the friendly names instead of the app IDs: https://github.com/home-assistant/home-assistant/pull/28417
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.
Thanks in advance
Denis
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.
Did anyone else experience this?
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.
You can use multiple values.
EDIT
This configuration is incorrect. See here: Native support for Android TV / Android devices
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'
Thanks @JeffLIrion! Will give this a try tonight to see if I can get Prime Video to report state better.
It’s giving me an error ‘duplicate entry for wake_lock_size’. So I’m trying
- platform: androidtv
host: 192.168.178.7
name: "FireTV"
adb_server_ip: 127.0.0.1
state_detection_rules:
'com.amazon.tv.launcher':
- 'wake_lock_size':
4: 'playing' # this indentation is important!
3: 'playing' # this indentation is important!
2: 'paused' # this indentation is important!
1: 'paused' # this indentation is important!
- 'standby'
as described in your thread here
Let’s see how this works out