Native support for Android TV / Android devices

Does anybody know how to turn on / off Ambilight + Hue on a philips android TV using this component?

I tried to use it with Philips TV 55POS900212 and experience the same issue when it correctly shows which app is running but it doesn’t change idle status to playing when the app is actually playing. I can provide details if it helps to debug it.

Hello everyone,
I have the mibox and the components wich works well.
But the original remote is broken so I replace it by USB remote.

Activate USB debugging in the mibox completely deactivate all remote connected to the mibox.

An idea ?

You should use your smartphone to control it.
Search for Android TV Remote control. Works perfectly for me.

thanks but my wife will never accept that :smiley:

fix for 0.88.0:
the include at line 33

from homeassistant.components.media_player import (
    DOMAIN, MediaPlayerDevice, PLATFORM_SCHEMA, SUPPORT_NEXT_TRACK,
    SUPPORT_PAUSE, SUPPORT_PLAY,
    SUPPORT_PREVIOUS_TRACK, SUPPORT_STOP, SUPPORT_TURN_OFF,
    SUPPORT_TURN_ON, SUPPORT_VOLUME_MUTE, SUPPORT_VOLUME_STEP)

becomes:

from homeassistant.components.media_player import ( DOMAIN,
    MediaPlayerDevice, PLATFORM_SCHEMA)
from homeassistant.components.media_player.const import (
    SUPPORT_NEXT_TRACK, SUPPORT_PAUSE, SUPPORT_PLAY,
    SUPPORT_PREVIOUS_TRACK, SUPPORT_STOP, SUPPORT_TURN_OFF,
    SUPPORT_TURN_ON, SUPPORT_VOLUME_MUTE, SUPPORT_VOLUME_STEP)

Hello I’m a Hass.io user and tried setting this up in version 0.87.1. I get the following error even though the ADB addon is showing connectivity to my AndroidTV. Any ideas anyone? I’ve tried deleting the deps folder and letting it rebuild. I’m using the latest androidtv.py file (.0.0.7) so at a loss at the moment.

2019-02-20 17:40:42 ERROR (MainThread) [homeassistant.components.media_player] Error while setting up platform androidtv
Traceback (most recent call last):
File “/usr/local/lib/python3.6/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.6/asyncio/tasks.py”, line 358, in wait_for
return fut.result()
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 196, in setup_platform
adb_server_port=config[CONF_ADB_SERVER_PORT])
File “/config/deps/lib/python3.6/site-packages/androidtv/init.py”, line 249, in init
self.properties = self.device_info()
File “/config/deps/lib/python3.6/site-packages/androidtv/init.py”, line 441, in device_info
properties = self.adb_shell(‘getprop’)
File “/config/deps/lib/python3.6/site-packages/androidtv/init.py”, line 272, in _adb_shell_pure_python_adb
return self._adb_device.shell(cmd)
File “/config/deps/lib/python3.6/site-packages/adb_messenger/command/transport/init.py”, line 20, in shell
conn = self.create_connection(timeout=timeout)
File “/config/deps/lib/python3.6/site-packages/adb_messenger/device.py”, line 45, in create_connection
self.transport(conn)
File “/config/deps/lib/python3.6/site-packages/adb_messenger/command/transport/init.py”, line 15, in transport
connection.send(cmd)
File “/config/deps/lib/python3.6/site-packages/adb_messenger/connection.py”, line 77, in send
return self._check_status()
File “/config/deps/lib/python3.6/site-packages/adb_messenger/connection.py”, line 83, in _check_status
raise RuntimeError(“ERROR: {} {}”.format(repr(recv), error))
RuntimeError: ERROR: ‘FAIL’ 000edevice offline

Got this in 0.88

2019-02-21 10:18:55 ERROR (MainThread) [homeassistant.loader] Error loading custom_components.media_player.androidtv. Make sure all dependencies are installed

Traceback (most recent call last):

File "/usr/local/lib/python3.7/site-packages/homeassistant/loader.py", line 147, in _load_file

module = importlib.import_module(path)

File "/usr/local/lib/python3.7/importlib/__init__.py", line 127, in import_module

return _bootstrap._gcd_import(name[level:], package, level)

File "<frozen importlib._bootstrap>", line 1006, in _gcd_import

File "<frozen importlib._bootstrap>", line 983, in _find_and_load

File "<frozen importlib._bootstrap>", line 967, in _find_and_load_unlocked

File "<frozen importlib._bootstrap>", line 677, in _load_unlocked

File "<frozen importlib._bootstrap_external>", line 728, in exec_module

File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed

File "/config/custom_components/media_player/androidtv.py", line 33, in <module>

from homeassistant.components.media_player import (

ImportError: cannot import name 'SUPPORT_TURN_OFF' from 'homeassistant.components.media_player' (/usr/local/lib/python3.7/site-packages/homeassistant/components/media_player/__init__.py)

2019-02-21 10:18:55 ERROR (MainThread) [homeassistant.loader] Unable to find platform androidtv

I guess is not yet fixed in github

go up a few messages, I wrote a simple fix. and yes it’s not committed yet =)

1 Like

Is this simple fix available? I keep getting “Platform not found: media_player.androidtv” after updating to 0.88.0

I hope this migration guide helps: https://developers.home-assistant.io/blog/2019/02/19/the-great-migration.html

  • create a folder named androidtv in custom_components
  • put androidtv.py into custom_components/androidtv and rename it to media_player.py

my file is now at: /config/custom_components/androidtv/media_player.py

Still getting this error: Platform not found: media_player.androidtv

1 Like

You might need to add an empty file in the androidtv directory named __init__.py.

The other error is due to imports changing. This line from homeassistant.components.media_player import ( needs to become from homeassistant.components.media_player.const import (

Didn’t help…

Tried all the same, upgraded to .88 made the changes pier and fahr suggested and getting the device offline error still. I even tried the suggestion made way further back by Kyle: Native support for Android TV / Android devices

Still getting this error, any help would be appreciated:

2019-02-21 17:40:10 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 230, in init
self.properties = self.device_info()
File “/config/deps/lib/python3.7/site-packages/androidtv/init.py”, line 325, in device_info
properties = self._adb_shell(‘getprop’)
File “/config/deps/lib/python3.7/site-packages/androidtv/init.py”, line 479, 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 20, in shell
conn = self.create_connection(timeout=timeout)
File “/config/deps/lib/python3.7/site-packages/adb_messenger/device.py”, line 45, in create_connection
self.transport(conn)
File “/config/deps/lib/python3.7/site-packages/adb_messenger/command/transport/init.py”, line 15, in transport
connection.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’ 000edevice offline

So I did the changes that fahr mentioned but with the following file setup: /config/custom_components/media_player/androidtv.py

Now I get this error: Package androidtv setup failed. Component media_player cannot be merged. Expected a dict.

I did all of the changes above, but it wasn’t until I deleted the deps folder and rebooted 2 or 3 times to compiled new deps that it started working.

Did you delete the deps folder each time you restarted?
I’m still getting the following error:

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 183, in setup_platform
    atv = AndroidTV(host, adbkey)
  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 446, in device_info
    wifi_out = self.adb_shell('ip addr show wlan0')
  File "/config/deps/lib/python3.7/site-packages/androidtv/__init__.py", line 262, 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'