I thought I’d take the opportunity to add a Google Home to my gadget collection. After all it’s on a £50 off same this week, so comes in at £79 delivered.
What I really want from it above all is to control my Kodi setup. Being able to voice control what movie or TV show to play would make the wife’s life a lot easier – and when she’s happy, I’m happy.
This is where I came across the GoogleHomeKodi project on GitHub and referenced on the Kodi forum here.
The connectivity to get Google Home to talk to Kodi is somewhat convoluted. There is no direct Google Home to Kodi link. This requires some cloud technology.
Google Home talks to IFTTT, IFTTT talks to the GoogleHomeKodi service, the GoogleHomeKodi service talks to Kodi.
So you need to setup an IFTTT (If This Then That) account and then install GoogleHomeKodi either onto the cloud or onto your own web server. Sounds complicated? It really isn’t that bad. The developers of GoogleHomeKodi have a pretty well documented process for much of it.
Instead of using the cloud install on Glitch, I chose to install the GoogleHomeKodi service onto my Synology NAS. You could install it onto pretty much anything that is capable of running Node.js including the Raspberry Pi you may have Kodi installed on.
First step on the Synology is to go into the Web UI Packages app and select to install Node.js v8 [beta]. This will give us the command line tool needed to run the GoogleHomeKodi program.
Then in the Synology Control Panel in Security open a Firewall port for 8099 so your Google Home can talk to it. You’ll also want to port forward it which you can also do in the Control Panel, Router Configuration as long as your router support UPNP.
Download and extract the GoogleHomeKodi ZIP file into an appropriate folder, I used /volume1/code
– as this made it easier to assign permissions to run it as a service later. It’ll extract into GoogleHomeKodi-master
by default.
Copy/rename and edit the config file kodi-hosts.config.js.dist
in the GoogleHomeKodi-master
folder so it is called kodi-hosts.config.js
. Change the details within it to match the details of your Kodi server.
Using SSH (Putty) logon to the Synology as admin and change to the GoogleHomeKodi-master
path and install the projects dependencies.
$ cd /volume1/code/GoogleHomeKodi-master $ npm install
Run the server service so you can then see it actually works when you send it instructions.
$ node server.js Loaded 1 hosts from the config.js Starting using kodi-hosts.config.js, {"authToken":"mymadeuptoken","listenerPort":"8099","youtubeKey":"AIzaSyBYKxhPJHYUnzYcdOAv14Gmq-43_W9_79w"} Your app is listening on port 8099
Then you can go about setting up your IFTTT recipes to point at the Synology server:
http://myname.synology.me:8099/[command]
Where myname.synology.me
could be an IP address. But it makes things much easier if you’ve registered to use Synology’s DDNS service – it’s free.
eg.
If you need to test things out before you get to speaking to your Google Home you can make these calls to the API using curl
. If you’re using a Raspberry Pi with OSMC you can use it from there.
$ curl -H "Content-Type: application/json" -X POST -d '{"token":"mymadeuptoken"}' http://myname.synology.me:8099/stop
You’ll see this on the output for the SSH session running server.js if you made a successful call. You’ll then also see Kodi carry out your command (as above) if you issue something like:
http://myname.synology.me:8099/playmovie?q=sleeping+beauty
Running as a Service
Now you just need to make the Node.js server.js run as a service or a background process.
I ensured that the proposed service account would have all the necessary permissions to run by placing the GoogleHomeKodi-master into /volume1/code and then setting the permissions using:
$ sudo chmod 777 -Rv /volume1/code
This may be a bit more than it needs, but it’ll do for now. You can tighten this up as necessary using your typical chown/chmod Linux commands.
Then using the guidance from an older blog post here:
http://majikshoe.blogspot.co.uk/2014/12/starting-service-on-synology-dsm-5.html
I created a file /etc/init/googlehomekodi.conf
so it would start as a service.
# only start this service after the network has started start on syno.network.ready stop on runlevel [06] # stop the service gracefully if the runlevel changes to 'reboot' stop on runlevel [06] # run the scripts as the 'http' user. Running as root (the default) is a bad idea. setuid http # exec the process. Use fully formed path names so that there is no reliance on $PATH exec /usr/local/bin/node /volume1/code/GoogleHomeKodi-master/server.js
Then to start it and ensure it stays running and stop it use:
$ sudo start googlehomekodi $ sudo status googlehomekodi googlehomekodi start/running, process 14378 $ sudo stop googlehomekodi
You can also look in your /var/log/messages
to see if anything fails.
References
http://majikshoe.blogspot.co.uk/2014/12/starting-service-on-synology-dsm-5.html
Thank you! This was perfect!
LikeLiked by 1 person
Thank you so much. I got this working for me but I could not get it server.js running automatically without having to run server.js via putty each time. This is really good and easy to follow info. Other things I picked up is to use myname.synology.me service instead of using a DynDNS service for my dynamic IP
Thanks again
LikeLiked by 1 person
Hi
I tried this. Now I could use putty and have the server.js running via sudo start googlehomekodi. However when the NAS is rebooted it never come on itself. Is it may be that the command is attempted before system is ready for it? Could you please advise. I would like this to work so that I could avoid to starting it manually every time I restart the NAS. I am running 213j and DMS 6+
LikeLike
The important part of the script is the line, which works hapily on my DS214play with DSM 6.1.4-15217 Update 5:
start on syno.network.ready
So it should fire up as soon as the network is up.
But I’ve also seen
start on syno.share.ready and syno.network.ready
So that may help.
Other pointers if you’re using another service like a webserver start it when that’s ready.
https://home-assistant.io/docs/autostart/synology/
LikeLike
Thanks
so could I give “start on syno.share.ready and syno.network.ready”. That is use “and” to join them?
LikeLike
I believe so, based on that article. But it’s not something I’ve used as mine works with just the `start on syno.network.ready`
That said my 214 updated yesterday at 20:00 and I couldn’t log into the Web UI as it just came up with “System not ready. Login again later.” I got an email today at 15:00 saying “DiskStation has finished checking the consistency on system volume (Root). The system is now ready for use.”. So I’ve only just got back in.
LikeLike
Thanks. Will give it a go..
One more question- Have you got 2 Kodi’s working? I could not get it working but followed the instructions. I asked the question here but no lucj yet https://forum.kodi.tv/showthread.php?tid=314096&page=8&highlight=google+home post #115
LikeLike
Sorry no. I only have one Kodi instance. It looks like your config is OK, but try running the googlehomekodi as an app on the Synology and not as a service. Then you get to see any error message that comes up. So you may discover what the 500 error actually is.
LikeLike
Thanks I figured out. After each config change need to npm install which update the changes. Also If you edit and rename already existing IFTT sometimes it does not work so need to create applet again. With this it is working like a charm. Instructions are 100% accurate it is just that if you try to amend the config.js file you need to npm install. This is not clear in the original instructions
LikeLike
Wondering if theres an update to the script. Cant get it to start automatically any longer! Thanks!
LikeLike
Hmm, been a week or so since I used it. But then probably been longer since I ran an update. Mainly because “if ain’t broke…” and it does all the commands I need.
I’ll revisit it and see if there’s something changed.
LikeLike
Disregard. Apparently after each update it wipes the /etc/init folder and I had to put it back in again and chmod and it worked. Thanks man.
LikeLike
Good to know. I was going to have a go at the weekend.
LikeLike
0 Pingbacks
Search this site
Categories
Recent Posts
Archives
Tag Cloud
active directory ajax ansible apache asterisk authentication azure backup bash Bootstrap certificates CoffeeScript debian dhcp dkim dns Docker electron electronics email esp32 esp8266 exim4 firewall ftp git gnome gulp horizon html5 iptables java jquery json juniper keycloak kodi kvm Laravel ldap manjaro mssql mysql nginx node.js nzbget oauth2 openvpn owncloud php postgis postgresql proxy python qemu radius raspberry pi ReactJS rsync Security single-sign-on smtp spf ssh ssl synology tomcat updates vmware vpn vue.js webpack wireguard xml xmpp