Native support for Android TV / Android devices


#182

I had the same error yet when I turned the tv off and rebooted it works no problem


#183

I can’t seem to enable ADB on my Mi Box S. Any tips on how to acheive this? The internet seems to be saying that ADB debugging is disabled on Mi Box S (or perhaps rather port 5555 is), and my testing is agreeing with that. Enabled USB Debugging but can’t connect the ADB server. Running version 8.1.0. Thanks!


#184

you need to enable wireless adb, not sure if this is still current but a little bit of googling led me to this: https://www.reddit.com/r/AndroidTV/comments/61o6l4/mi_box_how_to_connect_adb_over_wifi/dflukgy/


#185

Thanks. I have seen this as well, but it looks like adb is turned off at reboot, so you would need to set up your Mi Box never to turn off, right?


#186

Turn on usb debugging in developer options.


#187

Yes, already did that, but that does not enable ADB over TCP (for me at least), as per above it seems like you need to turn that on over USB and then just make sure your Mi Box doesn’t reset that by rebooting. This is on 8.1. Sounds familiar?


#188

stopped working after latest update


#189

hello everyone,

got some troubles so far making it work on my QNAP nas in containers, but i’m facing an issue and i’m blocked.

I replaced the init file and now I’m getting this error.

anyone has already seen that issue?

fyi, i’m using a custom firmware (https://www.atvxperience.com/).

if i can activate any debug or edit the code to provide more information, i’d be glad to help :slight_smile:

thanks anyway in advance if anyone can help me, or at least point me to the right direction!

PS: can’t wait to make it work !

Traceback (most recent call last):
File “/usr/src/app/homeassistant/helpers/entity.py”, line 221, in async_update_ha_state
await self.async_device_update()
File “/usr/src/app/homeassistant/helpers/entity.py”, line 349, in async_device_update
await self.hass.async_add_executor_job(self.update)
File “/usr/local/lib/python3.6/concurrent/futures/thread.py”, line 56, in run
result = self.fn(*self.args, **self.kwargs)
File “/config/custom_components/media_player/androidtv.py”, line 287, in _adb_wrapper
returns = func(self, *args, **kwargs)
File “/config/custom_components/media_player/androidtv.py”, line 362, in update
self._app_name = self.get_app_name(self.androidtv.app_id)
AttributeError: ‘AndroidTV’ object has no attribute ‘app_id’


#190

You need to be more specific if you need help or want to help. Otherwise all we can say is “oh, really?”.
What does the log say? What exact version are you talking about, hass version, component version, add-on version etc? Give more info otherwise no one will be able to help.


#191

could some please help me
im running hass.io on 88.2 and using the adb addon. i have an nvidia shield that working without issue, yet i can’t get HA to stay connected to my sony bravia

here is the error i’m getting

2019-03-08 08:03:50 ERROR (MainThread) [homeassistant.components.media_player] Error while setting up platform androidtv
Traceback (most recent call last):
  File "/usr/local/lib/python3.7/site-packages/homeassistant/helpers/entity_platform.py", line 128, in _async_setup_platform
    SLOW_SETUP_MAX_WAIT, loop=hass.loop)
  File "/usr/local/lib/python3.7/asyncio/tasks.py", line 416, 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 "/config/custom_components/androidtv/media_player.py", line 196, in setup_platform
    adb_server_port=config[CONF_ADB_SERVER_PORT])
  File "/config/deps/lib/python3.7/site-packages/androidtv/__init__.py", line 249, in __init__
    self.properties = self.device_info()
  File "/config/deps/lib/python3.7/site-packages/androidtv/__init__.py", line 441, in device_info
    properties = self.adb_shell('getprop')
  File "/config/deps/lib/python3.7/site-packages/androidtv/__init__.py", line 272, in _adb_shell_pure_python_adb
    return self._adb_device.shell(cmd)
  File "/config/deps/lib/python3.7/site-packages/adb_messenger/command/transport/__init__.py", line 23, in shell
    conn.send(cmd)
  File "/config/deps/lib/python3.7/site-packages/adb_messenger/connection.py", line 77, in send
    return self._check_status()
  File "/config/deps/lib/python3.7/site-packages/adb_messenger/connection.py", line 83, in _check_status
    raise RuntimeError("ERROR: {} {}".format(repr(recv), error))
RuntimeError: ERROR: 'FAIL' 0006closed

does anyone know how to fix it?


#192

i am getting an error with HA 0.89.1
python 3.5.3
Update for media_player.android_tv_media fails Traceback (most recent call last): File "/srv/homeassistant/lib/python3.5/site-packages/homeassistant/helpers/entity.py", line 220, in async_update_ha_state await self.async_device_update() File "/srv/homeassistant/lib/python3.5/site-packages/homeassistant/helpers/entity.py", line 348, in async_device_update await self.hass.async_add_executor_job(self.update) File "/usr/lib/python3.5/asyncio/futures.py", line 380, in __iter__ yield self # This tells Task to wait for completion. File "/usr/lib/python3.5/asyncio/tasks.py", line 304, in _wakeup future.result() File "/usr/lib/python3.5/asyncio/futures.py", line 293, in result raise self._exception File "/usr/lib/python3.5/concurrent/futures/thread.py", line 55, in run result = self.fn(*self.args, **self.kwargs) File "/home/homeassistant/.homeassistant/custom_components/androidtv/media_player.py", line 262, in __adb_decorator return func(self, *args, **kwargs) File "/home/homeassistant/.homeassistant/custom_components/androidtv/media_player.py", line 323, in update success = self.androidtv.update() File "/srv/homeassistant/lib/python3.5/site-packages/androidtv/__init__.py", line 419, in update screen_on, awake, wake_lock_size, _current_app = self.get_properties(lazy=True) File "/srv/homeassistant/lib/python3.5/site-packages/androidtv/__init__.py", line 672, in get_properties volume_level = re.findall(self.device + VOLUME_REGEX_PATTERN, stream_block, re.DOTALL | re.MULTILINE)[0] IndexError: list index out of range


