Kodi Community Forum
Release Kanzi: Amazon Alexa skill for Kodi - Printable Version

+- Kodi Community Forum (https://forum.kodi.tv)
+-- Forum: Support (https://forum.kodi.tv/forumdisplay.php?fid=33)
+--- Forum: Supplementary Tools for Kodi (https://forum.kodi.tv/forumdisplay.php?fid=116)
+--- Thread: Release Kanzi: Amazon Alexa skill for Kodi (/showthread.php?tid=254502)



RE: Amazon Echo skill for Kodi - Dewey72 - 2016-04-28

So I have seen another way that someone does this using AWS servers (Lambda I think is called) versus Heroku. The server is often down and rarely works. So would this only look for what you have locally? Would it look for a media source if you were using Netflix or Quasar on Kodi for example? I don’t keep local files so I would need it to talk to add-ons


RE: Amazon Echo skill for Kodi - fuzzer - 2016-04-30

what does the following indicate?

"I am unable to reach the requested skill"

TIA


RE: Amazon Echo skill for Kodi - m0ngr31 - 2016-05-06

(2016-04-30, 04:22)fuzzer Wrote: what does the following indicate?

"I am unable to reach the requested skill"

TIA

That sounds like it's not able to talk to your Heroku server.

(2016-04-28, 17:10)Dewey72 Wrote: So I have seen another way that someone does this using AWS servers (Lambda I think is called) versus Heroku. The server is often down and rarely works. So would this only look for what you have locally? Would it look for a media source if you were using Netflix or Quasar on Kodi for example? I don’t keep local files so I would need it to talk to add-ons

I don't have Quasar, so I don't know if it would allow library integration. I think if you used Exodus or something you can add things to your library and this would work.


RE: Amazon Echo skill for Kodi - wiphye - 2016-05-07

Just wanted to say thanks for the script.

I was able to get it working locally using apache and mod_wsgi running on a raspberry pi. I was also able to extend it to switch apps on my nvidia shield. I.E. "ask kodi to switch to netflix" etc.. Even launch a few plugins like next aired. "Kodi what's on tv tonight".

I have my shield hooked up with a hdhomerun so saying "kodi switch to CW" and having the live channels app launch and switch to the given network is pretty cool.

I'm currently trying to figure out how to get it handle shows and movies with punctuation better. It seems to hate agents of s.h.i.e.l.d or grey's anatomy.


RE: Amazon Echo skill for Kodi - Rantlers - 2016-05-08

Just wanted to say thank you for sharing this, I've successfully implemented it with two of my htpcs. I honestly thought I'd have to wait at least a couple more years before something like this was available!

Quick question, would it be possible to run this setup without using Heroku (or any cloud based service) and just utilizing equipment you have in-house? (I'm unfortunately not a programmer, so forgive me if I'm missing something completely obvious as to why this wouldn't work)


RE: Amazon Echo skill for Kodi - m0ngr31 - 2016-05-09

(2016-05-07, 22:37)wiphye Wrote: Just wanted to say thanks for the script.

I was able to get it working locally using apache and mod_wsgi running on a raspberry pi. I was also able to extend it to switch apps on my nvidia shield. I.E. "ask kodi to switch to netflix" etc.. Even launch a few plugins like next aired. "Kodi what's on tv tonight".

I have my shield hooked up with a hdhomerun so saying "kodi switch to CW" and having the live channels app launch and switch to the given network is pretty cool.

I'm currently trying to figure out how to get it handle shows and movies with punctuation better. It seems to hate agents of s.h.i.e.l.d or grey's anatomy.

Would you mind sharing that code? It would be cool to have the functionality even if everyone can't use it.

(2016-05-08, 05:06)Rantlers Wrote: Quick question, would it be possible to run this setup without using Heroku (or any cloud based service) and just utilizing equipment you have in-house? (I'm unfortunately not a programmer, so forgive me if I'm missing something completely obvious as to why this wouldn't work)

Yes, you can use a combination of apache + mod_wsgi to handle the requests, but you'll have to generate your own SSL certs.


RE: Amazon Echo skill for Kodi - wiphye - 2016-05-10

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.


RE: Amazon Echo skill for Kodi - edru - 2016-05-10

So I updated to the new Ubuntu build on my private server and it seems to have broke the skill access.I created a brand new Ubuntu instance and set it up all from scratch and receive the same errors.

On a fully stock base setup, here are the errors I receive:

[Mon May 09 19:32:03.643413 2016] [wsgi:error] [pid 5457] [client 10.8.29.1:11330] mod_wsgi (pid=5457): Target WSGI script '/var/www/html/kodi-alexa/wsgi.py' cannot be loaded as Python module.
[Mon May 09 19:32:03.643456 2016] [wsgi:error] [pid 5457] [client 10.8.29.1:11330] mod_wsgi (pid=5457): Exception occurred processing WSGI script '/var/www/html/kodi-alexa/wsgi.py'.
[Mon May 09 19:32:03.643473 2016] [wsgi:error] [pid 5457] [client 10.8.29.1:11330] Traceback (most recent call last):
[Mon May 09 19:32:03.643490 2016] [wsgi:error] [pid 5457] [client 10.8.29.1:11330] File "/var/www/html/kodi-alexa/wsgi.py", line 40, in <module>
[Mon May 09 19:32:03.643605 2016] [wsgi:error] [pid 5457] [client 10.8.29.1:11330] import kodi
[Mon May 09 19:32:03.643615 2016] [wsgi:error] [pid 5457] [client 10.8.29.1:11330] File "/var/www/html/kodi-alexa/kodi.py", line 31, in <module>
[Mon May 09 19:32:03.643688 2016] [wsgi:error] [pid 5457] [client 10.8.29.1:11330] import requests
[Mon May 09 19:32:03.643703 2016] [wsgi:error] [pid 5457] [client 10.8.29.1:11330] ImportError: No module named requests



I dont know if I'm missing any pre-req's at all.

EDIT: FIXED - had to install python setup tools and then PIP and then install the register python module.


RE: Amazon Echo skill for Kodi - zpanderson - 2016-05-12

Just curious if you have any ETA on if/when this would be certified?

It looks pretty cool and I've just got my echo so I haven't got to play around with the skills much.

Edit:

Got this set up finally. As a note if anyone is trying to set this up on your home server you have to use port 443 as that is all Alexa skills allow. I first tried to use a custom port and was banging my head on the wall trying to figure out why I was getting unreachable errors.


RE: Amazon Echo skill for Kodi - fbrea - 2016-05-22

Quote:Quick question, would it be possible to run this setup without using Heroku (or any cloud based service) and just utilizing equipment you have in-house? (I'm unfortunately not a programmer, so forgive me if I'm missing something completely obvious as to why this wouldn't work)
Quote:Yes, you can use a combination of apache + mod_wsgi to handle the requests, but you'll have to generate your own SSL certs.

Has anyone been able to run this in a Synology NAS? Can somebody give me some ideas.

TIA


RE: Amazon Echo skill for Kodi - shaunnadan - 2016-06-04

hi

ive managed to get this to partially work and was wondering if i could get some assistance.

i currently can play, pause and navigate the menus

i have about a 5% chance of it playing a specific movie title

it refuses to play any series

? is there anything specific about my library i should have setup.? i have set the source content as movies or TV shows and im using local metadata i have grabbed previously using (media companion)

? how do i navigate in a menu down 3 places for example, or to folders starting with the letter "s"


RE: Amazon Echo skill for Kodi - _Andy_ - 2016-06-16

Maybe an idea to convert to alexa-app and alexa-server-app with node.js. Very easy to setup and stable.
I could install the complete server within 10 minutes and works without an issue. SSL setup is easy. Just some config lines and the server and some test apps are working.


RE: Amazon Echo skill for Kodi - m0ngr31 - 2016-06-21

(2016-06-04, 13:52)shaunnadan Wrote: hi

ive managed to get this to partially work and was wondering if i could get some assistance.

i currently can play, pause and navigate the menus

i have about a 5% chance of it playing a specific movie title

it refuses to play any series

? is there anything specific about my library i should have setup.? i have set the source content as movies or TV shows and im using local metadata i have grabbed previously using (media companion)

? how do i navigate in a menu down 3 places for example, or to folders starting with the letter "s"
Did you run your library through this? https://sleepy-wave-26412.herokuapp.com/

Have you tried running the speech recognizer from the Alexa app?

(2016-06-16, 22:38)_Andy_ Wrote: Maybe an idea to convert to alexa-app and alexa-server-app with node.js. Very easy to setup and stable.
I could install the complete server within 10 minutes and works without an issue. SSL setup is easy. Just some config lines and the server and some test apps are working.

I'm sorry, but I don't have plans to re-write the entire thing in node.js


RE: Amazon Echo skill for Kodi - Dominique - 2016-07-05

I am crazy frustrated.

I wish someone would make a video tutorial with a step-by-step.

I am a visual person, I have tried following the directions with no luck. I would assume I am not the first.

Still, all the work put into this is very much appreciated.


RE: Amazon Echo skill for Kodi - SkyBehind - 2016-07-05

(2016-04-17, 23:05)mwgray81 Wrote: If anyone is interested, I modified the code slightly to run on Amazon Web Services as a Lamda function. No additional features just another option for servers.

Here's a tutorial of how to setup a lamda function
https://developer.amazon.com/public/solutions/alexa/alexa-skills-kit/docs/developing-an-alexa-skill-as-a-lambda-function

Select the "alexa-skills-kit-color-expert-python" template

Download the code from https://github.com/mwgray81/kodi-alexa
You'll have to edit the kodi.py send command function to use you kodi ip address, username, and password as I don't know how to use environment variables on AWS.
Zip the entire directory and upload it to the code tab. On the "Configuration" tab enter "wsgi.lambda_handler" into the Handler field. Under the Advanced settings change timeout from 3 seconds to 30 seconds.

You create the Alexa skill the same way as before with one exception, you will use the "Lambda ARN (Amazon Resource Name)" instead of the https. You get this value from the Lamda function page on you AWS console. Select the radio button next to the function you wish to use and click the "Actions" button then "Show ARN"

I haven't tested it extensively, but it seems to work.

I did make one small modification on the GetMovies function. I added a filter to only return titles that contained the heard word.

Thanks m0ngr31 for creating this awesome skill.


For the Lambda Server, I get "errorMessage": "Handler 'lambda_handler' missing on module 'wsgi'" as a response. I looked at the wsgi.py file and saw lambda_handler code, did you have any issues with the wsgi.py file?