Native support for Android TV / Android devices

Thanks for that. I was under the impression that I had to use the add on for adb under hassio. That’s how I set it up. I didn’t add the adb server IP. Now that I’ve done that it’s all good. Thanks for the quick help.

Not sure wether I’m correct in this thread as I’m trying to use Home Assistants “native” component with FireTV support (introduced in 0.90). But I ran into an issue when trying to set it up. Posted about it here, maybe you can have a look?

I’m getting the same errors.

Did you use the server method by installing the ADB addon? @capstan1 looks like you have the Android TV addon configured to use the server so I just wanted to make sure you had the server set up and configured. You also need to make sure the server is able to connect to your devices. The device will prompt to trust this computer. If that doesn’t happen, then that’s your issue.

I have Hassio 90.1, ADB - Android Debug Bridge 0.3.0 installed.

ADB Bridge log:

[20:48:24] INFO: Connecting to device: 192.168.1.189…
connected to 192.168.1.189:5555

I accepted the auth on the TV so it looks they are communicating.

But in the Hassio log:

2019-03-25 20:49:45 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 115, 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 152, in get_device_properties
wifimac = re.findall(WIFIMAC_REGEX_PATTERN, wifi_out)[0]
IndexError: list index out of range

Any idea to fix? I googled it but that just caused me more confusion…
Thanks

I have Hassio 90.1, ADB - Android Debug Bridge 0.3.0 installed.

If i edit out the philipstv section below then the shieldtv is picked up and works great, if I include the philipstv section I get the errors below and neither devices are picked up…any ideas? I have had the secure box popup on both tv’s and have accepted the connection permanently.

configuration.yaml:

  • platform: androidtv
    host: 192.168.10.35
    name: ShieldTV
    adb_server_ip: 127.0.0.1
    apps:
    com.google.android.tvlauncher: “Home”
    com.google.android.youtube.tv: “Youtube”
    com.amazon.amazonvideo.livingroom: “Amazon Prime Video”
    com.plexapp.android: “Plex”
    com.netflix.ninja: “Netflix”

  • platform: androidtv
    host: 192.168.10.31
    name: PhilipsTV
    adb_server_ip: 127.0.0.1
    apps:
    com.google.android.tvlauncher: “Home”
    com.google.android.youtube.tv: “Youtube”
    com.amazon.amazonvideo.livingroom: “Amazon Prime Video”
    com.plexapp.android: “Plex”
    com.netflix.ninja: “Netflix”

ADB Bridge log:

[22:58:13] INFO: Starting the Android Debug Bridge server…
error: could not install smartsocket listener: Address already in use
[22:58:14] INFO: Starting the Android Debug Bridge server…
error: could not install smartsocket listener: Address already in use

repeats…

if I restart app then the error goes and connects to both shieldtv & philipstv

the hassio log:

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 119, in setup_platform
if not aftv.available:
File “/config/deps/lib/python3.7/site-packages/androidtv/basetv.py”, line 218, in available
adb_devices = self._adb_client.devices()
File “/config/deps/lib/python3.7/site-packages/adb_messenger/command/host/init.py”, line 19, in devices
result = self._execute_cmd(cmd)
File “/config/deps/lib/python3.7/site-packages/adb_messenger/command/host/init.py”, line 10, in _execute_cmd
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 80, in _check_status
recv = self._recv(4).decode(‘utf-8’)
File “/config/deps/lib/python3.7/site-packages/adb_messenger/connection.py”, line 56, in _recv
return self.socket.recv(length)
ConnectionResetError: [Errno 104] Connection reset by peer


Its great on the shieldtv, but frustrating that the philips won’t work especially as its just had a major update to the android interface (now same as shieldtv)

I’ve found that restarting the TV (not just turning off and on) and restarting hassio gets it to reconnect. Not ideal, but I have 5 Android TV’s so I was able to check as this happened in different sets multiple times.

I fixed this in the next release. In the meantime, you can use it as a custom component.

Thanks for your reply @panteragstk ! The addon is connecting succesfully:

[06:48:18] INFO: Connecting to device: 192.168.0.7…
connected to 192.168.0.7:5555

So my Mibox3 has been an absolute pain with this and the ADB binaries. Everything would work fine while it was on, but would constantly either drop connection or take about 30 secs per update cycle, fail to respond or just go into a reconnect loop when it was switched off. Testing with from the command line showed either horrible response times or a timeout.

And it finally dawned on me why! F#*king Android Doze! The damn thing is dropping into battery saving mode, throttling the cpu and dropping the wifi into “location and whitelisted apps only” mode.

