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 - jacobh - 2016-11-10

(2016-11-10, 23:29)jingai Wrote: Two things then:

1) Do you have KODI_SCHEME and KODI_SUBPATH defined in your .env file? Even if they're empty -- I just want to know if they're uncommented.

2) If you can put those print statements below the os.getenv() calls it will probably tell me what I need to know. I can get a pre-modified copy of kodi.py to you if you need me to.

1) They're commented still.
2) I was trying to do some step-through debugging locally, but that's a good idea. I don't have time right now, but hopefully I'll have some time tonight.


RE: Amazon Echo skill for Kodi - jacobh - 2016-11-11

After adding in the print statements, it prints out 'None' for both.

If I uncomment those two variables in the .env file everything works:
Code:
KODI_SCHEME =

# If using a reverse proxy you might need to add an extra bit to the url before "jsonrpc"
# You can do this with KODI_SUBPATH (don't use slashes before or after)
#
KODI_SUBPATH =

I tried commenting back out the variables and changing the environment variable lookup to this:
Code:
SCHEME = os.getenv('KODI_SCHEME','http')
But this didn't work either. SCHEME printed out a value None.

For some reason when these variables are commented out in the .env file it still won't use the default value or pass the "if not SCHEME" check.


RE: Amazon Echo skill for Kodi - digiltd - 2016-11-11

I have a working https and subpath setup using AWS and thought I would test this also

My current working .env file (to show how i enter the variables) is this:

Code:
# The Kodi webserver only supports HTTP.
#
# You can change KODI_SCHEME to https to tell the skill to use https (from AWS to your local network)
# It is assumed that you know what https is and that you have already set this up with your own certificates

KODI_SCHEME = https
KODI_ADDRESS = supersecret.evenmoresecret.com
KODI_PORT = 34242
KODI_USERNAME = supersecretusername
KODI_PASSWORD = supersecretandsuperlongpassword

# If using a reverse proxy you might need to add an extra bit to the url before "jsonrpc"
#
#     KODI_SCHEME://KODI_ADDRESS:KODI_PORT/KODI_SUBPATH/jsonrpc
#
# Set this with KODI_SUBPATH (no slashes)

KODI_SUBPATH = supersecretsubpath

SKILL_APPID = amzn1.ask.skill.123123123123123212123312312321

LAMBDA_ENV_VARS = KODI_SCHEME,KODI_ADDRESS,KODI_PORT,KODI_SUBPATH,KODI_USERNAME,KODI_PASSWORD,SKILL_APPID

AWS_DEFAULT_REGION = eu-west-1
LAMBDA_TIMEOUT = 60
LAMBDA_MEMORY_SIZE = 128
LAMBDA_HANDLER = wsgi.lambda_handler

AWS_ACCESS_KEY_ID = ABDHSDGDHSKDHSALHFDSHFDJSHFJDLKS
AWS_SECRET_ACCESS_KEY = ASDASDASDASDASDASDASDASDASDASDASD
LAMBDA_ROLE = arn:aws:iam::123123123123:role/lambda_kodi_basic_execution

RESULT
Code:
Sending request to https://supersecret.evenmoresecret.com:34242/supersecretsubpath/jsonrpc


TEST 1 : Comment out KODI_SCHEME and KODI_SUBPATH

Code:
# The Kodi webserver only supports HTTP.
#
# You can change KODI_SCHEME to https to tell the skill to use https (from AWS to your local network)
# It is assumed that you know what https is and that you have already set this up with your own certificates

# KODI_SCHEME = https
KODI_ADDRESS = supersecret.evenmoresecret.com
KODI_PORT = 34242
KODI_USERNAME = supersecretusername
KODI_PASSWORD = supersecretandsuperlongpassword

# If using a reverse proxy you might need to add an extra bit to the url before "jsonrpc"
#
#     KODI_SCHEME://KODI_ADDRESS:KODI_PORT/KODI_SUBPATH/jsonrpc
#
# Set this with KODI_SUBPATH (no slashes)

