OmerTu / GoogleHomeKodi

Control kodi via Google Home / Assistant
523 stars 163 forks source link

Help needed on running on a local webserver #42

Closed yguns31 closed 7 years ago

yguns31 commented 7 years ago

I am having some issues using the method of running on a local webserver. I was able to setup the local node.js server and got things configured in step B.2). So when I create the applets in IFTTT, what do I put into the argument instead of the Glitch URL? This is the part that I am stuck on.

p0psicles commented 7 years ago

You'll have to forward the port in your router. Just like how you needed to do that for your kodi api. And you can use your outside available ip address for that. For example if you outside ip is: 80.80.80.2, you'd want to use for the url: http://80.80.80.2/...

jojo1419 commented 7 years ago

I have the same trouble. I made it work with glitch but can't with the local node server. Also, when using http://external_ip/jsonrpc?request={%22jsonrpc%22:%222.0%22,%22id%22:1,%22method%22:%22Player.playpause%22,%22params%22:{%22playerid%22:1}} it doesnt work but with my internal it works.

So when creating the applets, what do you put instead of YOUR_GLITCH_SERVER_ADDRESS/playmovie?q= {{TextField}}.

would you put

http://MY_EXTERNAL_IP_ADDRESS:PORT/playmovie?q= {{TextField}}.

I tried and it doesnt work

p0psicles commented 7 years ago

If you check out the develop branch, there is a new route in there. /koditestconnection. It provides some more logging. As also shows a notification in kodi, if the connection is okay.

Can you try that one?

Stefan300381 commented 7 years ago

@jojo1419 Here is an example that works for me, my node js is running on port 8099

http://MYDNSNAME:8099/mute

or

http://MYDNSNAME:8099/playmovie?q={{TextField}}

Remember to set in IFTTT, method, content type and body. Additionally establish a port forwarding in your home router.

jojo1419 commented 7 years ago

@p0psicles Thanks I'll try that once I get home!

@Stefan300381 So for 'MYDSNNAME' would I put my external ip address??? but just to make sure I'm not mistaken. Let say I'm using kodi on my raspberry Pi with port 8099. I would need to port forward the ip address of the pi. let say (111.111.1.11) with port 8099. Then for the server.js I would edit the kodi-host.config.js with