#193

pip3 install androidtv
solved the issue


#194

When ha is connected to my nividia shield, it sometimes becomes unresponsible.
I push buttons and nothing happens.


#195

I had the same issue.as said earlifer, this can be fixed with the following:
cd /srv/homeassistant/lib/python3.5/site-packages/androidtv/
mv __init__.py __init__.py.bak
wget https://raw.githubusercontent.com/JeffLIrion/python-androidtv/fe6e9ffadfd86ef4c45ce75c3a87e0495bfa45c1/androidtv/__init__.py
then restart HA…
hope you ll be ok after this :slight_smile:


#196

thanks, but now i have different error:

Update for media_player.android_tv_media fails
Traceback (most recent call last):
File “/srv/homeassistant/lib/python3.5/site-packages/homeassistant/helpers/entity.py”, line 220, in async_update_ha_state
await self.async_device_update()
File “/srv/homeassistant/lib/python3.5/site-packages/homeassistant/helpers/entity.py”, line 348, in async_device_update
await self.hass.async_add_executor_job(self.update)
File “/usr/lib/python3.5/asyncio/futures.py”, line 380, in iter
yield self # This tells Task to wait for completion.
File “/usr/lib/python3.5/asyncio/tasks.py”, line 304, in _wakeup
future.result()
File “/usr/lib/python3.5/asyncio/futures.py”, line 293, in result
raise self._exception
File “/usr/lib/python3.5/concurrent/futures/thread.py”, line 55, in run
result = self.fn(*self.args, **self.kwargs)
File “/home/homeassistant/.homeassistant/custom_components/androidtv/media_player.py”, line 262, in __adb_decorator
return func(self, *args, **kwargs)
File “/home/homeassistant/.homeassistant/custom_components/androidtv/media_player.py”, line 323, in update
success = self.androidtv.update()
File “/srv/homeassistant/lib/python3.5/site-packages/androidtv/init.py”, line 315, in update
re.DOTALL | re.MULTILINE)[0]
IndexError: list index out of range


#197

Hi Guy’s,
is there anyone that could help me resolve this issue.
my shield never fails, yet for some reason I can’t get my sony braiva to stay connected, it worked fine for about a week.


#198

wait for a week, a solid androidtv version is coming
It’s under review,
So may be next release


New Android component how do you send youtube links
#199

Strange, but since this became official I’m still getting the following in hassio v0.90.1:

019-03-22 20:59:52 ERROR (MainThread) [homeassistant.components.media_player] Error while setting up platform androidtv
Traceback (most recent call last):
File “/usr/local/lib/python3.7/site-packages/homeassistant/helpers/entity_platform.py”, line 128, in _async_setup_platform
SLOW_SETUP_MAX_WAIT, loop=hass.loop)
File “/usr/local/lib/python3.7/asyncio/tasks.py”, line 416, 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/local/lib/python3.7/site-packages/homeassistant/components/androidtv/media_player.py”, line 105, in setup_platform
device_class=config[CONF_DEVICE_CLASS])
File “/usr/local/lib/python3.7/site-packages/androidtv/init.py”, line 53, in setup
aftv.device_properties = aftv.get_device_properties()
File “/usr/local/lib/python3.7/site-packages/androidtv/androidtv.py”, line 151, in get_device_properties
wifi_out = self.adb_shell(‘ip addr show wlan0’)
File “/usr/local/lib/python3.7/site-packages/androidtv/basetv.py”, line 99, in _adb_shell_python_adb
return self._adb.Shell(cmd)
File “/usr/local/lib/python3.7/site-packages/adb/adb_commands.py”, line 376, in Shell
timeout_ms=timeout_ms)
File “/usr/local/lib/python3.7/site-packages/adb/adb_protocol.py”, line 411, in Command
return ‘’.join(cls.StreamingCommand(usb, service, command, timeout_ms))
File “/usr/local/lib/python3.7/site-packages/adb/adb_protocol.py”, line 439, in StreamingCommand
for data in connection.ReadUntilClose():
AttributeError: ‘NoneType’ object has no attribute ‘ReadUntilClose’


#200

Any other info I can offer here? No t sure where to start troubleshooting. This is on a new hassio vm install. Everything else seems to work fine after migrating from the docker.


#201

This is covered in the documentation, although it wasn’t as clear as I thought it was so I submitted a pull request to make it more clear.

https://deploy-preview-9012–home-assistant-docs.netlify.com/components/androidtv#adb-troubleshooting

The Python ADB implementation isn’t working for your device, so you need to use the ADB server approach.