Skip to content

Latest commit

 

History

History
743 lines (624 loc) · 45.2 KB

README.md

File metadata and controls

743 lines (624 loc) · 45.2 KB

Control Kodi through your Google Home / Google Assistant

Table of contents:


What it can do

Follow these steps to easily control your kodi using simple voice commands with your Google Home or Google assistant:

Play a movie:

"Hey Google, kodi play [movie name]" --> will search for the given movie name and play it.
"Hey Google, kodi resume [movie name]" --> will search for given movie name and pick up playback from where you left it.

Play a random movie:

"Hey Google, kodi play a random movie" --> will play a random movie.
"Hey Google, kodi play a random horror movie" --> will play a random movie of the genre "Horror".
"Hey Google, kodi play a random movie of the year 2010" --> will play a random movie of the year 2010.
"Hey Google, kodi play a random horror movie of the year 2010" --> will play a random movie of the genre "Horror" and of the year 2010.

Play a tv show:

Play the next unwatched episode: "Hey Google, kodi play tv show [tv show name]" --> will search for the given tv show and play the next unwatched episode.
Play a specific episode: "Hey Google, kodi play [tv show name] season 3 episode 1" --> will search for the given tv show and play season 3 episode 1.
Play a random episode from a tv show: "Hey Google, kodi shuffle [tv show name]" --> will search for the given tv show and play a random episode.
Play the most recently added episode: "Hey Google, kodi play new episode" --> will play the most recently added episode to the kodi library.
Binge watch a tv show: "Hey Google, kodi binge watch [tv show name]" --> will add all unwatched episodes to the playlist and play it.

Search and play a youtube video:

"Hey Google, kodi play youtube [youtube title]" --> will search a youtube video, and play the first video.
"Hey Google, kodi search youtube [youtube title]" --> will search youtube and show you the results on the kodi screen.

Pause / Resume kodi:

"Hey Google, pause kodi"

Stop kodi:

"Hey Google, stop kodi"

Change volume:

Mute kodi: "Hey Google, mute/unmute kodi"
Set volume: "Hey Google, set kodi volume to 60"
Increase volume: "Hey Google, Kodi volume up [by 10]" --> increase the volume by the requested amount or by 20% if no amount was specified
Decrease volume: "Hey Google, Kodi volume down [by 10]" --> similar to the above

Play PVR channel:

"Hey Google, switch kodi to BBC channel" or "Hey Google, switch kodi to channel 10"

Turn on TV:

"Hey Google, switch to kodi" --> will turn on the TV and switch to Kodi's HDMI input

Control Kodi-System:

"Hey Google, kodi shutdown" "Hey Google, kodi hibernate" "Hey Google, kodi reboot" "Hey Google, kodi suspend"

Scan/Clean library:

"Hey Google, kodi scan library" --> Will start a full library scan "Hey Google, kodi clean library" --> Will cleanup your library

Navigate kodi:

Navigate up: "Hey Google, kodi navigate up [3]" --> Will navigate up the requested amount or just once if no number was specified
Navigate Down: "Hey Google, kodi navigate down [3]" --> same as above for navigating down
Navigate Left: "Hey Google, kodi navigate left [3]" --> same as above for navigating left
Navigate Right: "Hey Google, kodi navigate right [3]" --> same as above for navigating right
Navigate Back: "Hey Google, kodi go back [3]" --> Will navigate back the requested amount or just once if no number was specified
Navigate Select: "Hey Google, kodi Select" --> Will select the hightlighted item
Navigate Context Menu: "Hey Google, kodi open context menu" --> Will open the context menu for the selected item
Navigate Go Home: "Hey Google, kodi go home" --> Will open the main menu page

Show kodi windows:

"Hey Google, kodi show favourites"
"Hey Google, kodi show movies"
"Hey Google, kodi show movies by title"
"Hey Google, kodi show movies by genre"
"Hey Google, kodi show recently added movies"
"Hey Google, kodi show tv shows"
"Hey Google, kodi show tv shows by title"
"Hey Google, kodi show tv shows by genre"
"Hey Google, kodi show recently added episodes"
"Hey Google, kodi show video addons"
"Hey Google, kodi show music addons"
"Hey Google, kodi show video files"
"Hey Google, kodi show music files"
"Hey Google, kodi show the top 100 albums"
"Hey Google, kodi show system settings"
"Hey Google, kodi show file manager"
"Hey Google, kodi show new YouTube videos"
"Hey Google, kodi show YouTube watch later"
"Hey Google, kodi show YouTube history"
"Hey Google, kodi show YouTube recommendations"
"Hey Google, kodi show YouTube subscriptions"
"Hey Google, kodi show YouTube settings"
"Hey Google, kodi show Spotify" (Spotify Kodi-Addon required)
"Hey Google, kodi show Spotify featured playlists" (Spotify Kodi-Addon required)

There are many more windows to choose from, a full list can be found here.

Whats Playing:

"Hey Google, kodi Whats Playing" --> Will show whats playing information

Change Subtitles:

