This is an old revision of the document!
Kodi & Alexa
https://forum.kodi.tv/showthread.php?tid=254502
https://lexigr.am/docs/getting-started.html
1.) An Amazon developer profile is required for custom Alexa skills. Log in with normal amazon account on this page and create a developer account: https://developer.amazon.com/
2.) NodeJS framework v8.11.1 is required. Do not use default ubuntu package of NodeJS as this is is an older version. Installation using NVM https://github.com/nvm-sh/nvm#installation-and-update
wget -qO- https://raw.githubusercontent.com/nvm-sh/nvm/v0.34.0/install.sh | bash
close and reopen terminal after installation
3.) Install NodeJS 8.11.1
nvm install 8.11.1 nvm use 8.11.1
4.) Install lexigram-cli
npm install -g lexigram-cli
5.) Use the cli to log in to Amazon and initialise the Alexa skill (Kanzi)
lexigram login --no-browser true # select default profile and confirm with yes to enter Amazon credentials # copy url into browser, grant access and paste the resulting Auth key back into terminal
6.) Download an empty config file
lexigram init-config
7.) Initialise the skill kanzi
lexigram init-skill kanzi
8.) Kodi setup
Go to settings โ system โ Services โ Web server and allow remote control
- via http
- from applications on this system
- from applications on other systems
Supply username/password
9.) A reverse caching proxy may be useful to cache search results. This is primarily useful for external access and not for local access, however, even local access may benefit from this.
10.) Adjust configuration file kodi.config with backend/proxy details, local timezone and as required.
vi kodi.config
shutdown = 'quit' timezone = Europe/London
11.) Set up webserver as target for the alexa command
sudo apt-get install apache2 libapache2-mod-wsgi sudo a2enmod ssl sudo systemctl restart apache2 sudo mkdir /etc/apache2/ssl sudo openssl genrsa -out /etc/apache2/ssl/apache.key 2048 sudo cat > ssl-key-conf.cnf << EOF [req] distinguished_name = req_distinguished_name x509_extensions = v3_req prompt = no [req_distinguished_name] C = GB ST = . L = . O = wuff CN = kodi-alexa [v3_req] keyUsage = keyEncipherment, dataEncipherment extendedKeyUsage = serverAuth subjectAltName = @subject_alternate_names [subject_alternate_names] DNS.1 = wuff.dyndns.org EOF openssl req -new -x509 -days 365 -key /etc/apache2/ssl/apache.key -config ssl-key-conf.cnf -out /etc/apache2/ssl/apache.crt sudo vi /etc/apache2/apache.conf # set ServerName example.dyndns.org sudo vi /etc/apache2/sites-available/default-ssl.conf # set DocumentRoot /var/www/html # set SSLCertificateFile /etc/apache2/ssl/apache.crt # set SSLCertificateKeyFile /etc/apache2/ssl/apache.key # add WSGIScriptAlias /kodi-alexa /var/www/kodi-alexa/alexa.wsgi sudo a2ensite default-ssl.conf sudo apt-get install python-tz sudo apt-get install python-pip sudo pip install flask-ask sudo pip install kodi-voice sudo pip install python-Levenshtein sudo systemctl restart apache2
12.) Deploy kanzi
cp -r /home/kodi/kanzi/source/repo /var/www/kodi-alexa chown -R www-data:www-data /var/www/kodi-alexa lexigram deploy kanzi
Set invocation name (2 for kodi)
#set skill server to local ip address https://example.dyndns.org/kodi-alexa
possible adjustment required. not sure if external access is absolutely required.
In Alexa Skill Set, Add your IP and service name as the HTTPS URL: https://XXXX.ddns.net/kodi-alexa Upload x509 certificate file for the endpoint (copy the /etc/apache2/ssl/apache.crt to the local PC or use cat and copy & paste the code into a local text file and upload that text file. Finally, if you haven't already, you'll have to open your apache server to the Internet with port forwarding. 13.) To limit requests to your own alexa skill only, use the skill ID and add it to kodi.config <code> skill_id = [set to amzn1.ask.skill.xxxxxxx as per url on developer.amazon.com
then re-deploy
lexigram deploy kanzi
Updates
npm upgrade -g lexigram-cli lexigram deploy kanzi