How To Control Kodi With The Google Home On The AppeTV [FREE]

5:33 AM



Referral 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

  1. In Kodi, go to Settings >> Web server
  2. Set Allow remote contorl via HTTP to On
  3. Choose a port number (e.g. 8080).
  4. Choose a username and password (Important!)
  5. 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)
  6. 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.
  1. 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 
  1. Go to Glitch.com and sign in with your github user
  2. Create a new Glitch project and under advance settings choose Import from GitHub
  3. Enter this project OmerTu/GoogleHomeKodi
  4. Change Glitch project settings to private (under share > Make private)
  5. 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.
  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)

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)

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:
    1. Method: POST
    2. Content Type: application/json
    3. 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)

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 phrasephraseurl
Say a phrase with a text ingredientKodi play $YOUR_NODE_SERVER/playmovie?q={{TextField}}
Say a phrase with a text ingredientKodi resume $YOUR_NODE_SERVER/resumemovie?q={{TextField}}
Say a phrase with a text ingredientKodi play a random [$] movie [of year #]YOUR_NODE_SERVER/playrandommovie?genre={{TextField}}&year={{NumberField}}
Say a phrase with a text ingredientKodi play an episode of $YOUR_NODE_SERVER/playtvshow?q={{TextField}}
Say a phrase with both a number and a text ingredientKodi play $ episode #YOUR_NODE_SERVER/playepisode?q={{TextField}}&e= {{NumberField}}
Say a simple phraseKodi play new episodeYOUR_NODE_SERVER/playrecentepisode
Say a simple phraseKodi pauseYOUR_NODE_SERVER/playpause
Say a simple phraseKodi stopYOUR_NODE_SERVER/stop
Say a simple phraseKodi muteYOUR_NODE_SERVER/mute
Say a phrase with a numberKodi 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 ingredientKodi switch to $ channelYOUR_NODE_SERVER/playpvrchannelbyname?q={{TextField}}
Say a phrase with a numberKodi switch to channel number #YOUR_NODE_SERVER/playpvrchannelbynumber?q={{NumberField}}
Say a simple phraseKodi activateYOUR_NODE_SERVER/activatetv
Say a simple phraseKodi standbyYOUR_NODE_SERVER/standbytv
Say a simple phraseKodi shutdownYOUR_NODE_SERVER/shutdown
Say a phrase with a text ingredientKodi shuffle $YOUR_NODE_SERVER/shuffleepisode?q={{TextField}}
Say a phrase with a text ingredientKodi youtube play $YOUR_NODE_SERVER/playyoutube?q={{TextField}}
Say a simple phraseKodi scan libraryYOUR_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 phraseKodi selectYOUR_NODE_SERVER/navselect
Say a simple phraseKodi show context menuYOUR_NODE_SERVER/navcontextmenu
Say a simple phraseKodi go homeYOUR_NODE_SERVER/navhome
Say a simple phraseKodi whats playingYOUR_NODE_SERVER/displayinfo
Say a phrase with a text ingredientKodi show $YOUR_NODE_SERVER/showWindow?q={{TextField}}
Say a phrase with a text ingredientKodi subtitles $YOUR_NODE_SERVER/setsubtitles?q={{TextField}}
Say a phrase with a numberKodi subtitles direct select #YOUR_NODE_SERVER/setsubtitlesdirect?q={{NumberField}}
Say a phrase with a text ingredientKodi audio stream $YOUR_NODE_SERVER/setaudio?q={{TextField}}
Say a phrase with a numberKodi 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 numberKodi seek to # minutesYOUR_NODE_SERVER/seektominutes?q={{NumberField}}
Say a phrase with a text ingredientKodi play the song $YOUR_NODE_SERVER/playsong?q={{TextField}}
Say a phrase with a text ingredientKodi play the album $YOUR_NODE_SERVER/playalbum?q={{TextField}}
Say a phrase with a text ingredientKodi play the artist $YOUR_NODE_SERVER/playartist?q={{TextField}}
Say a phrase with a text ingredientKodi 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

  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

Troubleshooting

If your can't preform a simple action like pausing a video, try to narrow down to problem:
  1. 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.
  1. 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.
  1. If it does work, there might be something wrong in your glich or IFTTT settings.

Credits

Thanks for everyone who contributed to this projects: p0psicleskeydonKeljian 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

You Might Also Like

0 comments

Popular Posts

Like us on Facebook

Flickr Images