One quick install of Wake Lock v3 on the Mibox, set to autostart and keep full CPU and Wifi locks, and everything works like magic…

I should just learn by now, if something is acting odd on Android, it’s probably Doze mode…

Now I’m off to test if that fixes the builtin adb server too…

Edit: Yes, yes, it looks like it does… Goddamn power saving…

2 Likes

I have Hassio 0.90.2 , ADB - Android Debug Bridge 0.3.0 installed.
This components work fine with my phone, but not with my androidtv

ADB Bridge log:

[18:23:02] INFO: Connecting to device: 192.168.1.10...
connected to 192.168.1.10:5555

But in Hassio Log i get this

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 115, in setup_platform
device_class=config[CONF_DEVICE_CLASS])
File “/config/deps/lib/python3.7/site-packages/androidtv/init.py”, line 34, in setup
return AndroidTV(host, adbkey, adb_server_ip, adb_server_port)
File “/config/deps/lib/python3.7/site-packages/androidtv/androidtv.py”, line 59, in init
self.device_properties = self.get_device_properties()
File “/config/deps/lib/python3.7/site-packages/androidtv/androidtv.py”, line 152, in get_device_properties
wifimac = re.findall(WIFIMAC_REGEX_PATTERN, wifi_out)[0]
IndexError: list index out of range

How i can fix this?

It’s fixed in the next release.

https://github.com/home-assistant/home-assistant/pull/22279

1 Like

Same problem today

Does anyone know where in tmp androidtv.media_player is stored? I replaced it already with androidtv.adb_command yet I still get an error that it found something in tmp with androidtv.media_player.

This is from my log:

Unable to prepare setup for platform androidtv.media_player: Could not install all requirements.

9:10 AM setup.py (ERROR)

Not initializing androidtv.media_player because could not install requirement androidtv==0.0.14

9:10 AM requirements.py (ERROR)

Unable to install package androidtv==0.0.14: Failed building wheel for pycryptodome python-jose-cryptodome 1.3.2 has requirement pycryptodome<3.4.0,>=3.3.1, but you’ll have pycryptodome 3.8.1 which is incompatible. pyrebase4 4.3.0 has requirement oauth2client==4.1.2, but you’ll have oauth2client 4.0.0 which is incompatible. broadlink 0.9 has requirement pycryptodome==3.4.11, but you’ll have pycryptodome 3.8.1 which is incompatible. Command “/usr/local/bin/python3 -u -c “import setuptools, tokenize;file=’/tmp/pip-install-i6pphdft/pycryptodome/setup.py’;f=getattr(tokenize, ‘open’, open)(file);code=f.read().replace(’\r\n’, ‘\n’);f.close();exec(compile(code, file, ‘exec’))” install --record /tmp/pip-record-5t4qnzmc/install-record.txt --single-version-externally-managed --prefix --compile --user --prefix=” failed with error code 1 in /tmp/pip-install-i6pphdft/pycryptodome/

9:10 AM util/package.py (ERROR)

2 Likes

Same error after updating to 0.91

I’ve got the same error after updating to 0.91

ADB is connecting 19:22:15] INFO: Connecting to device: 192.168.1.112... already connected to 192.168.1.112:5555

But get these messages in the log upon startup

Unable to install package androidtv==0.0.14: Failed building wheel for pycryptodome python-jose-cryptodome 1.3.2 has requirement pycryptodome<3.4.0,>=3.3.1, but you'll have pycryptodome 3.8.1 which is incompatible. pyrebase4 4.3.0 has requirement oauth2client==4.1.2, but you'll have oauth2client 4.0.0 which is incompatible. broadlink 0.9 has requirement pycryptodome==3.4.11, but you'll have pycryptodome 3.8.1 which is incompatible. Command "/usr/local/bin/python3 -u -c "import setuptools, tokenize;__file__='/tmp/pip-install-auja82e5/pycryptodome/setup.py';f=getattr(tokenize, 'open', open)(__file__);code=f.read().replace('\r\n', '\n');f.close();exec(compile(code, __file__, 'exec'))" install --record /tmp/pip-record-9ss__l_o/install-record.txt --single-version-externally-managed --prefix --compile --user --prefix=" failed with error code 1 in /tmp/pip-install-auja82e5/pycryptodome

Not initializing androidtv.media_player because could not install requirement androidtv==0.0.14

Unable to prepare setup for platform androidtv.media_player: Could not install all requirements.

:frowning:

I have similar issue. 0.91

