m0ngr31 / kanzi

Alexa skill for controlling Kodi
https://lexigr.am
MIT License
427 stars 149 forks source link

TV Show Issues #50

Closed Xtropy74 closed 7 years ago

Xtropy74 commented 7 years ago

Having a few issues with episode playing on a number of shows:

  1. Saying "Alexa, ask Kodi to play the next episode of Making a Murderer (or Strike Back)" does nothing. However, saying "Alexa, ask Kodi to play the next episode of Big Band Theory (or Rome)" works fine. Seems to be random
  2. Saying "Alexa, ask Kodi to play Season 1 Episode 8 of Rome" comes back with "Sorry, something went wrong". Some shows work, most don't (note the play next episode utterance works find for this show)
  3. Saying "Alexa, ask Kodi to play the latest episode of Making a Murderer (or Strike Back)" starts to play my last played music playlist on the Echo? However, saying "Alexa, ask Kodi to play the latest episode of Big Band Theory (or Rome)" works fine. Seems to be random again...
  4. Strangely, if I say "Alexa, ask Kodi are there any new episodes of Making a Murderer (or Strike Back)" I get an immediate reply with the unwatched episode count. Same with "Alexa, ask Kodi to play an episode of Making a Murderer (or Strike Back)" and it plays a random episode every time. So this doesn't seem to be an issue with the name of the show being recognized

Seems to be an issue with the "PlayEpisode" and "PlayNextEpisode" intents. I've tried to test everything I can using 4-5 shows and utterances. As mentioned, some shows are fine, others fail with a spoken "Something went wrong" or nothing happens.

jingai commented 7 years ago

All of these things work for me, but I named my skill "Cody" as I found "Kodi" was sometimes unreliable. You might try that first.

In particular, I think if she can't get an exact match on skill name (because she hears "Cody" when you say "Kodi"), some of her built-in keywords (play, pause, etc) seem to take over.

You can also try replacing "play" in your phrases with "watch" and see if it makes a difference.

If that doesn't help, please post Kodi and server logs during these requests, as well as any relevant Cards from Alexa.

Xtropy74 commented 7 years ago

Yes, I named it Cody as well (typed Kodi for consistency sake). The issue is not with ALL but only some shows and some utterances. Could it be related to changes make in GIT? I updated the code on my Linux box but do I need to run "deploy-to-lambda.py" if using Lambda after each GIT commit? What are the steps needed for updates as they are not in the README?

Also, which specific logs do you want me to post?

jingai commented 7 years ago

I specified the logs I want to see already: Kodi, your web server handling the Skill requests, and relevant Cards that might shed any light on the problem.

Also, please try "watch" instead of "play".

jingai commented 7 years ago

Point 3 of your original post does seem to indicate that Alexa is processing some of your commands herself rather than sending them to the skill.

jingai commented 7 years ago

I have to leave for work now, but one more thought before I go: do you happen to have a home automation device called "Kodi"? I previously had a virtual device called "Kodi" that would intercept some of my commands meant for the skill. Once I renamed it to "Cody" (to match the skill), this problem went away.

jingai commented 7 years ago

I updated the code on my Linux box but do I need to run "deploy-to-lambda.py" if using Lambda after each GIT commit?

Yes. deploy-to-lambda.py is a helper script that copies only the necessary files to a temporary directory and then runs lamba-deploy.

Xtropy74 commented 7 years ago

Yes, I have a "Watch Kodi" for starting the home theater, I'll play with the renaming as you suggested.

Also of note, if I type "Alexa, ask Kodi to play the next episode of Making a Murderer" into the Service Simulator everything works fine so this maybe the issue. I'll test and advise. Thanks

jingai commented 7 years ago

Yeah, it's hard to determine exactly what will intercept commands since the rules seem to be magic and fluid -- my device named "Kodi" didn't used to interfere.

digiltd commented 7 years ago

@Xtropy74 Yes you do have to run python deploy-to-lambda.py when you pull any changes from the master branch to your local machine.

If you haven't already, you should also be looking at your CloudWatch logs.

Open AWS Lambda in your AWS console and click on the function (if using the deploy-to-lambda.py script it will be called kodi-alexa). Click the monitoring tab and you will see a View logs in CloudWatch link above the line charts on the right. They are not instant but only takes a few seconds for things to show up.

Oh, and don't copy and paste the CloudWatch logs here as they will contain sensitive information about your setup.

One other thing, you haven't mentioned if Alexa is correctly hearing your commands. Check these in the Alexa app (Settings, History)

Is your "Watch Kodi" command setup using a Hue Bridge and Harmony? I have a "Mac Mini" activity (as most of the home theatre stuff would be using that as the source). It is triggered with "turn on Mac Mini".

