Alexa controlling kodi

i know its not exactly ST related but i found an article on How To Geek website apparently showing the steps to have your Echo (alexa ) control Kodi.
OMG wish i’d never started , a degree in IT required (well that’s what it felt like for me)
I can follow instructions most of the time but this has got the better of me , laptop nearly went for a flying lesson . i would be interested to hear if anyone has got this up and running or can provide instructions in layman’s terms or in the excellent easy to follow style of MichaelS.
have a look see what you think.

I’ve seen a few stories on that and agree they all seemed well above my 30+ year old programming knowledge and the ability to copy/paste somebody else’s hard work.

I got something like this working in node.js, it takes an incoming GET request, extracts the movie title, looks it up in the Kodi library, gets the associated MovieId, then sends the play command. I’ve just recently started teaching myself javascript but this has been working for me. See here if you’re interested:

[code]var express = require(‘express’);
var app = express();
var request = require(‘request’);
const serverPort = 8078;

app.get(’/kodi-lookup’, function (req, res) {
if (!req.query) return res.sendStatus(400)
var movie_title = req.query.movie_title.toLowerCase().replace(‘the ‘,’’);
var kodi_ip = req.query.kodi_ip;
if (movie_title && kodi_ip){
res.send(‘Searching for ’ + movie_title + ’ on ’ + kodi_ip);
console.log(‘Searching for ’ + movie_title + ’ on ’ + kodi_ip);
var options = {
uri: ‘http://’+kodi_ip+’:8080/jsonrpc?request={“jsonrpc”:“2.0”, “method”:“VideoLibrary.GetMovies”, “id”:1}’,
method: ‘GET’,
json: true
request(options, function(error, response, body) {
if (!error && response.statusCode == 200) {
var jsonBody = JSON.stringify(body);

var nameList = jsonBody.split('"label":"');"Found " + nameList.length + " movies in library");

var movieCount = nameList.length;
var i;

for(i = 0; i < movieCount; i++) {
	var endPos = nameList[i].indexOf('"');	
	nameList[i] = nameList[i].substring(0,endPos).toLowerCase().replace('the ','');[i]);

var movieId = nameList.indexOf(movie_title);"Found match, movieId: " + movieId);
play(kodi_ip, movieId);


console.log("Listening on port "+serverPort);

function play (kodi_ip, movieID) {
var options = {
uri: ‘http://’+kodi_ip+’:8080/jsonrpc?request={“jsonrpc”:“2.0”, “method”:“Player.Open”, “id”:1,“params”:{“item”:{“movieid”:’ + movieID + ‘}}}’,
method: ‘GET’,
json: true
request(options, function(error, response, body) {
if (!error && response.statusCode == 200) {
console.log("Sending play command to " + kodi_ip);


As for the trigger, I’m using Google Home -> IFTTT -> SmartThings (CoRE) -> node.js app, where the SmartThings hub is acting as the intermediary between the internet and my local network. You could do this with Alexa too, but without the text variable that’s available in Google Assistant, you’d have to add a separate applet for each title.

The CoRE request looks like this:

HTTP response looks like this:

Searching for minions on

Console response looks like this:

Listening on port 8078
{ movie_title: 'minions', kodi_ip: '' }
Searching for minions on
{"id":1,"jsonrpc":"2.0","result":{"limits":{"end":23,"start":0,"total":23},"movies":[{"label":"Cars","movieid":1},{"label":"Cars 2","movieid":2},{"label":"Despicable Me","movieid":3},{"label":"Despicable Me 2","movieid":4},{"label":"Finding Dory","movieid":5},{"label":"Finding Nemo","movieid":6},{"label":"Inside Out","movieid":7},{"label":"Lady and the Tramp","movieid":8},{"label":"Minions","movieid":9},{"label":"Frozen","movieid":10},{"label":"Planes","movieid":11},{"label":"Storks","movieid":12},{"label":"The Accountant","movieid":13},{"label":"The Girl on the Train","movieid":14},{"label":"The Hunt for Red October","movieid":15},{"label":"The Intervention","movieid":16},{"label":"The Secret Life of Pets","movieid":17},{"label":"Toy Story","movieid":18},{"label":"Toy Story 2","movieid":19},{"label":"Toy Story 3","movieid":20},{"label":"Joy","movieid":21},{"label":"Tangled","movieid":22},{"label":"Big Hero 6","movieid":23}]}}
Found 24 movies in library
cars 2
despicable me
despicable me 2
finding dory
finding nemo
inside out
lady and tramp
girl on the train
hunt for red october
secret life of pets
toy story
toy story 2
toy story 3
big hero 6
Found match, movieId: 9
Sending play command to
{ id: 1, jsonrpc: '2.0', result: 'OK' }

I have another web service running that sends adb commands to my Fire TV to wake it up and launch the Kodi app when my piston fires, and the piston also turns on the “Watch Fire TV” activity, so I can go from my system being dead off to watching a movie from my library with one voice command. I have a 3 year old who likes watching the same movies over and over again and constantly changes her mind about which one she wants to watch, so this is coming in pretty handy :slight_smile:


You sir are legend

Look here :