"Hey Google, kodi subtitles on/off/previous/next" --> Will change subtitle settings

Change Subtitles direct select:

"Hey Google, kodi change subtitle to track 3" --> Will change subtitle track to a specific track

Change Audiostream(Language):

"Hey Google, kodi audiostream previous/next" --> Will change audiostream settings

Change Audiostream(Language) direct select:

"Hey Google, kodi change audiostream to track 3" --> Will change audiostream settings

Seek forward x minutes:

"Hey Google, kodi go forward 30 minutes" --> will seek forward [the requested number] of minutes or just 1 minute if no number was specified

Seek backwards x minutes:

"Hey Google, kodi go backward 30 minutes" --> same as above just seeking backward

Seek to x minutes:

"Hey Google, kodi jump to 30 minutes"

Play music:

"Hey Google, kodi play the song [song name]" --> will search for the given song name and play it.
"Hey Google, kodi play the album [album name]" --> will search for the given album name and play it.
"Hey Google, kodi play songs by the artist [music artist name]" --> will search for the given music artist name and play it.
"Hey Google, kodi play some [genre name] music" --> will play shuffled songs of that genre.
"Hey Google, kodi toggle party mode" --> starts the kodi party mode.

Playlist Control:

"Hey Google, kodi play playlist [playlistname]" --> This will look for a playlist with that name and play it. Smart and regular playlist supported.
"Hey Google, kodi playlist previous/next/[list item number]" --> This will go forward/backward or select an item on the currently playing playlist #.


How to setup and update

Disclaimer: Use on your own risk and choose complex username & password in the below steps.

A) Enable webserver access in kodi

  1. In Kodi, go to Settings > Services > Web server
  2. Set Allow remote contorl via HTTP to On
  3. Choose a port number (e.g. 8080). We will refer to that port as YOUR_KODI_PORT
  4. Choose a username and password (Important!). We will refer to those values as YOUR_KODI_USER_NAME and YOUR_KODI_PASSWORD

B) Set up a nodejs-webserver to control your kodi

We currently support three methods of how this app can be hosted.
1. Hosting it in Glitch, a 3rd-party web-hosting service (No longer usable)
2. Hosting it yourself
3. Hosting it yourself with Docker
4. Hosting it with Google Cloud Run

The first method is very easy to set up and to maintain and also free of charge. The second method is for advanced users. You have to setup and maintain the nodejs environment yourself. But it supports multiple Kodi instances, greatly reduces latency and does not expose your kodi-webservice to the internet directly. The third method is also for advanced users. After installing docker, you can simply run our app as a production ready docker container. This is the recommended method for LibreELEC users.

B.1 Set up a webserver in Glitch (Click to expand instructions)