# KODI_SUBPATH = supersecretsubpath

SKILL_APPID = amzn1.ask.skill.123123123123123212123312312321

LAMBDA_ENV_VARS = KODI_SCHEME,KODI_ADDRESS,KODI_PORT,KODI_SUBPATH,KODI_USERNAME,KODI_PASSWORD,SKILL_APPID

AWS_DEFAULT_REGION = eu-west-1
LAMBDA_TIMEOUT = 60
LAMBDA_MEMORY_SIZE = 128
LAMBDA_HANDLER = wsgi.lambda_handler

AWS_ACCESS_KEY_ID = ABDHSDGDHSKDHSALHFDSHFDJSHFJDLKS
AWS_SECRET_ACCESS_KEY = ASDASDASDASDASDASDASDASDASDASDASD
LAMBDA_ROLE = arn:aws:iam::123123123123:role/lambda_kodi_basic_execution


RESULT
Code:
Sending request to http://None:/supersecret.evenmoresecret.com:34242/None/jsonrpc

TEST 2 : Uncommented KODI_SCHEME and KODI_SUBPATH but leave KODI_SUBPATH empty

Code:
# The Kodi webserver only supports HTTP.
#
# You can change KODI_SCHEME to https to tell the skill to use https (from AWS to your local network)
# It is assumed that you know what https is and that you have already set this up with your own certificates

KODI_SCHEME = http
KODI_ADDRESS = supersecret.evenmoresecret.com
KODI_PORT = 34242
KODI_USERNAME = supersecretusername
KODI_PASSWORD = supersecretandsuperlongpassword

# If using a reverse proxy you might need to add an extra bit to the url before "jsonrpc"
#
#     KODI_SCHEME://KODI_ADDRESS:KODI_PORT/KODI_SUBPATH/jsonrpc
#
# Set this with KODI_SUBPATH (no slashes)

KODI_SUBPATH =

SKILL_APPID = amzn1.ask.skill.123123123123123212123312312321

LAMBDA_ENV_VARS = KODI_SCHEME,KODI_ADDRESS,KODI_PORT,KODI_SUBPATH,KODI_USERNAME,KODI_PASSWORD,SKILL_APPID

AWS_DEFAULT_REGION = eu-west-1
LAMBDA_TIMEOUT = 60
LAMBDA_MEMORY_SIZE = 128
LAMBDA_HANDLER = wsgi.lambda_handler

AWS_ACCESS_KEY_ID = ABDHSDGDHSKDHSALHFDSHFDJSHFJDLKS
AWS_SECRET_ACCESS_KEY = ASDASDASDASDASDASDASDASDASDASDASD
LAMBDA_ROLE = arn:aws:iam::123123123123:role/lambda_kodi_basic_execution

RESULT
Code:
Sending request to http://supersecret.evenmoresecret.com:34242/jsonrpc

Which I will assume would have worked fine if I had everything set up to receive.

A long post I know, but it's clearer to see the whole thing.

Hope it helps


RE: Amazon Echo skill for Kodi - Stuckinohio85 - 2016-11-11

I'm gonna start with saying all you guys are doing amazing with everything. I've been following and learning as I go with kodi for a couple years now and this part is very unique and interesting for me. This is my first post with kodi and I'm looking forward to learning more and hopefully helping out soon as well. Awesome Job so far looks great!


RE: Amazon Echo skill for Kodi - jingai - 2016-11-11

Ok, so this is a bit weird, and shouldn't be difficult.. lol

On my Debian box with Python 2.7.12, I ran the following code:

Code:
#!/bin/python

import os

SCHEME = os.getenv('KODI_SCHEME')
print "SCHEME is %s" % (SCHEME)
print type(SCHEME)

if not SCHEME:
  print "not SCHEME"
