Sure. I don't know how useful the function would be in the context of using heroku or lambada instances. I'm just issuing adb shell commands from my raspberry pi running your script using apache and mod_wsgi. To authorize tcpip debugging on the shield you have to connect the pi directly to the shield using USB to get the RSA key so I'm not sure there is anyway to do this with a cloud instance of the script.
P.S. Python is new to me.
So in the .py file I have:
Code:
import subprocess
def SendADB(app, channel=""):
output = 1
count = 0
while (output != 0 and count < 10):
output = subprocess.call("sudo adb connect " + KODI, shell=True)
if output == 0:
output = subprocess.call("sudo adb shell monkey -p " + app + " -c android.intent.category.LAUNCHER 1", shell=True)
if (output == 0 and channel != ""):
subprocess.call("sudo adb shell input text '" + channel + "'", shell=True)
if output == 0:
output = subprocess.call("sudo adb disconnect", shell=True)
count += 1
I'm just passing the android app name "com.netflix.ninja" to the function. If there is a channel number passed I'm assuming the app passed was the live tv app on the shield "com.google.android.tv". I loop trough a couple of times to make sure the shield is awake and that the adb daemon started.
For the Next Aired plugin (this is ugly) I'm just requesting the URL.
Code:
# Open Next Aired
def OpenNextAired():
requests.get('http://' + KODI + ':' +str(PORT) + '/jsonrpc?request={"jsonrpc":%20"2.0",%20"method":%20"Addons.ExecuteAddon",%20"params":%20{%20"addonid":%20"script.tv.show.next.aired"},%20"id":%201%$
return
In the .wsgi I have for the live tv app with the HDhomerun.
Code:
# Open watchABC
def alexa_open_watchabc(slots):
print('Opening ABC')
sys.stdout.flush()
kodi.SendADB("com.google.android.tv", "5.1")
answer = "Opening ABC"
return build_alexa_response(answer)
or
Code:
# Open Netflix
def alexa_open_netflix(slots):
print('Opening Netflix')
sys.stdout.flush()
kodi.SendADB("com.netflix.ninja")
answer = "Opening Netflix"
return build_alexa_response(answer)
Of course I didn't include any of the code to setup the mapping of the intents.