Please note, this method is no longer usable, due to Glitch's new policy regarding IFTTT and other pinging services like it. This section is left here for historic reasons. See #305 for more details.

  1. Configure your router to forward YOUR_KODI_PORT.
    Note: This is needed, so your kodi can be contacted from the internet.
  2. Find your external IP address (i.e. google for 'what's my ip?'). We will refer to that as YOUR_EXTERNAL_IP_ADDRESS later.
    Hint: It is strongly recommended to setup a dynDNS service of your choice. (i.e. selfhost.me)
  3. Go to Glitch.com and sign in with your github user
  4. Create a new Glitch project and under advance settings choose Import from GitHub
  5. Enter this project OmerTu/GoogleHomeKodi
  6. Change Glitch project settings to private (under share > Make private)
  7. Edit the .env file in your Glitch project with the following settings: (see this example)
KODI_PROTOCOL="http"
KODI_IP="YOUR_EXTERNAL_IP_ADDRESS"
KODI_PORT="YOUR_KODI_PORT"
KODI_USER="YOUR_KODI_USER_NAME"
KODI_PASSWORD="YOUR_KODI_PASSWORD"
AUTH_TOKEN="YOUR_CONNECTION_PASSWORD"
BROKER_ACCENT_INSENSITIVE_MATCH="true"
BROKER_LANGUAGE_CACHE_ENABLE="false"

YOUR_CONNECTION_PASSWORD can be anything you want. BROKER_ACCENT_INSENSITIVE_MATCH is a boolean value indicating if broker should do accent insensitive pattern matching (default: false). If set to true, broker will convert accentued characters from the sent phrase and the configured pattern in <lang_code>.json (for example é, è, ê and ë) to the unaccentued equivalent character (for example e). This allow to configure pattern regarde in <lang_code>.json and match regarde, regardé. BROKER_LANGUAGE_CACHE_ENABLE is a boolean value indicating if broker should can cache language file if previous and actual request language are equals (default: true).

  1. Check your Glitch server address by choosing 'Show Live' on the top left. A new tab with your server will open. Note your server address in the address bar, you will need that later. We will refer to this address as YOUR_NODE_SERVER. (i.e. https://green-icecream.glitch.me)

How to update to the latest version

  1. Go to Glitch.com and sign in with your github user
  2. Select your Glitch project and under advance settings choose Import from GitHub
  3. Enter this project OmerTu/GoogleHomeKodi
B.2 Set up local webserver (Click to expand instructions)

  1. Install the Node.js application server on your target computer
    Note: Minimum required Version is 6.10 (but 10 or higher for the broker feature)
  2. Choose a location, where your app will live (i.e C:\node\)
  3. Clone this repo with git (recommended) or simply download and unzip the sourcecode (green button on the top-right)
  4. You now should have a folder with a bunch of files in it (i.e. here C:\node\GoogleHomeKodi)
  5. Install this app
cd C:\node\GoogleHomeKodi
npm install
  1. Create a copy of the kodi-hosts.config.js.dist file and name it kodi-hosts.config.js.
  2. Edit the file and make sure the kodiConfig and globalConfig sections match your environment.
  3. Set up your router to forward the port you just configured.
    Default: globalConfig.listenerPort: '8099'
  4. You should now be able to start the node server by running: node server.js.
  5. Determine the internal IP-Address or the hostname of the machine running this node server.
    (i.e. by executing ipconfig/ifconfig) We refer to that as YOUR_INTERNAL_NODE_IP.
  6. Configure your router to forward the port from step 8 to YOUR_INTERNAL_NODE_IP.
    Note: This is needed, so your kodi can be contacted from the internet.
  7. Find your external IP address (i.e. Google 'what's my ip?')
    Hint: It is strongly recommended to setup a dynDNS service of your choice. (i.e. selfhost.me)
  8. The address of your self hosted node server now consists of the port of step 8 and the ip/host of step 12.
    We will refer to this address later as YOUR_NODE_SERVER. (i.e. http://omertu.selfhost.me:8099)

For Linux-Users only: Here is a systemd init config. To run it as a daemon. On a debian dist save it as /etc/systemd/system/kodiassistant.service. Don't forget to run: sudo systemctl enable sudo systemctl enable kodiassistant.service to start the deamon on startup.

[Unit]
Description=Node.js Google Home Kodi Interface

[Service]
ExecStart=/usr/bin/node /opt/GoogleHomeKodi/server.js
# Required on some systems
WorkingDirectory=/opt/GoogleHomeKodi
Restart=always
# Restart service after 10 seconds if node service crashes
RestartSec=10
# Output to syslog
StandardOutput=syslog
StandardError=syslog
SyslogIdentifier=nodejs-example

[Install]
WantedBy=multi-user.target

How to update to the latest version

a. If you cloned the repo, just do git pull --autostash && npm install
b. If you downloaded and unzipped, backup your configuration, redownload and unzip, followed by npm install. Finally reapply your config.

B.3 Set up local webserver using Docker (Click to expand instructions)

As an alternative to (B.2), it's possible to use a Docker container to run a local instance.

You can configure your instance simply through environment variables or a kodi-hosts.config.js inside a folder mapped to the container-file-path /config.

  1. Install the Docker engine
    • If you want to run it on a LibreELEC system
      You can simply install the offical service addon Docker
      Note: Enable the feature Wait for network before starting kodi under Settings > LibreELEC > Network
    • For all other systems please see the offical documentation
      Docker Installation
  2. Get the latest GoogleHomeKodi docker image
    docker pull omertu/googlehomekodi
    
  3. Now just run the production-ready docker image
    • with the use of environment variables:
      docker run \
         --detach \
         --publish 8099:8099 \
         --restart always \
         -e KODI_PROTOCOL="http" \
         -e KODI_IP="YOUR_INTERNAL_KODI_IP_ADDRESS" \
         -e KODI_PORT="YOUR_KODI_PORT" \
         -e KODI_USER="YOUR_KODI_USER_NAME" \
         -e KODI_PASSWORD="YOUR_KODI_PASSWORD" \
         -e AUTH_TOKEN="YOUR_CONNECTION_PASSWORD" \
         -e BROKER_ACCENT_INSENSITIVE_MATCH="false" \
         -e BROKER_LANGUAGE_CACHE_ENABLE="true" \
         --name googlehomekodi \
         omertu/googlehomekodi
    • with the use of docker-compose:
      create a file named docker-compose.yml with the following contents:
       version: '3'
       services:
         googlehomekodi:
           image: omertu/googlehomekodi
           ports:
             - "8099:8099"
           environment:
             - KODI_PROTOCOL=http
             - KODI_IP=YOUR_INTERNAL_KODI_IP_ADDRESS
             - KODI_PORT=YOUR_KODI_PORT
             - KODI_USER=YOUR_KODI_USER_NAME
             - KODI_PASSWORD=YOUR_KODI_PASSWORD
             - AUTH_TOKEN=YOUR_CONNECTION_PASSWORD
             - BROKER_ACCENT_INSENSITIVE_MATCH=true
             - BROKER_LANGUAGE_CACHE_ENABLE=false
           restart: always
      
      and then just fire it up with
      docker-compose up --detach
    • or with the use of the config file:
      • Create a copy of the kodi-hosts.config.js.dist file and name it kodi-hosts.config.js.
      • Edit the file and make sure the kodiConfig and globalConfig sections match your environment.
      • Run it
        docker run \
           --detach \
           --publish 8099:8099 \
           --restart always \
           -v YOUR_CONFIG_DIR:/config \
           --name googlehomekodi \
           omertu/googlehomekodi
  4. Determine the internal IP-Address or the hostname of the machine running the docker container.
    We refer to that as YOUR_INTERNAL_NODE_IP.
    Hint: When running the docker container on the same LibreELEC-host just use the hostname libreelec as the IP-Address of your node server.
  5. Configure your router to forward the port from the step 3 (8099 is the default) to YOUR_INTERNAL_NODE_IP.
    Note: This is needed, so your kodi can be contacted from the internet.
  6. Find your external IP address (i.e. Google 'what's my ip?')
    Hint: It is strongly recommended to setup a dynDNS service of your choice. (i.e. selfhost.me)
  7. The address of your self hosted node server now consists of the port of step 5 and the ip/host of step 6.
    We will refer to this address later as YOUR_NODE_SERVER. (i.e. http://omertu.selfhost.me:8099)

How to update to the latest version

Execute:

docker rmi --force omertu/googlehomekodi

then just repeat steps 2 and 3 of the installation above.

B.4 Google Cloud Run (Click to expand instructions)

  1. Just click here:
    Run on Google Cloud

C) [OPTIONAL] controlling multiple kodi instances

There are two ways of implementing the scenario of multiple kodi instances (i.e one in the living room and another in the bedroom). For both methods you will need two IFTTT-Applets with different phrases, due to the text-parameter limitation of IFTTT.

  1. Having two node servers. Each targeting one instance. (Recommended when hosting with glitch)
    i.e. the phrase living room kodi play... could target https://mylivingroom.glitch.com/playpause
    and the phrase bedroom kodi play... could target https://bedroom.glitch.com/playpause.
    • Note: Behind a single external IP the kodi instances need still to be distinguishable.
      This can be achieved in two ways:
      • Configuring both kodi instances with different ports
        (i.e. 8080 and 8090)
        or
      • Mapping with your routers port forwarding two different ports to the same port on different hosts
        (i.e. 8080 -> 192.168.100.1:8080 and 8090 -> 192.168.100.2:8080)
  2. Having one node server targeting both kodi instances. (Recommended when hosting yourself)
    The utilization of the kodi-hosts.config.js allows you to name your instances and target them individually.
    i.e. the phrase living room kodi play... could target http://192.168.100.1:8080/playpause
    and the phrase bedroom kodi play... could target http://192.168.100.2:8080/playpause).
C.2 utilize the kodi-hosts.config.js (Click to expand instructions)

For this you will need to extend the list of configured kodi instances. Like in this example:

exports.kodiConfig = [
  {
      id: 'kodi', // Give your main instance here any name you want
      // YOUR_KODI_PROTOCOL (http or https)
      kodiProtocol: 'http',
      // YOUR_KODI_IP_ADDRESS
      kodiIp: '192.168.178.10',
      // YOUR_KODI_PORT
      kodiPort: '8080',
      // YOUR_KODI_USER_NAME
      kodiUser: 'kodi',
      // YOUR_KODI_PASSWORD
      kodiPassword: 'myKodiPass'
  },
      // You can use this to specify additonal kodi installation, that you'd like to control.
      // For example alternate kodi destination 1:
  {
      id: 'bedroom',
      // YOUR_2ND_KODI_PROTOCOL (http or https)
      kodiProtocol: 'http',
      // YOUR_2ND_KODI_IP_ADDRESS
      kodiIp: '192.168.1.11',
      // YOUR_2ND_KODI_PORT
      kodiPort: '8080',
      // YOUR_2ND_KODI_USER_NAME
      kodiUser: 'kodi',
      // YOUR_2ND_KODI_PASSWORD
      kodiPassword: 'myKodiPass'
  },
      // You can use this to specify additonal kodi installation, that you'd like to control.
      // For example alternate kodi destination 2:
  {
      id: 'kitchen',
      // YOUR_3RD_KODI_PROTOCOL (http or https)
      kodiProtocol: 'http',
      // YOUR_3RD_KODI_IP_ADDRESS
      kodiIp: '192.168.1.12',
      // YOUR_3RD_KODI_PORT
      kodiPort: '8080',
      // YOUR_3RD_KODI_USER_NAME
      kodiUser: 'kodi',
      // YOUR_3RD_KODI_PASSWORD
      kodiPassword: 'myKodiPass'
  }
];

The id (a name you can choose freely) will match your kodi instance with a spoken keyword. For every command / kodi destination you will need to add a new IFTTT applet. The only difference is found in the body. As up until now you have been using a body only with a token attribute like: {"token":"*YOUR_CONNECTION_PASSWORD*"}. Now you will need to add the kodiid attribute to it, matching the id of your configuration.

Example scan library If you normally would use a sentence like: "Hey Google, kodi scan library" --> Will start a full library scan. For running this command on your second kodi instance, you could copy the applet, and change it to: "Hey Google, kodi scan library in the bedroom".

In this new applet, you will need to make sure it will recognize this new sentence, and add the attribute kodiid to the body. For example: {"token":"*YOUR_CONNECTION_PASSWORD*", "kodiid":"bedroom"}

D) Set up IFTTT with your Google Home

  1. Go to IFTTT

  2. Create a new applet: if This then That

  3. For This choose: Google Assistance

    1. Choose Say a phrase with a text ingredient
    2. In What do you want to say? enter something like:

    Kodi play movie $

    1. In What do you want the Assistant to say in response? enter something like:

    ok playing $ movie

  4. For That choose: Maker Webhooks

    1. Choose Make a web request
    2. In URL enter:

    YOUR_NODE_SERVER/playmovie?q={{TextField}}

    For example, if your node server address is 'green-icecream.glitch.me', your should enter:

    https://green-icecream.glitch.me/playmovie?q={{TextField}}

    1. Method: POST
    2. Content Type: application/json
    3. Body:

    {"token":"YOUR_CONNECTION_PASSWORD"}

Check out this example to make sure your settings are correct

Now every time you say "Hey Google, Kodi play movie bla bla", it should play bla bla on your kodi.
Note: If your external IP changes, this will stop working (consider getting a static IP address)
Tip: If you don't want define action for every phrase separatelly, you can use Phrase broker

Setting up other actions:

For Tv show support - Next unwatched episode, follow all the steps in D, except these changes:

  • Choose a different phrase (e.g. "Kodi play an episode of $")
  • Use this URL:

    YOUR_NODE_SERVER/playtvshow?q={{TextField}}

For Tv show support - Specific episode, follow all the steps in D, except these changes:

  • Choose "Say a phrase with both a number and a text ingredient" in step 3
  • Choose a different phrase (e.g. "Kodi play $ episode #").

For this to work, when you talk to your GoogleHome, the $ part must be in the format of "[TV_SHOW_NAME] season [SEASON_NUMBER]". Meaning the word "Season" has to be said, the tv show name must be said before it and the season number must be said after it (i.e. "okay google kodi play bla season 4 episode 1")

  • Use this URL:

    YOUR_NODE_SERVER/playepisode?q={{TextField}}&e={{NumberField}}

To pause or resume kodi follow the instructions in D, except these changes:

  • Choose "Say a simple phrase" in step 3
  • Use this URL:

    YOUR_NODE_SERVER/playpause

To Stop kodi, follow the same instructions as pause but use this URL:

YOUR_NODE_SERVER/stop

To Mute kodi, follow the same instructions as pause but use this URL:

YOUR_NODE_SERVER/mute

To Set Volume on kodi use "Say a phrase with a number" and the URL:

YOUR_NODE_SERVER/volume?q={{NumberField}}

To Seek forward by x minutes use "Say a phrase with a number" and the URL:

YOUR_NODE_SERVER/seekforwardminutes?q={{NumberField}}

For PVR TV/radio support - Set channel by name, follow all the steps in D, except these changes:

  • Choose a different phrase (e.g. "switch kodi to $ channel")
  • Use this URL:

    YOUR_NODE_SERVER/playtvchannelbyname?q={{TextField}} YOUR_NODE_SERVER/playradiochannelbyname?q={{TextField}}

For PVR TV/radio support - Set channel by number, use "Say a phrase with a number" and the URL:

YOUR_NODE_SERVER/playtvchannelbynumber?q={{NumberField}} YOUR_NODE_SERVER/playradiochannelbynumber?q={{NumberField}}

Phrase broker:

Instead of defining each phrase separately on IFTTT, you can use built-in phrase broker, which will parse phrase on node server. It uses regular expression for matching phrases, so it is more powerful than IFTTT's $ and #. For setup phrase broker you need to define on IFTTT one single action (for example "Kodi $") and direct that action to the broker URL:

YOUR_NODE_SERVER/broker?phrase={{TextField}}

If you want to use other language than english, just lang parameter to that URL:

YOUR_NODE_SERVER/broker?phrase={{TextField}}&lang=<lang_code>

where <lang_code> is name of json file in app's broker folder without json extension (so for example "lang=en")

If there is not your language in broker folder yet, it is easy to add a new language. Just copy en.json and name it with your language's code. Then edit that new file and change language text in second column to your language. You can also create your variant of default language, just copy required json file, name it with your name (f.e. "en.json" -> "en_my.json") and change texts on your own. Don't forget to set new language code in your action (so for our example it would be "YOUR_NODE_SERVER/broker?phrase={{TextField}}&lang=en_my"). Format of one lanuage's json file record is simple:

"<HelperHandlerName>": "<regular expression to match and extract parameters>"

For more variants of single handler just use suffix ":<whatever_unique>", so in case of second variant of kodiPlayMovie handler it would be "kodiPlayMovie:1", for third "kodiPlayMovie:2" and so on. Don't forget, that records on the top of file have greater priority than on the bottom. If broker finds match on the top, it does not continue to the bottom.

Full table with available actions

Type of phrase phrase url
Say a phrase with a text ingredient Kodi play $ YOUR_NODE_SERVER/playmovie?q={{TextField}} *delay
Say a phrase with a text ingredient Kodi resume $ YOUR_NODE_SERVER/resumemovie?q={{TextField}} *delay
Say a simple phrase Kodi play file YOUR_NODE_SERVER/playfile?q=path/to/file *delay
Say a phrase with a text ingredient Kodi play a random [$] movie [of year #] YOUR_NODE_SERVER/playrandommovie?genre={{TextField}}&year={{NumberField}} *delay
Say a phrase with a text ingredient Kodi play an episode of $ YOUR_NODE_SERVER/playtvshow?q={{TextField}} *delay
Say a phrase with a text ingredient Kodi resume an episode of $ YOUR_NODE_SERVER/resumetvshow?q={{TextField}} *delay
Say a phrase with a text ingredient Kodi binge watch $ YOUR_NODE_SERVER/bingewatchtvshow?q={{TextField}}
Say a phrase with both a number and a text ingredient Kodi play $ episode # YOUR_NODE_SERVER/playepisode?q={{TextField}}&e= {{NumberField}}
Say a simple phrase Kodi play new episode YOUR_NODE_SERVER/playrecentepisode
Say a simple phrase Kodi pause YOUR_NODE_SERVER/playpause
Say a simple phrase Kodi unpause YOUR_NODE_SERVER/playpause
Say a simple phrase Kodi stop YOUR_NODE_SERVER/stop
Say a simple phrase Kodi mute YOUR_NODE_SERVER/mute
Say a simple phrase Kodi unmute YOUR_NODE_SERVER/mute
Say a phrase with a number Kodi set volume # YOUR_NODE_SERVER/volume?q={{NumberField}}
Say a phrase with a number
Say a simple phrase
Kodi volume up by #
Kodi volume up
YOUR_NODE_SERVER/volumeup?q={{NumberField}}
YOUR_NODE_SERVER/volumeup
Say a phrase with a number
Say a simple phrase
Kodi volume down by #
Kodi volume down
YOUR_NODE_SERVER/volumedown?q={{NumberField}}
YOUR_NODE_SERVER/volumedown
Say a phrase with a text ingredient Kodi switch to $ channel YOUR_NODE_SERVER/playtvchannelbyname?q={{TextField}}
Say a phrase with a number Kodi switch to channel number # YOUR_NODE_SERVER/playtvchannelbynumber?q={{NumberField}}
Say a phrase with a text ingredient Kodi switch to $ radio channel YOUR_NODE_SERVER/playradiochannelbyname?q={{TextField}}
Say a phrase with a number Kodi switch to radio channel number # YOUR_NODE_SERVER/playradiochannelbynumber?q={{NumberField}}
Say a simple phrase Kodi activate YOUR_NODE_SERVER/activatetv
Say a simple phrase Kodi standby YOUR_NODE_SERVER/standbytv
Say a simple phrase Kodi shutdown YOUR_NODE_SERVER/shutdown
Say a simple phrase Kodi hibernate YOUR_NODE_SERVER/hibernate
Say a simple phrase Kodi reboot YOUR_NODE_SERVER/reboot
Say a simple phrase Kodi suspend YOUR_NODE_SERVER/suspend
Say a phrase with a text ingredient Kodi shuffle $ YOUR_NODE_SERVER/shuffleepisode?q={{TextField}}
Say a phrase with a text ingredient Kodi play youtube $ YOUR_NODE_SERVER/playyoutube?q={{TextField}}&max=15
Say a phrase with a text ingredient Kodi search youtube $ YOUR_NODE_SERVER/searchyoutube?q={{TextField}}
Say a simple phrase Kodi scan library YOUR_NODE_SERVER/scanlibrary
Say a simple phrase Kodi clean library YOUR_NODE_SERVER/cleanlibrary
Say a phrase with a number
Say a simple phrase
Kodi Navigate up #
Kodi Navigate up
YOUR_NODE_SERVER/navup?q={{NumberField}}
YOUR_NODE_SERVER/navup
Say a phrase with a number
Say a simple phrase
Kodi Navigate down #
Kodi Navigate down
YOUR_NODE_SERVER/navdown?q={{NumberField}}
YOUR_NODE_SERVER/navdown
Say a phrase with a number
Say a simple phrase
Kodi Navigate left #
Kodi Navigate left
YOUR_NODE_SERVER/navleft?q={{NumberField}}
YOUR_NODE_SERVER/navleft
Say a phrase with a number
Say a simple phrase
Kodi Navigate right #
Kodi Navigate right
YOUR_NODE_SERVER/navright?q={{NumberField}}
YOUR_NODE_SERVER/navright
Say a phrase with a number
Say a simple phrase
Kodi Navigate back #
Kodi Navigate back
YOUR_NODE_SERVER/navback?q={{NumberField}}
YOUR_NODE_SERVER/navback
Say a simple phrase Kodi select YOUR_NODE_SERVER/navselect
Say a simple phrase Kodi show context menu YOUR_NODE_SERVER/navcontextmenu
Say a simple phrase Kodi go home YOUR_NODE_SERVER/navhome
Say a simple phrase Kodi whats playing YOUR_NODE_SERVER/displayinfo
Say a phrase with a text ingredient Kodi show $ YOUR_NODE_SERVER/showWindow?q={{TextField}}
Say a phrase with a text ingredient Kodi show movie genre $ YOUR_NODE_SERVER/showMovieGenre?q={{TextField}}
Say a phrase with a text ingredient Kodi execute addon $ YOUR_NODE_SERVER/executeAddon?q={{TextField}}
Say a phrase with a text ingredient Kodi subtitles $ YOUR_NODE_SERVER/setsubtitles?q={{TextField}}
Say a phrase with a number Kodi subtitles direct select # YOUR_NODE_SERVER/setsubtitlesdirect?q={{NumberField}}
Say a phrase with a text ingredient Kodi audio stream $ YOUR_NODE_SERVER/setaudio?q={{TextField}}
Say a phrase with a number Kodi audio stream direct select # YOUR_NODE_SERVER/setaudiodirect?q={{NumberField}}
Say a phrase with a number
Say a simple phrase
Kodi seek forward # minutes
Kodi seek forward
YOUR_NODE_SERVER/seekforwardminutes?q={{NumberField}}
YOUR_NODE_SERVER/seekforwardminutes
Say a phrase with both a number and a text ingredient Kodi seek forward $ hour and # minutes YOUR_NODE_SERVER/seekforwardminutes?q={{NumberField}}&hours={{TextField}}
Say a phrase with a number
Say a simple phrase
Kodi seek backward # minutes
Kodi seek backward
YOUR_NODE_SERVER/seekbackwardminutes?q={{NumberField}}
YOUR_NODE_SERVER/seekbackwardminutes
Say a phrase with both a number and a text ingredient Kodi seek backward $ hour and # minutes YOUR_NODE_SERVER/seekbackwardminutes?q={{NumberField}}&hours={{TextField}}
Say a phrase with a number Kodi seek to # minutes YOUR_NODE_SERVER/seektominutes?q={{NumberField}}
Say a phrase with a text ingredient Kodi play the song $ YOUR_NODE_SERVER/playsong?q={{TextField}}
Say a phrase with a text ingredient Kodi play the album $ YOUR_NODE_SERVER/playalbum?q={{TextField}}
Say a phrase with a text ingredient Kodi shuffle the album $ YOUR_NODE_SERVER/shufflealbum?q={{TextField}}
Say a phrase with a text ingredient Kodi play the artist $ YOUR_NODE_SERVER/playartist?q={{TextField}}
Say a phrase with a text ingredient Kodi play the music genre $ YOUR_NODE_SERVER/playgenre?q={{TextField}}
Say a phrase with a text ingredient Kodi play playlist $ YOUR_NODE_SERVER/playplaylist?q={{TextField}}
Say a phrase with a text ingredient Kodi playlist $ YOUR_NODE_SERVER/playercontrol?q={{TextField}}
Say a simple phrase Kodi toggle party mode YOUR_NODE_SERVER/togglePartymode
Say a phrase with a text ingredient Kodi open $ from my favourites YOUR_NODE_SERVER/playfavourite?q={{TextField}}
Say a phrase with a text ingredient Kodi open $ from my tvshows YOUR_NODE_SERVER/opentvshow?q={{TextField}}
Say a phrase with a text ingredient Kodi open $ from my movies YOUR_NODE_SERVER/openmovie?q={{TextField}}
Say a simple phrase Kodi toggle fullscreen YOUR_NODE_SERVER/togglefullscreen
Say a phrase with a text ingredient Kodi load profile $ YOUR_NODE_SERVER/loadProfile
Say a simple phrase Kodi play tagesschau YOUR_NODE_SERVER/tagesschau/playTodaysBroadcast
Say a phrase with a text ingredient Kodi play $ of directory YOUR_NODE_SERVER/playItemOfDirectory?directory=%2Fstorage%2Fkaraoke%2F&q={{TextField}

To Start/resume a movie/tv episode with a delay The commands marked with *delay (above) take an optional delay parameter to delay startup of the media by the specified number of seconds.

For example:
YOUR_NODE_SERVER_/playmovie?q=Deadpool&delay=10

To Turn on/off the TV and switch Kodi's HDMI input

  • This requires Kodi 17 (Krypton) and above

  • This also requires that both your kodi device and TV support CEC commands

  • You need to install this script.json-cec add-on: Download and move it to your kodi device and then in Kodi choose Settings>Add-ons>Install from zip file > choose the zip your just downloaded.

  • Finally you can use this in 2 ways:

    • Turn on: Add another command: follow the same instructions as pause but use this URL:

    YOUR_NODE_SERVER/activatetv

    • If host your server on Glitch, add the following line to your .env file (see step B.1 - (5) above) and kodi will automaticly turn on the tv and switch the HDMI input everytime your trigger the main playing actions (play a move / tv show / episode / pvr channel)

    ACTIVATE_TV="true"

    • If you host your server yourself (see step B.2 - (7) above), then add the following line at the end of your kodi-hosts.config.js file instead

    process.env['ACTIVATE_TV'] = 'true';

    • Turn off: Add another command: follow the same instructions as pause but use this URL:

    YOUR_NODE_SERVER/standbytv


Testing language files

When testing language files present in test/broker/<lang_code>.json, you can define a config key used when handling the request.

The config key can be defined for the entire endpoint :

  {
    "endpoint": "kodiPlayTvChannelByName",
    "phrases": [
      // config is inherited from endpoint
      { "phrase": "change la télé sur m6", "q": "m6" },
    ],
    "config": {
      "brokerAccentInsensitiveMatch": true
      "brokerLanguageCacheEnable": false
    }
  }

The config key can also be defined for a given phrase and take precedence on endpoint config :

  {
    "endpoint": "kodiPlayTvChannelByName",
    "phrases": [
      // config from phrase overrides endpoint config
      { "phrase": "change la télé sur m6", "q": "m6", "config": { "brokerAccentInsensitiveMatch": false },
    ],
    "config": {
      "brokerAccentInsensitiveMatch": true
      "brokerLanguageCacheEnable": false
    }
  }

Troubleshooting

If your can't preform a simple action like pausing a video, try to narrow down to problem. Execute the following tests in their listed order! Since early errors can make all following tests fail.

  1. Try getting your current kodi volume by entering this in your browser:
    http://YOUR_INTERNAL_KODI_IP:PORT/jsonrpc?request={"jsonrpc":"2.0","method":"Application.GetProperties","params":{"properties":["volume"]},"id":1}

    • If you get prompt to enter username and password choose the ones you set in Kodi (also known as YOUR_KODI_USER_NAME and YOUR_KODI_PASSWORD).
    • If that doesn't work, repeat/check all steps in section A!
  2. For hosting-scenario B.1 only Try getting your current kodi volume by entering this in your browser with your external IP: Note: This test is only meaningful, if done from outside of your home network! (i.e. Smartphone with disabled Wifi!)
    http://YOUR_EXTERNAL_IP:PORT/jsonrpc?request={"jsonrpc":"2.0","method":"Application.GetProperties","params":{"properties":["volume"]},"id":1}

    • If that doesn't work you probably have a problem with your router port forwarding configuration. Check the internet on how to properly forward a port from a local host to the internet for your router model.
  3. For hosting-scenarios B.2 & B.3 only Open the following URL in your browser on your local home network:
    http://YOUR_INTERNAL_NODE_IP:8099/

    • Does a page load asking for your token? (aka YOUR_CONNECTION_PASSWORD)
    • If the page doesn't load, your node server is currently not running or is not reachable.
      Repeat/check all the steps in section B!
  4. Open the YOUR_NODE_SERVER Url in a browser.
    Note: This test is only meaningful, if done from outside of your home network! (i.e. Smartphone with disabled Wifi!)
    i.e. http://omertu.selfhost.me:8099/

    • Does a page load asking for your token? (aka YOUR_CONNECTION_PASSWORD)
    • If that doesn't work you probably have a problem with your router port forwarding configuration. Check the internet on how to properly forward a port from a local host to the internet for your router model.
  5. Open the YOUR_NODE_SERVER Url in a browser and provide the token (aka YOUR_CONNECTION_PASSWORD).
    i.e. http://omertu.selfhost.me:8099/
    Ensure /koditestconnection is set as the route to test.
    Click Execute!

    • If a popup appears on your kodi box, all went well.
    • If not try make sense of the red error message. But its most likely a configuration error in the node app.
      So check if the kodi- username, password, ip and port are correctly configured.
      If you cannot find the error open an issue on github. Tell us there your choosen hosting scenario (B.1, B.2 or B.3) and attach the console output of the node app, after fully completing the execution the test-route.
  6. If all tests were successful so far, the problem is probably the configuration of the IFTTT-Applet itself.

    • Ensure the body is json
    • Ensure the method is POST
    • Ensure the token is in regular quotes " (iphones tend to mess them up, use a PC then)
    • If you cannot find the error open an issue on github. Tell us there your choosen hosting scenario (B.1, B.2 or B.3) and attach the console output of the node app, after fully completing the execution the applet.
  7. Whaat? How did you manage to pass all previous tests and yet still have trouble?
    Go to github, open an issue and explain yourself!


Credits

Thanks for everyone who contributed to this projects: p0psicles, keydon, Keljian and Lunatixz

I also used some code from these 3 projects: MarvinSchenkel/HomeyKodi Jephuff/kodi-rpc joshjowen/script.json-cec

And this wonderful website makes setting this up super easy - Glitch


Made by Omer Turgeman

I hope you find this helpful! If you'd like, you can give me a cup of coffee :)

Donate