And just to put this out there in case it of interest, my kodi-alexa Skill (this repo) has an invocation name of "kodi". I also have a Hue Bridge device called "cody sound" to control the volume with "alexa, set cody sound to 70 percent" or "alexa, turn cody sound off" (see https://github.com/bwssytems/ha-bridge/issues/193 for more info, questions about it should be raised there) . Both are working without interfering with each other.

jingai commented 7 years ago

@digiltd when I had a device named Kodi and the skill named Cody, most things would work fine. But, some random little things would fail with the 'fail beep' from Alexa. For instance, "Alexa, ask Cody to pause" failed. Also, "Alexa, tell Cody to play" would fail, while "Alexa, ask Cody to play" would work.

In your case, "cody sound" may be different enough from "kodi" for her to make a solid distinction though. I don't know.

digiltd commented 7 years ago

@jingai A big part of it is that Alexa thinks my "cody sound" device is a fake Hue bulb so it is treated as a smart home device rather than a skill with commands like "Alexa, turn on / start / open / run " rather than the required "alexa, ask / tell " command for is used for skills.

For instance, "Alexa, ask Cody to pause" failed. Also, "Alexa, tell Cody to play" would fail, while "Alexa, ask Cody to play" would work.

I expect part of the problem is that "ask" ends with a k sound and "kodi" starts with the same. I have found in my other skills that adding "mr" to the invocation name would help ("ask mr kodi to ...")

jingai commented 7 years ago

@digiltd it works fine with them both named Cody though (ask and tell).

My Cody smarthome device is also a fake Hue bulb, interpreted by Indigo, which then starts the Harmony activity and opens Kodi on my Mac mini for "turn on" and does the reverse for "turn off".

Even though "tell" and "ask" aren't commands for smarthome devices, it appeared to send them to the smarthome device anyway (sometimes) when I had the device named "Kodi" and the skill named "Cody".

What I think is happening is that it's matching the device/skill name before further processing. Sometimes it would match on "Kodi" and others it would match on "Cody". If it matched one of my skill commands to the smarthome device by mistake, it wouldn't fallback to the skill and instead just produce the ba-dum "fail beep".

Xtropy74 commented 7 years ago

Ok, so what I've done:

  1. I renamed the invocation name to "frank". Tried saying "Alexa, ask frank to play the next episode of Making a Murderer" and it starts to play my last played music playlist.
  2. I deleted the entire kodi-alexa function and re-deployed via python deploy-to-lambda.py and added the Alexa Skills Kit. Tested 1. above and same issue
  3. I deleted the kodi-alexa folder on my Linux box and re-pulled from GIT and re-created the .env file. Tested 1. above and same issue
  4. While the music was playing in 1. above, I said the same command again and got the response "I can't skip to the next song on Tune-in live"
  5. I checked the logs on Cloud Watch and none of these requests show up. If I say "Alexa, ask frank to play the next episode of Big Bang Theory", I get the log entry in Cloud Watch.

Note: This issue is not isolated to "Making a Murderer" there are a number of shows with this issue but lots of other ones work fine. Since these are not showing up in Cloud Watch, I am assuming "something" it taking over the command but cannot see any visibility on what is doing that.

Note 2: I also have a askAlexa Lamba function for using the SmartThings platform. It has the same ARN and not sure if that is the cause. I checked the Cloud Watch logs and these requests are not showing up there either.

Really at a loss on this one....

* EDIT *

Here are the logs from my deploy-to-lambda run:

/usr/local/sbin/kodi-alexa$ sudo python deploy-to-lambda.py

2016-10-29 13:59:26:INFO:botocore.credentials: Found credentials in environment variables.
2016-10-29 13:59:26:INFO:lambda_deploy: Packaging lambda kodi-alexa
2016-10-29 13:59:26:WARNING:lambda_deploy: A .env file exists in your Lambda directory - be careful that it does not contain any secrets you don't want uploaded to AWS!
2016-10-29 13:59:26:WARNING:lambda_deploy: Skipping inclusion of of .env file - use LAMBDA_ENV_VARS instead (see documentation for more information)
2016-10-29 13:59:26:INFO:urllib3.connectionpool: Starting new HTTPS connection (1): pypi.python.org
2016-10-29 13:59:29:INFO:distlib.util: Creating /tmp/tmpcTG8Tf/bin
2016-10-29 13:59:29:INFO:distlib.util: changing mode of /tmp/tmpcTG8Tf/bin/gunicorn_paster to 755
2016-10-29 13:59:29:INFO:distlib.util: changing mode of /tmp/tmpcTG8Tf/bin/gunicorn to 755
2016-10-29 13:59:29:INFO:distlib.util: changing mode of /tmp/tmpcTG8Tf/bin/gunicorn_django to 755
2016-10-29 13:59:29:INFO:botocore.vendored.requests.packages.urllib3.connectionpool: Starting new HTTPS connection (1): lambda.us-east-1.amazonaws.com
2016-10-29 13:59:30:INFO:lambda_deploy: Adding new kodi-alexa lambda
2016-10-29 14:00:34:INFO:lambda_deploy: Successfully deployed kodi-alexa version 4
Downloading/unpacking requests (from -r /usr/local/sbin/kodi-alexa/kodi-alexa/requirements.txt (line 1))
Downloading/unpacking gunicorn (from -r /usr/local/sbin/kodi-alexa/kodi-alexa/requirements.txt (line 2))
Downloading/unpacking yaep (from -r /usr/local/sbin/kodi-alexa/kodi-alexa/requirements.txt (line 3))
  Downloading yaep-0.0.6-py2-none-any.whl
Downloading/unpacking pycountry (from -r /usr/local/sbin/kodi-alexa/kodi-alexa/requirements.txt (line 4))
  Running setup.py (path:/tmp/pip_build_root/pycountry/setup.py) egg_info for package pycountry

    warning: no previously-included files matching 'src/pycountry' found anywhere in distribution
    warning: no previously-included files matching '*.pyc' found anywhere in distribution
Installing collected packages: requests, gunicorn, yaep, pycountry
Compiling /tmp/pip_build_root/gunicorn/gunicorn/workers/_gaiohttp.py ...
  File "/tmp/pip_build_root/gunicorn/gunicorn/workers/_gaiohttp.py", line 84
    yield from self.wsgi.close()
             ^
SyntaxError: invalid syntax

  Running setup.py install for pycountry

    warning: no previously-included files matching 'src/pycountry' found anywhere in distribution
    warning: no previously-included files matching '*.pyc' found anywhere in distribution
Successfully installed requests gunicorn yaep pycountry
Cleaning up...
Xtropy74 commented 7 years ago

Finally, just to add another test, I say, "Alexa, ask frank to play the latest episode of Blah Blah" and I get a reply stating "Could not find a show named 'Blah Blah'"

jingai commented 7 years ago
  1. I renamed the invocation name to "frank". Tried saying "Alexa, ask frank to play the next episode of Making a Murderer" and it starts to play my last played music playlist.

To be clear, you mean Alexa plays the last played music playlist, or a music playlist on Kodi? If it's the latter, it means that Alexa did not pass your command to the skill.

  1. While the music was playing in 1. above, I said the same command again and got the response "I can't skip to the next song on Tune-in live"
  2. I checked the logs on Cloud Watch and none of these requests show up. If I say "Alexa, ask frank to play the next episode of Big Bang Theory", I get the log entry in Cloud Watch.

All of this points to the issue being with Alexa or your configuration, rather than the skill itself.

Try these verbatim, please:

Additionally, if at all possible, try dropping all of your smart home devices from Alexa temporarily and re-try the commands (i.e., clicking "Forget all devices").

Xtropy74 commented 7 years ago

To be clear, you mean Alexa plays the last played music playlist, or a music playlist on Kodi? If it's the latter, it means that Alexa did not pass your command to the skill.

Alexa starts playing the last Tune-in radio station I played for some reason, nothing is sent to Kodi

All of this points to the issue being with Alexa or your configuration, rather than the skill itself.

I agree after looking at the Cloud Watch logs, none of what I am asking (that's failing) shows in the logs

Try these verbatim, please:

  • "Alexa, ask frank to watch the next episode of Making a Murderer"

Same issue

  • "Alexa, tell frank to play the next episode of Making a Murderer"

It plays!!!!

  • "Alexa, tell frank to watch the next episode of Making a Murderer"

It plays!!!!

Looks like this a platform issue. I'll disable my smart home devices and test further. Looks like all I need to do to get this working is change the word "ask" to "tell" and everything works perfectly. Very very strange....

jingai commented 7 years ago

Like I said, I had similar issues (ask vs tell, and some commands like Pause consistently not working) with conflicting smart home devices, which is why I wanted you to try those :)

Do report back if dumping your smart home devices makes "ask" work.

Xtropy74 commented 7 years ago

Unfortunately it doesn't work, but now I get an error reported immediately from Alexa. I forgot everything in Smart Home and tried for about 15 minutes. Alexa responds, "I am having difficulties right now, please try again later" and other generic errors (nothing reported in Cloud Watch or cards). Once I add the Smart Home devices back, she wants to skip to the next track when I "ask" using the failed commands posted. I guess I just need to stop being so polite and tell her to do things ;)

jingai commented 7 years ago

IIRC, "I am having difficulties right now, please try again later" means she's unable to contact Amazon's servers. Either way, I'll close this since I don't believe the problem is in the skill itself.