Mit Echo (Alexa) Kodi Media Center steuern
Viele haben ein Kodi Mediacenter zu Hause. Vielleicht auf einem Raspberry PI oder einem Intel NUC.
Wäre es nicht super das Mediacenter via Sprache mit alexa steuern zu können?
Der dafür notwendige Skill kommt von Joe Ipson und kann hier heruntergeladen werden.
Im Kodi musst du die Webgui aktivieren und mit User und Kennwort schützen.
Auf deinem Router musst du dann noch den Port 8080 freigeben. Weil das Mediacenter nach außen freigegeben wird empfehle ich
ein starkes Kennwort.
Jetzt brauchst du einen AWS Account, den du vielleicht bereits hast, da du meiner Anleitung gefolgt bist.
Geh auf https://aws.amazon.com/de/ und klick auf „Kostenloses Konto erstellen“. Einfach mit dem Amazon Account einloggen.
Man braucht eine Kreditkarte. Es wird aber nichts berechnet, denn im AWS Account sind 1 Millionen requests im Monat kostenlos enthalten.
Da müsste man schon sehr viel mit Alexa und Kodi für reden…
Anschließend wird der Account mittels Telefonnummer verifiziert. Wähle „Basis“ Paket aus, das ist nämlich kostenlos und tut es für unsere Zwecke.
{code lang:bash hidden:false}
apt-get update
apt-get install python unp pip
cd /opt/
wget https://github.com/m0ngr31/kodi-alexa/archive/master.zip
unp master.zip
rm master.zip
cd kodi-alexa-master
mv .env.lambda .env
{/code}
Die env ist versteckt! Das erkennt man an dem PUNKT vor der Datei. Unter Linux ist das kein Problem.
Nun musst du die Datei mit dem Editor deiner Wahl (meiner ist vim) anpassen
{code lang:bash hidden:false}
vim .env
{/code}
{code lang:bash hidden:false}
KODI_ADDRESS=XXXXXX.dlinkddns.com
KODI_PORT=8080
KODI_USERNAME=kodiuser
KODI_PASSWORD=kodipassword
{/code}
Bei Kodi Adress bitte kein WWW voran!!!
Ganz am Ende der Datei gibt es noch eine Einstellung
{code lang:bash hidden:false}
AWS_DEFAULT_REGION = eu-west-1
{/code}
Nun sind am Ende noch weitere Einstellungen vorzunehmen. Dafür benötigen wir nun den oben genannten AWS Account.
Hier legst du einen User an –> Add user
Vergebe einen Namen / Kennwort und setze alle Einstellungen wie ich hier.
Auf „Attach existing policies directly“ klicken und den Haken bei „AWSLambdaFullAccess“ setzen.
„Create User“.
„Access Key ID“ und „Secret access key“ kopieren und für gleich bereithalten. Wer will fügt es einfach schon in der .env ein.
Jetzt links auf „Roles“ und wie hier im Screenshot eine Rolle anlegen.
„AWS Lambda“ wählen –> Select
Nun die Policy „AWSLambdaFullAccess“ wählen.
Jetzt auf „Next Step“
Jetzt wird dir unter anderem der Role ARN in der Form „arn:aws:iam::11111111111:role/meinRollenName“. – Kopieren und dann auf „Create Role“.
Jetzt geht es in der .ENV weiter.
Unten die gerade ermittelten Werte eintragen.
{code lang:bash hidden:false}
AWS_ACCESS_KEY_ID=XXXxXXXXXXxxXXX
AWS_SECRET_ACCESS_KEY=XXXXXXXxxxxxxXXXXXXXXxXxXXx
LAMBDA_ROLE=arn:aws:iam::XXXXXXXXXXXX:role/meineRolleName
{/code}
Nun musst du die Datei „wsgi.py“ anpassen
{code lang:bash hidden:false}
cd /opt/kodi-alexa-master
vim wsgi.py
{/code}
Hier muss die zweite Zeile ergänzt werden.
{code lang:bash hidden:false}
#!/usr/bin/python
# This Python file uses the following encoding: utf-8
import os
{/code}
Jetzt musst du deinen Skill zu AWS übertragen.
{code lang:bash hidden:false}
cd /opt/kodi-alexa-master
pip install lambda-deploy
lambda-deploy deploy
{/code}
Jetzt geht es wieder in der AWS Console und dort zur Lambda-Seite weiter.
Bei Region oben rechts Ireland auszuwählen, sonst klappt das nicht!
Klicke auf Functions.
Wichtig: Im nächsten Bild rechts oben den Code der mit „ARN“ kopieren und z.B. im Notepad zwischenspeichern.
Create a Lmbda function –> Jetzt auf „Triggers“ –> „Add Trigger“ –> „Alexa Skill Kit“
Jetzt musst du den Skill mit Alexa verknüpfen.
Dazu brauchst du einen Amazon Developer Account. Den gibt es hier https://developer.amazon.com/login.html
Anmelden mit deinem Amazon Account und registriere dich für den Developer Account.
Und gib dort an, das du damit kein Geld verdienen willst.
Weiter geht es oben im Menü mit „Alexa“ –> „Get Started“ –> „Add New Skill“
Hier alles eintragen.
Skill Type: Custom Interaction Model
Language: German
Name: Kodi
Invocation name: media center
Audio Player: no
Der Invocation Name ist der Name auf den Alexa hört. Mit „Alexa, frage Invocation name, wie heißt der Titel“ wird gearbeitet
Ich habe mit „media center“ das beste Ergebnis. Denkbar sind aber auch andere Begriff oder Namen (James…).
Es geht weiter. Bei Intent Schema diesen Code einfügen
{code lang:bash hidden:false}
{
„intents“: [
{
„intent“: „WhatNewAlbums“,
„slots“: []
},
{
„intent“: „WhatNewMovies“,
„slots“: [
{
„name“: „Genre“,
„type“: „MOVIEGENRES“
}
]
},
{
„intent“: „WhatNewShows“,
„slots“: []
},
{
„intent“: „NewShowInquiry“,
„slots“: [
{
„name“: „Show“,
„type“: „SHOWS“
}
]
},
{
„intent“: „CleanVideo“,
„slots“: []
},
{
„intent“: „UpdateVideo“,
„slots“: []
},
{
„intent“: „CleanAudio“,
„slots“: []
},
{
„intent“: „UpdateAudio“,
„slots“: []
},
{
„intent“: „PlayPause“,
„slots“: []
},
{
„intent“: „PlayerSeekSmallForward“,
„slots“: []
},
{
„intent“: „PlayerSeekSmallBackward“,
„slots“: []
},
{
„intent“: „PlayerSeekBigForward“,
„slots“: []
},
{
„intent“: „PlayerSeekBigBackward“,
„slots“: []
},
{
„intent“: „Stop“,
„slots“: []
},
{
„intent“: „WhatAlbums“,
„slots“: [
{
„name“: „Artist“,
„type“: „MUSICARTISTS“
}
]
},
{
„intent“: „ListenToArtist“,
„slots“: [
{
„name“: „Artist“,
„type“: „MUSICARTISTS“
}
]
},
{
„intent“: „ListenToAlbum“,
„slots“: [
{
„name“: „Artist“,
„type“: „MUSICARTISTS“
},
{
„name“: „Album“,
„type“: „MUSICALBUMS“
}
]
},
{
„intent“: „ListenToSong“,
„slots“: [
{
„name“: „Artist“,
„type“: „MUSICARTISTS“
},
{
„name“: „Song“,
„type“: „MUSICSONGS“
}
]
},
{
„intent“: „ListenToAlbumOrSong“,
„slots“: [
{
„name“: „Artist“,
„type“: „MUSICARTISTS“
},
{
„name“: „Album“,
„type“: „MUSICALBUMS“
},
{
„name“: „Song“,
„type“: „MUSICSONGS“
}
]
},
{
„intent“: „ListenToAudioPlaylist“,
„slots“: [
{
„name“: „AudioPlaylist“,
„type“: „MUSICPLAYLISTS“
}
]
},
{
„intent“: „ShuffleAudioPlaylist“,
„slots“: [
{
„name“: „AudioPlaylist“,
„type“: „MUSICPLAYLISTS“
}
]
},
{
„intent“: „ListenToAudioPlaylistRecent“,
„slots“: []
},
{
„intent“: „WatchEpisode“,
„slots“: [
{
„name“: „Show“,
„type“: „SHOWS“
},
{
„name“: „Episode“,
„type“: „AMAZON.NUMBER“
},
{
„name“: „Season“,
„type“: „AMAZON.NUMBER“
}
]
},
{
„intent“: „WatchRandomEpisode“,
„slots“: [
{
„name“: „Show“,
„type“: „SHOWS“
}
]
},
{
„intent“: „WatchLatestEpisode“,
„slots“: [
{
„name“: „Show“,
„type“: „SHOWS“
}
]
},
{
„intent“: „WatchNextEpisode“,
„slots“: [
{
„name“: „Show“,
„type“: „SHOWS“
}
]
},
{
„intent“: „WatchLastShow“,
„slots“: []
},
{
„intent“: „WatchMovie“,
„slots“: [
{
„name“: „Movie“,
„type“: „MOVIES“
}
]
},
{
„intent“: „WatchRandomMovie“,
„slots“: [
{
„name“: „Genre“,
„type“: „MOVIEGENRES“
}
]
},
{
„intent“: „WatchVideoPlaylist“,
„slots“: [
{
„name“: „VideoPlaylist“,
„type“: „VIDEOPLAYLISTS“
}
]
},
{
„intent“: „ShuffleVideoPlaylist“,
„slots“: [
{
„name“: „VideoPlaylist“,
„type“: „VIDEOPLAYLISTS“
}
]
},
{
„intent“: „ShufflePlaylist“,
„slots“: [
{
„name“: „AudioPlaylist“,
„type“: „MUSICPLAYLISTS“
},
{
„name“: „VideoPlaylist“,
„type“: „VIDEOPLAYLISTS“
}
]
},
{
„intent“: „Prev“,
„slots“: []
},
{
„intent“: „Skip“,
„slots“: []
},
{
„intent“: „StartOver“,
„slots“: []
},
{
„intent“: „Home“,
„slots“: []
},
{
„intent“: „Back“,
„slots“: []
},
{
„intent“: „Up“,
„slots“: []
},
{
„intent“: „Down“,
„slots“: []
},
{
„intent“: „Right“,
„slots“: []
},
{
„intent“: „Left“,
„slots“: []
},
{
„intent“: „Select“,
„slots“: []
},
{
„intent“: „Menu“,
„slots“: []
},
{
„intent“: „PageUp“,
„slots“: []
},
{
„intent“: „PageDown“,
„slots“: []
},
{
„intent“: „Fullscreen“,
„slots“: []
},
{
„intent“: „Mute“,
„slots“: []
},
{
„intent“: „VolumeUp“,
„slots“: []
},
{
„intent“: „VolumeDown“,
„slots“: []
},
{
„intent“: „VolumeSet“,
„slots“: [
{
„name“: „Volume“,
„type“: „AMAZON.NUMBER“
}
]
},
{
„intent“: „VolumeSetPct“,
„slots“: [
{
„name“: „Volume“,
„type“: „AMAZON.NUMBER“
}
]
},
{
„intent“: „SubtitlesOn“,
„slots“: []
},
{
„intent“: „SubtitlesOff“,
„slots“: []
},
{
„intent“: „SubtitlesNext“,
„slots“: []
},
{
„intent“: „SubtitlesPrevious“,
„slots“: []
},
{
„intent“: „AudioStreamNext“,
„slots“: []
},
{
„intent“: „AudioStreamPrevious“,
„slots“: []
},
{
„intent“: „PlayerMoveUp“,
„slots“: []
},
{
„intent“: „PlayerMoveDown“,
„slots“: []
},
{
„intent“: „PlayerMoveLeft“,
„slots“: []
},
{
„intent“: „PlayerMoveRight“,
„slots“: []
},
{
„intent“: „PlayerRotateClockwise“,
„slots“: []
},
{
„intent“: „PlayerRotateCounterClockwise“,
„slots“: []
},
{
„intent“: „PlayerZoomHold“,
„slots“: []
},
{
„intent“: „PlayerZoomIn“,
„slots“: []
},
{
„intent“: „PlayerZoomInMoveUp“,
„slots“: []
},
{
„intent“: „PlayerZoomInMoveDown“,
„slots“: []
},
{
„intent“: „PlayerZoomInMoveLeft“,
„slots“: []
},
{
„intent“: „PlayerZoomInMoveRight“,
„slots“: []
},
{
„intent“: „PlayerZoomOut“,
„slots“: []
},
{
„intent“: „PlayerZoomOutMoveUp“,
„slots“: []
},
{
„intent“: „PlayerZoomOutMoveDown“,
„slots“: []
},
{
„intent“: „PlayerZoomOutMoveLeft“,
„slots“: []
},
{
„intent“: „PlayerZoomOutMoveRight“,
„slots“: []
},
{
„intent“: „PlayerZoomReset“,
„slots“: []
},
{
„intent“: „Hibernate“,
„slots“: []
},
{
„intent“: „Reboot“,
„slots“: []
},
{
„intent“: „Shutdown“,
„slots“: []
},
{
„intent“: „Suspend“,
„slots“: []
},
{
„intent“: „EjectMedia“,
„slots“: []
},
{
„intent“: „PartyMode“,
„slots“: []
},
{
„intent“: „CurrentPlayItemInquiry“,
„slots“: []
},
{
„intent“: „CurrentPlayItemTimeRemaining“,
„slots“: []
},
{
„intent“: „AddonExecute“,
„slots“: [
{
„name“: „Addon“,
„type“: „ADDONS“
}
]
},
{
„intent“: „AddonGlobalSearch“,
„slots“: [
{
„name“: „Artist“,
„type“: „MUSICARTISTS“
},
{
„name“: „Album“,
„type“: „MUSICALBUMS“
},
{
„name“: „Song“,
„type“: „MUSICSONGS“
},
{
„name“: „Movie“,
„type“: „MOVIES“
},
{
„name“: „Show“,
„type“: „SHOWS“
}
]
}
]
}
{/code}
Jetzt musst du so genannte Slots anlegen (9). Diese kannst du automatisch für ein schnelles Copy & Paste hier erzeugen: https://slot-generator.herokuapp.com/
Jetzt könnt ihr euch die „Sample Utterances“ hier laden. Wenn ihr es für erforderlich haltet, könnt ihr diese weiter anpassen.
Den Inhalt der Datei bei „Sample Utterances“ einfügen und dann „Save“, dann auf „Next“.
Alle so einstellen wie im Bild. Den weiter oben im Notepad gesicherten ARN Code hier einfügen!
Folgendes einstellen. Und dann einfach nur auf „Save“.
Jetzt gehts auf HTTPS://alexa.amazon.de/ –> Skills –> Ihre Skills (oben rechts).
Jetzt kannst du den Skill aktivieren und mit „Alexa, frage mediacenter, spiele musik von Michael Jackson“ testen.
Dir hat das Projekt gefallen? Dann Unterstütze mich, damit ich weiterhin solche Projekte vorstellen kann!