elif SCHEME is None:
  print "SCHEME is None"
else:
  print "SCHEME is '%s'" % (SCHEME)

and got this output:

Code:
SCHEME is None
<type 'NoneType'>
not SCHEME

KODI_SCHEME is not set in my environment. So, it works as it should.

The only thing I can think of is that os.getenv('FOO') is returning a string with the value of 'None' under AWS Lambda's execution environment with the environment variable not set. Perhaps it's a side-effect of how they set the environment variables in the container from the list specified by LAMBDA_ENV_VARS.

@jonjon, could you test this for me by commenting out KODI_SCHEME in your .env and adding a couple print statements under the os.getenv() call, like so:

Code:
# These two methods construct the JSON-RPC message and send it to the Kodi player
def SendCommand(command):
  # Do not use below for your own settings, use the .env file
  SCHEME = os.getenv('KODI_SCHEME')
  print type(SCHEME)
  print "SCHEME is %s" % (SCHEME)
  if not SCHEME:
    SCHEME = 'http'



RE: Amazon Echo skill for Kodi - jacobh - 2016-11-11

(2016-11-11, 08:05)jonjon Wrote: A long post I know, but it's clearer to see the whole thing.

Hope it helps

This is exactly what I'm seeing as well.

If the variables are commented out, the environment lookup returns None. The code that checks for that and replaces it with a default value isn't working (and neither was using a default value in the getenv call). So there seems to be something strange about how os.getenv returns when the environment variable doesn't exist at all (vs. it existing and being empty).

Maybe this is specific to the python interpreter being used by AWS Lambda?


RE: Amazon Echo skill for Kodi - digiltd - 2016-11-11

(2016-11-11, 14:39)jingai Wrote: Ok, so this is a bit weird, and shouldn't be difficult.. lol

On my Debian box with Python 2.7.12, I ran the following code:

Code:
#!/bin/python

import os

SCHEME = os.getenv('KODI_SCHEME')
print "SCHEME is %s" % (SCHEME)
print type(SCHEME)

if not SCHEME:
  print "not SCHEME"
elif SCHEME is None:
  print "SCHEME is None"
else:
  print "SCHEME is '%s'" % (SCHEME)

and got this output:

Code:
SCHEME is None
<type 'NoneType'>
not SCHEME

KODI_SCHEME is not set in my environment. So, it works as it should.

The only thing I can think of is that os.getenv('FOO') is returning a string with the value of 'None' under AWS Lambda's execution environment with the environment variable not set. Perhaps it's a side-effect of how they set the environment variables in the container from the list specified by LAMBDA_ENV_VARS.

@jonjon, could you test this for me by commenting out KODI_SCHEME in your .env and adding a couple print statements under the os.getenv() call, like so:

Code:
# These two methods construct the JSON-RPC message and send it to the Kodi player
def SendCommand(command):
  # Do not use below for your own settings, use the .env file
  SCHEME = os.getenv('KODI_SCHEME')
  print type(SCHEME)
  print "SCHEME is %s" % (SCHEME)
  if not SCHEME:
    SCHEME = 'http'


Done

Code:
<type 'str'>

SCHEME is None

Sending request to http://None:/supersecret.evenmoresecret.com:34242/None/jsonrpc



RE: Amazon Echo skill for Kodi - jacobh - 2016-11-11

Looks like Jingai is right about the value being returned as a string.


RE: Amazon Echo skill for Kodi - MaKin - 2016-11-12

Hi,

I'd really like to test your Skill but somehow when triggering Lambda the request is not submitted correctly due to a false URL parsing. Here is the log:

Code:
START RequestId: id Version: $LATEST
lambda_handler: applicationId=app_id
Verifying application ID...
on_session_started: requestId=reqId, sessionId=SessionId.xy
on_intent: requestId=reqId, sessionId=SessionId.xy
Requested intent: CurrentPlayItemInquiry
Currently playing item
Sending request to http://None:/http:/myDomainName.org:8888/None/jsonrpc
END RequestId: xyz
REPORT RequestId: xyz    Duration: 32.99 ms    Billed Duration: 100 ms     Memory Size: 128 MB    Max Memory Used: 11 MB

