Native support for Android TV / Android devices


#61

Little update : 127.0.0.1 works just fine !


#62

How do I suppress this in my log?

08-01-2019:14:18:50,270 DEBUG    [connection.py:24] Connect to adb server - 10.0.0.8:5037
08-01-2019:14:18:50,270 DEBUG    [connection.py:75] b'0027host-serial:10.0.0.24:5555:get-serialno'
08-01-2019:14:18:50,271 DEBUG    [connection.py:47] Connection closed...
08-01-2019:14:18:50,272 DEBUG    [connection.py:24] Connect to adb server - 10.0.0.8:5037
08-01-2019:14:18:50,272 DEBUG    [connection.py:24] Connect to adb server - 10.0.0.8:5037
08-01-2019:14:18:50,273 DEBUG    [connection.py:75] b'0027host-serial:10.0.0.23:5555:get-serialno'
08-01-2019:14:18:50,273 DEBUG    [connection.py:47] Connection closed...
08-01-2019:14:18:50,274 DEBUG    [connection.py:24] Connect to adb server - 10.0.0.8:5037
08-01-2019:14:18:50,274 DEBUG    [connection.py:24] Connect to adb server - 10.0.0.8:5037
08-01-2019:14:18:50,275 DEBUG    [connection.py:75] b'001Dhost:transport:10.0.0.23:5555'
08-01-2019:14:18:50,276 DEBUG    [connection.py:75] b'002Ashell:dumpsys power | grep "Display Power"'
08-01-2019:14:18:50,571 DEBUG    [connection.py:47] Connection closed...

#63

Cool, how does one do this? Running hassio ion a rpi3 at the moment!

Step-by-step :slight_smile:


#64
  • Install the “Portainer” add-on from the “Community Hass.io Add-Ons”.
  • Configure and start the add-on.
  • Open Portainer (http://ip-of-hassio:9000) and add a new container with the settings like my sreenshot :

  • Press “Deploy the container” to create the container. This may take a while so wait for the process to complete.
  • When the deploy is ready connect to the shell of the new container, see screenshots :

image

  • When connected to the console enter the following commands :

    apt-get update
    apt-get install android-tools-adb
    adb -a nodaemon server &
    adb connect _ip-of-androidtv_
    

    After entering the adb connect command you should get a popup on your androidtv to trust the connection.

  • You now should be able to use the component with the following settings in your configuration.yaml :

     - platform: androidtv
       host: ip-of-androidtv
       name: AndroidTV   
       adb_server_ip: 127.0.0.1
    

I didn’t test what happens when you restart the container. To make this fool proof you can add a startup script to the raspbian installation to start the adb server.


#65

Thanks for your awesome instructions! :+1:
I think adding a crontab to connect to the device on restart, and also keep connecting to it, like every 10min would make a great Hass.io addons.


#66

Following what @hvdheurik did, I think this ADB server addon works now. Please test it and let me know! https://github.com/JeffLIrion/hassio-adb-server-addon


#67

First of all, love the idea of the add-on ! Makes it much easier to install. After starting the add-on the following error appaers in the log and the add-on stops :

/run.sh: line 9: 10 Segmentation fault (core dumped) adb -a nodaemon server


#68

That’s odd, I definitely didn’t get that error. Did you stop your other container?


#69

Hi @JeffLIrion, this add-on is a great idea!!

I installed the add-on, but I receive the same error:

/run.sh: line 9: 10 Segmentation fault (core dumped) adb -a nodaemon server

I’m running hassio on a Intel NUC


#70

@hvdheurik and @matisaul, I replaced adb -a nodaemon server with adb start-server. I uninstalled and then reinstalled the addon, but now it won’t start for me. I’m not sure what the problem is :thinking:


#71

Yes, i stopped my container but maybe it has something to do with the port (5037) being in use.


#72

Same problem here how to suppress this log spamming? Thanks

my config:

  • Home assistant manual installation on debian in a virtual env

  • in configuration.yaml:

    logger:

    default: warn

#73

So whars the status on this. Does it work ie should one test or is it not working at all currently?


#74

I need help getting it to work. If you think you could fix it, then please give it a shot!


#75

sorry … what’s the syntax to open an applicatio?n (for example, Kodi, Netflix, Plex …)

{ “entity_id” :“media_player.mibox3”, “intent”: “xxxxxxxx” }


#76

If I had the knowhow I would! I appreciate your effort, hopefully it will get solved.


#77

Hass.io ADB server addon (https://github.com/JeffLIrion/hassio-adb-server-addon ) failed to install with the following error

ERROR (SyncWorker_17) [hassio.docker.addon] Can’t build a77d3ee3/amd64-addon-adb_server:0.1: The command ‘/bin/sh -c apt-get update && apt-get install -y jq android-tools-adb’ returned a non-zero code: 100


#78

Yeah, it doesn’t work…:frowning_face:

My next idea is to build from the hassioaddons/ubuntu-base-* images, using the aircast addon as a template.


#79

So I managed to get this working somewhat to my surprise!

My setup is running Hass.io in a VM that sits on unRAID. My Docker understanding is pretty limited to unRAID where i have a number of containers running.

I deployed the Docker container sorccu/adb to unRAID with the following settings

Network Type: Host
Privileged: Yes
Container Port: 5037
Container Path: /opt/platform-tools

I then extracted the latest platform-tools into the local path that was mapped to /opt/platform-tools, In my limited experience i had assumed the docker image would create these files, but aside from a small permissions change it seamed to work fine me manually supplying the platform-tools files.

I added the following to my media_player.yaml, pointing adb_server_ip to my unRAID servers IP

- platform: androidtv
  host: 10.5.5.243
  name: MiBox3
  adb_server_ip: 10.5.5.10

and finally enabled USB / WiFi debugging on the Mi Box (had to connect it to USB before running adb tcpip 5555)

Will report back after using the addon for a while.


#80

That’s what I am doing. But you will find that after some amount of sleep, the ADB connection drops and then this component breaks. I created a cron job to execute adb connect every few minutes to force it to reconnect when the Mi Box wakes up again.