2019-04-04 18:46:33 ERROR (SyncWorker_5) [homeassistant.util.package] Unable to install package androidtv==0.0.14: Failed building wheel for pycryptodome

python-jose-cryptodome 1.3.2 has requirement pycryptodome&lt;3.4.0,&gt;=3.3.1, but you'll have pycryptodome 3.8.1 which is incompatible.

pyrebase4 4.3.0 has requirement oauth2client==4.1.2, but you'll have oauth2client 4.0.0 which is incompatible.

broadlink 0.9 has requirement pycryptodome==3.4.11, but you'll have pycryptodome 3.8.1 which is incompatible.

Command "/usr/local/bin/python3 -u -c "import setuptools, tokenize;__file__='/tmp/pip-install-2a4zmcxt/pycryptodome/setup.py';f=getattr(tokenize, 'open', open)(__file__);code=f.read().replace('\r\n', '\n');f.close();exec(compile(code, __file__, 'exec'))" install --record /tmp/pip-record-sr77539d/install-record.txt --single-version-externally-managed --prefix --compile --user --prefix=" failed with error code 1 in /tmp/pip-install-2a4zmcxt/pycryptodome/

2019-04-04 18:46:33 ERROR (MainThread) [homeassistant.requirements] Not initializing androidtv.media_player because could not install requirement androidtv==0.0.14

2019-04-04 18:46:33 ERROR (MainThread) [homeassistant.setup] Unable to prepare setup for platform androidtv.media_player: Could not install all requirements.

I have this issue aswell.

+1 with the same issues listed in the previous 5 comments after updating to 0.91

2019-04-04 21:59:27 ERROR (SyncWorker_14) [homeassistant.util.package] Unable to install package androidtv==0.0.14: Failed building wheel for pycryptodome
python-jose-cryptodome 1.3.2 has requirement pycryptodome&lt;3.4.0,&gt;=3.3.1, but you'll have pycryptodome 3.8.1 which is incompatible.
pyrebase4 4.3.0 has requirement oauth2client==4.1.2, but you'll have oauth2client 4.0.0 which is incompatible.
broadlink 0.9 has requirement pycryptodome==3.4.11, but you'll have pycryptodome 3.8.1 which is incompatible.
Command "/usr/local/bin/python3 -u -c "import setuptools, tokenize;__file__='/tmp/pip-install-bxch3zcf/pycryptodome/setup.py';f=getattr(tokenize, 'open', open)(__file__);code=f.read().replace('\r\n', '\n');f.close();exec(compile(code, __file__, 'exec'))" install --record /tmp/pip-record-m6qh8e0_/install-record.txt --single-version-externally-managed --prefix --compile --user --prefix=" failed with error code 1 in /tmp/pip-install-bxch3zcf/pycryptodome/
2019-04-04 21:59:27 ERROR (MainThread) [homeassistant.requirements] Not initializing androidtv.media_player because could not install requirement androidtv==0.0.14
2019-04-04 21:59:27 ERROR (MainThread) [homeassistant.setup] Unable to prepare setup for platform androidtv.media_player: Could not install all requirements.
2019-04-04 17:20:00 ERROR (SyncWorker_4) [homeassistant.util.package] Unable to install package androidtv==0.0.14: Failed building wheel for pycryptodome
python-jose-cryptodome 1.3.2 has requirement pycryptodome<3.4.0,>=3.3.1, but you'll have pycryptodome 3.8.1 which is incompatible.
pyrebase4 4.3.0 has requirement oauth2client==4.1.2, but you'll have oauth2client 4.0.0 which is incompatible.
broadlink 0.9 has requirement pycryptodome==3.4.11, but you'll have pycryptodome 3.8.1 which is incompatible.
Command "/usr/local/bin/python3 -u -c "import setuptools, tokenize;__file__='/tmp/pip-install-leq3wqr4/pycryptodome/setup.py';f=getattr(tokenize, 'open', open)(__file__);code=f.read().replace('\r\n', '\n');f.close();exec(compile(code, __file__, 'exec'))" install --record /tmp/pip-record-m8q09x19/install-record.txt --single-version-externally-managed --prefix  --compile --user --prefix=" failed with error code 1 in /tmp/pip-install-leq3wqr4/pycryptodome/
2019-04-04 17:20:00 ERROR (MainThread) [homeassistant.requirements] Not initializing androidtv.media_player because could not install requirement androidtv==0.0.14
2019-04-04 17:20:00 ERROR (MainThread) [homeassistant.setup] Unable to prepare setup for platform androidtv.media_player: Could not install all requirements.

Same issue here since 0.91 update. Rolling back…