Page 1 of 1
AndroidTV api
Posted: Tuesday 15 May 2018 17:20
by Egregius
Hi All,
I just installed a Nvidia Shield as Mediaplayer. It'll run Netflix, Spotify, Kodi,...
Does anyone know if there's an api available to control Android TV from within domoticz?
When Kodi is started I can do everything I want, but I first need to start Kodi of course.
Would be great to be able to start the Shield, start a application and control pause/playback.
There are several ports listening, none of them display anything in a browser:
Code: Select all
Port Scanning host: 192.168.2.7
Open TCP Port: 6466
Open TCP Port: 6467
Open TCP Port: 8008 http-alt
Open TCP Port: 8009
Open TCP Port: 9000 cslistener
Open TCP Port: 9080 glrpc
Open TCP Port: 34803
portscan is voltooid…
Any ideas?
Re: AndroidTV api
Posted: Tuesday 15 May 2018 17:47
by skybehind
I don't know if this will help, but it's a guide to build libcec binary on Android
https://www.evernote.com/shard/s426/sh/ ... 6c7cfbd702
Re: AndroidTV api
Posted: Wednesday 16 May 2018 9:08
by Egregius
That's something for controlling devices over HDMI CEC.
I'd rather have a http api, like the json api from Domoticz.
I think the CEC way is mostly arrow up, down etc. Not directly possible the launch apps and stuff like that.
Re: AndroidTV api
Posted: Wednesday 16 May 2018 10:44
by DanM
You can control andrid devices using ADB and sending keypress events. Have a search on the forums for my Fire TV status script (Fire TV runs android, so the basic principles are the same.).
Something along these lines ought to get you started..
http://www.aftvnews.com/how-to-remotely ... ment-58950 (Again, this is fire TV not andorid but the priciples are the same)
Re: AndroidTV api
Posted: Wednesday 16 May 2018 14:42
by Egregius
Thank you for that!
First step: Enable ADB in Nvidia Shield (source:
https://sites.google.com/site/nvidiashi ... -debugging)
Code: Select all
Enable debugging
1. Goto Settings
2. Go across to About in Device
3. Go down to Build and click on it 10times until it says you are in development mode
ADB over USB
1. Make sure you have performed the above steps "Enable debugging"
2. Goto Settings
3. Go Across to Developer options
4. Go down to Debugging
5. Toggle USB debugging to On
ADB over Network
1. Make sure you have performed the above steps "Enable debugging"
2. Make sure you have performed the above steps "ADB over USB"
3. Toggle Network debugging to On
That went ok, see open ports:
Code: Select all
Port Scanning host: 192.168.2.7
Open TCP Port: 139 netbios-ssn
Open TCP Port: 445 microsoft-ds
Open TCP Port: 5555 personal-agent
Open TCP Port: 6466
Open TCP Port: 6467
Open TCP Port: 8008 http-alt
Open TCP Port: 8009
Open TCP Port: 9000 cslistener
Open TCP Port: 9080 glrpc
Open TCP Port: 38321
Now making a snapshot of my Domoticz install before installing the android adb tools.
Edit:
On my Domoticz debian Jessie:
Try a connection with these commands:
Code: Select all
adb kill-server
adb start-server
adb connect 192.168.2.7
Confirm the connection on the Nvidia Shield and place a checkmark on 'always allow device'.
A first small shell script enables me to handle play/pause from within domoticz (wich was the most important part for me)
Code: Select all
#!/bin/bash
adb start-server
adb connect 192.168.2.7
adb shell input keyevent 85
Re: AndroidTV api
Posted: Wednesday 16 May 2018 16:37
by Egregius
Thank you @DanM
Everything working, can control up/down/back etc
Can read the current application, thanks to your script.
Me happy

Re: AndroidTV api
Posted: Friday 18 May 2018 15:20
by DanM
You can also launch apps directly with the right ADB Commands.
Code: Select all
start -n com.package.name/com.package.name.ActivityName
You will have to google for the package names, but Ive had success launching netflix, iplayer and Kodi this way. Ill try and look at my code later if I can find some examples.
Re: AndroidTV api
Posted: Friday 18 May 2018 16:25
by Egregius
Sounds great, will try that later
Guess that would be something like this then:
Code: Select all
adb start -n com.package.name/com.package.Netflix.ActivityName
Edit, no should be more like
Code: Select all
adb shell "start -n com.package.name/com.package.name.ActivityName"
but I'm getting "start: must be root"
Re: AndroidTV api
Posted: Friday 18 May 2018 17:47
by kllngtme
Any way to power off the Shield in this manner as well or check status to see if it's online (other than a ping request to it)