Message:Coronavirus (COVID-19)

Blog

How to Control Your Kodi Media Center with an Amazon Echo

April 26th, 2016 by Mark Daly in Industry News No Comments »
How to Control Your Kodi Media Center with an Amazon Echo ilicomm Technology Solutions

Remote controls are so 1950. If you have a Kodi media center and an Amazon Echo, you can play all your favorite movies and shows with a well-placed voice command…if you’re willing to do a little setup.

The Amazon Echo is, in our opinion, one of the coolest parts of a smart home. Controlling your lights, blinds, and TV with your phone is cool, but controlling them with your voice is truly the future. I was skeptical, but quickly became impressed–and hungry for more.

Being able to turn my TV on is cool, but what I really wanted was to be able to control my media center. I wanted to be able to say “Play the next episode of Friends” and have it search my library, see what I watched last, and start playing the subsequent episode. And after a bit of searching, I found that one enterprising programmer named Joe Ipson had already done just that.

This takes a little bit of setup, and it looks very intimidating at first. You’ll need to create a web server, push some code from GitHub, and do a little work from the command line, but you don’t need to be a programmer to get this up and running. Ipson has done almost all the heavy lifting, and you just need to copy his code, edit a few parts, and upload it to the right place. If you follow this guide to the letter, you should be up and running in no time.

Step One: Prepare Your Kodi Web Server

In order for this to work, Kodi will need to have a server accessible from the web. Thankfully, this is built into Kodi, though you may need to forward some ports on your router and perform some other tasks before it works smoothly.

Open Kodi on your media center and head to System > Services > Web Server. Enable the web server if it isn’t enabled already, and give it a username and password. Be sure to use a password you don’t use for any other service.

How to Control Your Kodi Media Center with an Amazon Echo ilicomm Technology Solutions

You will also need the public IP address for your home. However, since this can change, we highly recommend signing up for a dynamic domain name using a service like Dynu. Follow our guide here before continuing if you don’t already have one.

How to Control Your Kodi Media Center with an Amazon Echo ilicomm Technology Solutions

Lastly, you’ll need to set up port forwarding for your Kodi box. This will differ from router to router, but you can check out our guide here for more information. Just forward any external port to the local IP address of your Kodi box (in my case, 192.168.1.12) and local port (8080 by default).

NOTE: while Kodi’s local port is 8080 by default, you can change it to whatever you want–or you can forward it to a different external port to make sure there are no complications (since other apps may ask for port 8080). I’m using 8080 in this tutorial, but if you use something different, just replace all instances of port 8080 with the external port you choose here.

How to Control Your Kodi Media Center with an Amazon Echo ilicomm Technology Solutions

If all goes well, you should be able to access Kodi’s web interface by opening a web browser and typing in:

my.dynamic-domain.com:8080

where my.dynamic-domain.com is the URL of your dynamic domain, and 8080 is the port you set in Kodi. If that doesn’t work, make sure that Kodi, your dynamic domain, and your port forwarding were all set up properly.

Step Two: Set Up Heroku

Next, you’ll need to sign up for an account at Heroku, a free platform for creating cloud-based apps. We’ll use this to create a web server that connects our Echo with our Kodi media center.

Head to Heroku’s home page and click the “Sign Up” button in the upper right-hand corner. Type in your name and email. For your primary development language, feel free to choose “I’m not a developer”.

How to Control Your Kodi Media Center with an Amazon Echo ilicomm Technology Solutions

Next, download and install the Heroku Toolbelt on your computer from this page. This process should work on Windows, OS X, and Linux, though we’ll be using Windows for our example. Choose the “Full Installation”.

How to Control Your Kodi Media Center with an Amazon Echo ilicomm Technology Solutions

After installing, press Windows+X on your keyboard and choose “Command Prompt”. (Mac and Linux users will want to open their respective Terminal apps). Then, run the following command:

heroku --version

This should either return a version of Heroku, or finish the Heroku Toolbelt installation process.

How to Control Your Kodi Media Center with an Amazon Echo ilicomm Technology Solutions

If everything looks good, run the next command to log into Heroku from the command line:

heroku login

Type in the email address you used to create your Heroku account and press Enter. Then, type your Heroku password, and press Enter. It will return a successful login message if all goes well.

How to Control Your Kodi Media Center with an Amazon Echo ilicomm Technology Solutions

