How To Control Kodi With The Google Home On The AppeTV [FREE]
5:33 AMReferral link to AppDB to install Kodi & other apps on AppleTV4K
The developers instructions to control Kodi with Google Home
MY EDITED INSTRUCTIONS(MY NOTES WILL BE IN RED & BOLD) :
How to setup
Disclaimer: Use on your own risk and choose complex username & password in the below steps.
A) Enable webserver access in kodi
- In Kodi, go to Settings >> Web server
- Set Allow remote contorl via HTTP to On
- Choose a port number (e.g. 8080).
- Choose a username and password (Important!)
- Configure your router to forward the port you selected to your kodi device
Note: Not needed if you decide to go with a local node webserver (B.2) - Find your external IP address (i.e. Google 'what's my ip?')
B) Set up a nodejs-webserver to control your kodi
We currently support three methods of how this app can be hosted.
- Hosting it in Glitch, a 3rd-party web-hosting service (I USED THIS OPTION)
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 prebuilt docker images.
B.1 Set up a webserver in Glitch
- Go to Glitch.com and sign in with your github user
- Create a new Glitch project and under advance settings choose Import from GitHub
- Enter this project OmerTu/GoogleHomeKodi
- Change Glitch project settings to private (under share > Make private)
- 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"
YOUR_CONNECTION_PASSWORD can be anything you want.
- 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)
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"
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.
- Having two node servers. Each targeting one instance. (Recommended when hosting with glitch)
i.e. the phraseliving room kodi play...
could targethttps://mylivingroom.glitch.com/playpause
and the phrasebedroom kodi play...
could targethttps://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)
- Configuring both kodi instances with different ports
- Note: Behind a single external IP the kodi instances need still to be distinguishable. This can be achieved in two ways:
- 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 phraseliving room kodi play...
could targethttp://192.168.100.1:8080/playpause
and the phrasebedroom kodi play...
could targethttp://192.168.100.2:8080/playpause
).
C.2 utilize the kodi-hosts.config.js (Click to expand instructions)
D) Set up IFTTT with your Google Home
- Go to IFTTT
- Create a new applet: if This then That
- For This choose: Google Assistance
- Choose Say a phrase with a text ingredient
- In What do you want to say? enter something like:
Kodi play movie $- In What do you want the Assistant to say in response? enter something like:
ok playing $ movie - For That choose: Maker Webhooks
- Choose Make a web request
- In URL enter:
YOUR_NODE_SERVER/playmovie?q={{TextField}}For example, if your node server address is 'green-icecream.glitch.me', your should enter:- Method: POST
- Content Type: application/json
- Body (enter the word token):
{"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)
Note: If your external IP changes, this will stop working (consider getting a static IP address)
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 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/playpvrchannelbyname?q={{TextField}}
For PVR TV support - Set channel by number, use "Say a phrase with a number" and the URL:
YOUR_NODE_SERVER/playpvrchannelbynumber?q={{NumberField}}
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}} |
Say a phrase with a text ingredient | Kodi resume $ | YOUR_NODE_SERVER/resumemovie?q={{TextField}} |
Say a phrase with a text ingredient | Kodi play a random [$] movie [of year #] | YOUR_NODE_SERVER/playrandommovie?genre={{TextField}}&year={{NumberField}} |
Say a phrase with a text ingredient | Kodi play an episode of $ | YOUR_NODE_SERVER/playtvshow?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 stop | YOUR_NODE_SERVER/stop |
Say a simple phrase | Kodi mute | 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/playpvrchannelbyname?q={{TextField}} |
Say a phrase with a number | Kodi switch to channel number # | YOUR_NODE_SERVER/playpvrchannelbynumber?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 phrase with a text ingredient | Kodi shuffle $ | YOUR_NODE_SERVER/shuffleepisode?q={{TextField}} |
Say a phrase with a text ingredient | Kodi youtube play $ | YOUR_NODE_SERVER/playyoutube?q={{TextField}} |
Say a simple phrase | Kodi scan library | YOUR_NODE_SERVER/scanlibrary |
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 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 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 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 play the artist $ | YOUR_NODE_SERVER/playartist?q={{TextField}} |
Say a phrase with a text ingredient | Kodi playlist $ | YOUR_NODE_SERVER/playercontrol?q={{TextField}} |
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- 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"- Turn off: Add another command: follow the same instructions as pause but use this URL:
YOUR_NODE_SERVER/standbytv
How to update to the latest version
- Go to Glitch.com and sign in with your github user
- Select your Glitch project and under advance settings choose Import from GitHub
- Enter this project OmerTu/GoogleHomeKodi
Troubleshooting
If your can't preform a simple action like pausing a video, try to narrow down to problem:
- While a video is being played in Kodi, try pausing it by entering this in your browser:
http://YOUR_INTERNAL_KODI_IP:PORT/jsonrpc?request={"jsonrpc":"2.0","id":1,"method":"Player.playpause","params":{"playerid":1}}
If you get prompt to enter username and password choose the ones you set in Kodi (step A above). If that doesn't work, you probably have a problem with your kodi setup.
- If that works, try pausing a video using your external IP:
http://YOUR_EXTERNAL_IP:PORT/jsonrpc?request={"jsonrpc":"2.0","id":1,"method":"Player.playpause","params":{"playerid":1}}
If that doesn't work you probably have a problem with your router configuration.
- If it does work, there might be something wrong in your glich or IFTTT settings.
Credits
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 :)
0 comments