exports.kodiConfig = [{ id: 'kodi', // For now leave the first set to kodi. // YOUR_EXTERNAL_IP_ADDRESS kodiIp: (let say : 123.456.789.123), // YOUR_KODI_PORT kodiPort: '8099', // YOUR_KODI_USER_NAME kodiUser: 'test', // YOUR_KODI_PASSWORD kodiPassword: 'testpassword'

exports.globalConfig = { // YOUR_CONNECTION_PASSWORD authToken: 'test', // YOUR_LOCAL_LISTENING_PORT listenerPort: '8099', // YOUR_YOUTUBE_API_KEY youtubeKey: 'AIzaSyBYKxhPJHYUnzYcdOAv14Gmq-43_W9_79w'

then on a terminal I run the server with 'node server.js'

And on IFTTT I would follow the same instructions

Stefan300381 commented 7 years ago

no, you are missing the port of the local web server. in my environment I have Kodi listening on port 8080 and nodejs runs on 8099. So in my router I have established a portforwarding to the local webserver, 8099. In the nodejs configuration file kodPort is set to 8080

MYDNSNAME can be in deed the external ip address. but in my case the external ip address changes every 24 hours. so I am using an external service that offers a DNS name like "myhomeaddress.dynv6.net". instead of entereing something like 80.112.3.55 I enter myhomeaddress.dynv6.net (in the nodejs config as well as in IFTTT)

jojo1419 commented 7 years ago

Crap! That's probly why it didn't work! I'll try again once I get home

Thanks :)

jojo1419 commented 7 years ago

@p0psicles

I had this : Request incomming for testing the end2end connectivity to kodi. (node:5736) UnhandledPromiseRejectionWarning: Unhandled promise rejection (rejection id: 2): You should configure an access token, to secure your app. (node:5736) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.

p0psicles commented 7 years ago

I think you don't have the token configured. I can add some error handling, that would show this.

p0psicles commented 7 years ago

Use the example.. exports.globalConfig = { // YOUR_CONNECTION_PASSWORD authToken: 'MyAuthTokenSharedWith_IFTTT_Applet', // YOUR_LOCAL_LISTENING_PORT listenerPort: '8099', // YOUR_YOUTUBE_API_KEY youtubeKey: 'AIzaSyBYKxhPJHYUnzYcdOAv14Gmq-43_W9_79w' };

jojo1419 commented 7 years ago

Is the token this part ? : // YOUR_CONNECTION_PASSWORD authToken: 'MyAuthTokenSharedWith_IFTTT_Applet',

Because I changed it to this : // YOUR_CONNECTION_PASSWORD authToken: 'test',

My port is 8099 and I didn't touch the YouTube.

With the server on I can go to http://my_internal_ip:8099 and it shows a page with Hello world. But when I try with my_external_ip:8099 it doesn't. But I checked with canyouseme to see if my port is open and it is

Stefan300381 commented 7 years ago

when you test with your external IP you should definitely see the hello world page, otherwise your port forwarding doesn't work. maybe you selected udp instead of tcp or entry port is different from forwarding port.

p0psicles commented 7 years ago

What's your ifttt.com configuration for the koditestconnection route? Using post with the correct body?

jojo1419 commented 7 years ago

@p0psicles when I put my internal ip so : http://192.168.2.15:8099/jsonrpc?request={%22jsonrpc%22:%222.0%22,%22id%22:1,%22method%22:%22Player.playpause%22,%22params%22:{%22playerid%22:1}}

I get : Cannot GET /jsonrpc

p0psicles commented 7 years ago

No, your config of ifttt.com.

jojo1419 commented 7 years ago

exports.kodiConfig = [{ id: 'kodi', // For now leave the first set to kodi. // YOUR_EXTERNAL_IP_ADDRESS kodiIp: '156.3x.2xx.xxx', // YOUR_KODI_PORT kodiPort: '8080', // YOUR_KODI_USER_NAME kodiUser: 'jojo', // YOUR_KODI_PASSWORD kodiPassword: 'jxxxxxxxx' } // You can use this to specify additonal kodi installation, that you'd like to control. // ,{id: 'bedroom', // For example the bedroom, will allow you to create IFTTT sentences like: okay google bedroom play .. // // YOUR_EXTERNAL_IP_ADDRESS // kodiIp: '192.168.1.18', // // YOUR_KODI_PORT // kodiPort: '8080', // // YOUR_KODI_USER_NAME // kodiUser: 'kodi', // // YOUR_KODI_PASSWORD // kodiPassword: 'myKodiPassword'} ];

exports.globalConfig = { // YOUR_CONNECTION_PASSWORD authToken: 'jojo2', // YOUR_LOCAL_LISTENING_PORT listenerPort: '8099', // YOUR_YOUTUBE_API_KEY youtubeKey: 'AIzaSyBYKxhPJHYUnzYcdOAv14Gmq-43_W9_79w' };

In IFTTT : URL : http://156.3x.2xx.xxx:8099/koditestconnection Method : GET Content Type : application/json Body : {"token":"jojo2"}

p0psicles commented 7 years ago

And you renamed the kodi-hosts.config.js.dist file to kodi-hosts.config.js? Only thing left to test is changing the GET to POST in ifttt.com. Rest looks OK.

jojo1419 commented 7 years ago

yes I did!, still wont work it with POST. Aw well, I play around with glitch.... Thanks alot everyone!!

p0psicles commented 7 years ago

If you want to try one last thing? I've added some error handling to the /koditestconnection route. So now, it should not show you the error: (node:5736) UnhandledPromiseRejectionWarning: Unhandled promise rejection (rejection id: 2):..., but something more meaningfull.

Also make sure that:

At least this should provide us with some more info.

jojo1419 commented 7 years ago

ok, downloaded the zip again. I checked my npm, everything is fine. got this in the command :

C:\Users\Joel>node C:\Users\Joel\Downloads\GoogleHomeKodi-develop\GoogleHomeKodi-develop\server.js Loaded 1 hosts from the config.js Starting using kodi-hosts.config.js, {"authToken":"jojo2","listenerPort":"8099","youtubeKey":"AIzaSyBYKxhPJHYUnzYcdOAv14Gmq-43_W9_79w"} Your app is listening on port 8099 Request incomming for testing the end2end connectivity to kodi. (node:6780) UnhandledPromiseRejectionWarning: Unhandled promise rejection (rejection id: 2): You should configure an access token, to secure your app.

p0psicles commented 7 years ago

Ok the error shows it's not getting the "token" in the body. This is what I have in IFTTT. image

Also what is your nodejs version?

jojo1419 commented 7 years ago

yeah it's weird it's not working, maybe something wrong with the port forward....

Node version 8.9.1

sveni-lee commented 7 years ago

I've the same problem... GooglehomeKodi is installed on a separat Linux server. Portforwarding is okay but I can't get it work...

exports.kodiConfig = [{ id: 'kodi', // For now leave the first set to kodi. // YOUR_EXTERNAL_IP_ADDRESS kodiIp: '192.168.1.103', // YOUR_KODI_PORT kodiPort: '8080', // YOUR_KODI_USER_NAME kodiUser: 'kodi', // YOUR_KODI_PASSWORD kodiPassword: 'test' } // You can use this to specify additonal kodi installation, that you'd like to control. // ,{id: 'bedroom', // For example the bedroom, will allow you to create IFTTT sentences like:okay google bedroom play ..` // // YOUR_EXTERNAL_IP_ADDRESS // kodiIp: '192.168.1.18', // // YOUR_KODI_PORT // kodiPort: '8080', // // YOUR_KODI_USER_NAME // kodiUser: 'kodi', // // YOUR_KODI_PASSWORD // kodiPassword: 'myKodiPassword'} ];

exports.globalConfig = { // YOUR_CONNECTION_PASSWORD authToken: 'xxx', // YOUR_LOCAL_LISTENING_PORT listenerPort: '4710', // YOUR_YOUTUBE_API_KEY youtubeKey: 'AIzaSyBYKxhPJHYUnzYcdOAv14Gmq-43_W9_79w' }; when try development brach I get the following error Error: Cannot find module './exceptions.js'`

p0psicles commented 7 years ago

Sorry, pull develop again. I've added the module. Please try again using this branch. The route /koditestconnection should provide the most info.

sveni-lee commented 7 years ago

thanks... server start now Starting using kodi-hosts.config.js, {"authToken":"test","listenerPort":"4710","youtubeKey":"AIzaSyBYKxhPJHYUnzYcdOAv14Gmq-43_W9_79w"} Your app is listening on port 4710

but when try http://myserver.de::4710 there is now "hallo world"

Stefan300381 commented 7 years ago

if you see hello world, then its running fine

sveni-lee commented 7 years ago

sorry was ma foult there is NO hello world

sveni-lee commented 7 years ago

okay... got it work thanks for that....

algouye commented 6 years ago

I have setup everything, using the local node js running. as if I am doing it manually connected directly to the node js server, I can enter playpause and the token set and it works fine however, when I trying to get ifttt; my applets getting skipped. I do not see any interaction from the node js console...

I have followed as described: using post + token as part of the body.

Any hint would be welcome..

keydon commented 6 years ago
  1. please open new issues instead of reopening old ones.
  2. ifttt needs to reach your local node.js server. So what URL are you using in your applets? It should have to use your external IP or dnyDNS. Your configured nods.js-Port with port forwarding setup in your router.