Step Three: Upload Your Code

Next, we’re going to create a new app within Heroku. Run the following command:

heroku create

Heroku will create a new app project for you with a random generic name. (You could give it your own name, but you can’t use a name anyone else has used before–so I just use the random one it gives me). It will give you two URLs containing this name. Write them down now; you’ll need them later.

How to Control Your Kodi Media Center with an Amazon Echo ilicomm Technology Solutions

Next, create a new folder on your computer where you’ll store the code for this project. I put mine in my Documents folder, and called it “Code”–so I know exactly where all my little projects like this go.

Once you’ve done that, CD into that folder with this command, replacing the folder path with your own:

CD C:\Users\Whitson\Documents\Code\

Then, run:

git clone https://github.com/m0ngr31/kodi-alexa.git

This will clone all of Ipson’s code for this project into a new folder called kodi-alexa.

How to Control Your Kodi Media Center with an Amazon Echo ilicomm Technology Solutions

Next, CD into that kodi-alexa folder with:

CD kodi-alexa

Then run the following command to add your Kodi IP address (or dynamic domain), Kodi webserver port, Kodi webserver username, and Kodi webserver password:

heroku config:set KODI_ADDRESS='my.dynamic-address.com' KODI_PORT='8080' KODI_USERNAME='kodi' KODI_PASSWORD='mysuperlongpassword' --app random-name-88888

Obviously, replace the address, port, username, and password, and random app name with the ones you set up in Kodi back in step one.

How to Control Your Kodi Media Center with an Amazon Echo ilicomm Technology Solutions

Lastly, run the following commands, pressing Enter after each one:

git remote add heroku https://git.heroku.com/random-name-88888.git

(…replacing random-name-88888 with the name of your project.)

git push heroku master
heroku ps:scale web=1 --app random-name-88888

Git will go through the process of uploading your code to Heroku and starting the app. After you enter the final command, you’ll see a brief output like “Scaling dynos… done” as confirmation.

When everything is finished, your app is in place on your web server–you just need to point your Echo to it.

How to Control Your Kodi Media Center with an Amazon Echo ilicomm Technology Solutions

Step Four: Create Your Amazon “App”

To connect Ipson’s code with our Echo, we’ll need to create an “app” for Alexa. This app won’t be distributed to anyone, it’ll just be in “testing mode” forever, connected to your own Amazon account for use with your Echo.

To start, set up a free Amazon Developer account. Head to this page, log in with your Amazon account, and register for a developer account. Fill in the required fields, agree to the terms, and say “No” when you’re asked if you’re going to monetize your apps.

How to Control Your Kodi Media Center with an Amazon Echo ilicomm Technology Solutions

Once logged in, head to “Apps & Services” in the top toolbar, then select “Alexa” from the sub-toolbar. Click the “Get Started” button under “Alexa Skills Kit”.

How to Control Your Kodi Media Center with an Amazon Echo ilicomm Technology Solutions

Next, click the “Add a New Skill” button.

How to Control Your Kodi Media Center with an Amazon Echo ilicomm Technology Solutions

Give your skill a name–I called mine “Kodi”–and give it an invocation name. This is what you’ll say when you want to invoke a command. For example, my invocation name is also “the living room”, which means I’ll have to say “Ask the living room to…” to give Alexa commands for my media center.

In my experience, long invocation names work better than shorter ones. I used “Kodi” for awhile (“Ask Kodi to…”) but Alexa occasionally had trouble finding movies. I couldn’t tell you why, but longer invocation names like “the living room” work almost flawlessly for me. So try choosing something with a few syllables.

Click Next when finished.

How to Control Your Kodi Media Center with an Amazon Echo ilicomm Technology Solutions

Click “Add Slot Type” button in the middle of the next window.

How to Control Your Kodi Media Center with an Amazon Echo ilicomm Technology Solutions

Create a new slot called SHOWS , and list some of your TV shows in the box, one per line–I have about 20-30 shows in mine. You don’t need to add every show in your Kodi library, but it’s good to have a decent number of examples. This will help Alexa recognize the shows you dictate to it. Click OK when finished.

How to Control Your Kodi Media Center with an Amazon Echo ilicomm Technology Solutions

Repeat this process with two more Slot Types: MOVIES and MUSIC . (If you don’t have a music library, create the slot type anyway–Ipson’s code requires it–and just stick a few random artist names in there. It won’t cause any problems.)