As you can see: http://None:/http:/myDomainName.org:8888/None/jsonrpc is obviously wrong.

My .env-section looks like this:

Code:
KODI_ADDRESS = http://domain.duckdns.org
KODI_PORT = 8888
KODI_USERNAME = user
KODI_PASSWORD = pw



RE: Amazon Echo skill for Kodi - jingai - 2016-11-12

I will fix this soon if no one else gets to it. But I'm on holiday this weekend.


RE: Amazon Echo skill for Kodi - nawo69 - 2016-11-12




RE: Amazon Echo skill for Kodi - stuCONNERS - 2016-11-13

(2016-11-12, 20:27)nawo69 Wrote:
(2016-11-12, 16:27)MaKin Wrote: Hi,

I'd really like to test your Skill but somehow when triggering Lambda the request is not submitted correctly due to a false URL parsing. Here is the log:

Code:
START RequestId: id Version: $LATEST
lambda_handler: applicationId=app_id
Verifying application ID...
on_session_started: requestId=reqId, sessionId=SessionId.xy
on_intent: requestId=reqId, sessionId=SessionId.xy
Requested intent: CurrentPlayItemInquiry
Currently playing item
Sending request to http://None:/http:/myDomainName.org:8888/None/jsonrpc
END RequestId: xyz
REPORT RequestId: xyz    Duration: 32.99 ms    Billed Duration: 100 ms     Memory Size: 128 MB    Max Memory Used: 11 MB

As you can see: http://None:/http:/myDomainName.org:8888/None/jsonrpc is obviously wrong.

My .env-section looks like this:

Code:
KODI_ADDRESS = http://domain.duckdns.org
KODI_PORT = 8888
KODI_USERNAME = user
KODI_PASSWORD = pw

Try changing the LAMBDA_ENV_VARS line in .env�

From

LAMBDA_ENV_VARS = KODI_SCHEME,KODI_ADDRESS,KODI_PORT,KODI_SUBPATH,KODI_USERNAME,KODI_PASSWORD,SKILL_APPID�

To

LAMBDA_ENV_VARS = KODI_ADDRESS,KODI_PORT,KODI_USERNAME,KODI_PASSWORD,SKILL_APPID�

Sent from my SHIELD Tablet K1 (typie typie)

Worked a treat for me, not bad timing


RE: Amazon Echo skill for Kodi - digiltd - 2016-11-13

(2016-11-12, 16:27)MaKin Wrote: Hi,

I'd really like to test your Skill but somehow when triggering Lambda the request is not submitted correctly due to a false URL parsing. Here is the log:

As you can see: http://None:/http:/myDomainName.org:8888/None/jsonrpc is obviously wrong.

My .env-section looks like this:

Code:
KODI_ADDRESS = http://domain.duckdns.org
KODI_PORT = 8888
KODI_USERNAME = user
KODI_PASSWORD = pw

For reference the KODI_ADDRESS should not contain the scheme (http://)

Code:
KODI_ADDRESS = domain.duckdns.org
KODI_PORT = 8888
KODI_USERNAME = user
KODI_PASSWORD = pw

Though I would stick with your working version at the moment till the None issue can be pinned down and fixed.


RE: Amazon Echo skill for Kodi - Dominique - 2016-11-14

I am sorry if someone already asked this... (this thread is kind of overwhelming)

When testing I get this error....

Quote:The remote endpoint could not be called, or the response it returned was invalid.

Can someone assist me?

Thanks.

EDIT: Here is what I am looking at. Is this correct?

Image


RE: Amazon Echo skill for Kodi - jingai - 2016-11-14

@Dominique, is the endpoint actually accessible?