How to Control Your Kodi Media Center with an Amazon Echo ilicomm Technology Solutions

NOTE: If you find that 20-30 random items isn’t enough for Alexa to recognize your commands, try this slot generator, also from Joe Ipson. It’ll scan your library and create a list of every movie, show, and artist on your Kodi box, to ensure Alexa gets it right every time. If you’d prefer not to enter your information into something hosted on his server, you can always clone the Github code yourself and create your own version on Heroku, just like we did in Step Three above.

When you’ve created all three Slot Types, head back to the folder you extracted from GitHub on your PC. Find the alexa.intents and alexa.utterances files. Open them both with an app likeNotepad++.

How to Control Your Kodi Media Center with an Amazon Echo ilicomm Technology Solutions

Select all the text in the alexa.intents file and paste it into the “Intent Schema” box on the Amazon Developer website. Repeat this process with the alexa.utterances file, placing the text in the “Sample Utterances” box.

When you’re done, click Next.

How to Control Your Kodi Media Center with an Amazon Echo ilicomm Technology Solutions

On the next page, choose “HTTPS” for the “Endpoint” box and paste in the Heroku URL for your app that you wrote down at the beginning of step two ( https://random-name-88888.herokuapp.com/ ). Choose “No” for Account Linking and click Next.

How to Control Your Kodi Media Center with an Amazon Echo ilicomm Technology Solutions

On the next page, select “My development endpoint is a subdomain of a domain that has a wildcard certificate from a certificate authority”. Click Next.

How to Control Your Kodi Media Center with an Amazon Echo ilicomm Technology Solutions

You shouldn’t need to add any information on the Test page, though you can test certain aspects of the code if you know what you’re doing. Otherwise, click Next.

On the Publishing Information page, fill out the required fields–but don’t worry too much about what you put in, since you won’t be submitting this app for certification. You’re the only one who will be using this app. (Here is a 108×108 icon and a 512×512 icon for you to use.) Click Next when finished.

How to Control Your Kodi Media Center with an Amazon Echo ilicomm Technology Solutions

On the final page, choose “No” for both privacy questions and check the Complicance box. Click the “Save” button when you’re finished. Do NOT click the “Submit for Certification” button.

How to Control Your Kodi Media Center with an Amazon Echo ilicomm Technology Solutions

Step Five: Test Your New Commands

If all went well, you should be able to test your new commands now. Make sure your Kodi box is turned on, and try saying something like:

“Alexa, ask the living room to play season one, episode one of Friends”

(…obviously replacing that with an episode and show that you have on your machine.) It may take Alexa a moment, but hopefully she should respond and start playing the show in question. If you get an error and the episode doesn’t play, go back and make sure you did everything properly.

NOTE: Due to the limitations of Heroku’s free tier, Alexa may sometimes give you an error that says “The requested skill took too long to respond”, even though the episode starts playing anyway. In my case, this only happened on my Raspberry Pi, or sometimes when my Heroku app was sleeping. Your mileage may vary, but in all our tests, this was either a minor issue or a non-issue entirely.

You can ask Alexa if you have any new episodes, ask her to play the next episode of a show, or even use her to control Kodi, as inefficient as it may be (“Alexa, ask the living room to pause,” “Alexa, ask the living room to navigate down,” etc.). Check out the alexa.utterances file to see all the things Alexa can do with this integration. If you ever want to add a new phrase that corresponds to one of those functions, just log back onto your Amazon Developer account and add it to the list we pasted in step four.

If you have multiple Kodi boxes, you can do this for each of them–you just need to create a new app on both Heroku and Amazon for each (and give each a different invocation name). For example, I have a second app controlling the Raspberry Pi in my bedroom that lets me “ask the bedroom” to play new shows.


This isn’t flawless, and it wasn’t without its growing pains when I first set it up. But once you get it working, it’s easily one of the coolest things you can do with your Amazon Echo, at least in my opinion. Now I can start watching TV while cooking in the kitchen, or when my remote’s batteries are dead. This is the kind of power Amazon Echo was designed to have, and even though it takes a bit of work, it’s well worth it.

Leave a Reply

You must be logged in to post a comment.

NEED MORE INFORMATION?Contact us to see how we can help your business

Call our Sales Team on:

+44 (0)121 289 3434

or email us at:

hello@ilicomm.com