OmerTu / GoogleHomeKodi

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

IFTTT and Glitch Question #307

Open outdoor720 opened 4 years ago

outdoor720 commented 4 years ago

@keydon @OmerTu If i've read correctly IFTTT does not work with Glitch any longer?

What do you suggest as an alternative and easy way to get IFTTT to trigger Kodi commands?

harlekinrains commented 4 years ago

I've posted a temporary workaround on the kodi forums, if you want it to work currently: https://forum.kodi.tv/showthread.php?tid=314096&pid=2961230#pid2961230

It probably would be preferable to buy a RaspPi and start hosting it yourself via docker at this point though. :)

keydon commented 4 years ago

I dont know about glitch and their plans. If the problem persists I will just remove them from the readme soon. Other known hosting options are described in the readme. pick one. Or if you find alternatives to glitch out there, please share.

RonnieBoy82 commented 4 years ago

Should be able to set up on Repl.it but I am not a coder. If someone gets it working, please let me know

RonnieBoy82 commented 4 years ago

Ok, have simple commands working on repl.it. Can’t get any commands with text fields to work. Please help

RonnieBoy82 commented 4 years ago

Number fields are ok but text fields bring back a 500 error on ifttt

RonnieBoy82 commented 4 years ago

Ok got this all working on repl.it. Make sure to install packages

outdoor720 commented 4 years ago

Ok got this all working on repl.it. Make sure to install packages

RonnieBoy,

Sorry i don't see a specific solution? is the Repl.it link supposed to take me to some coded repository that reproduces what glitch did?

RonnieBoy82 commented 4 years ago

Repl.it is a website offering an alternative to glitch. Can import the project from GitHub just like glitch. Can’t help with the setup though. I don’t know coding but a friend managed to get it to work right for me

harlekinrains commented 4 years ago

Its not as easy as setting it up on repl.it via the github import, adding the .env variables and hit run. So when you can, could you ask your friend how he set it up. Any additional pointers would be helpful.

(By default it runs under node.js (nom start)) and errors out when trying to launch the start script. :)

RonnieBoy82 commented 4 years ago

No env file. Put that info in the kodi-hosts.config.js.dist file and rename the file to remove the .dist. Basically the instructions for setting up a local server instead.

RonnieBoy82 commented 4 years ago

And I just leave the page open on my phone to ensure it stays live. Not sure if it’s necessary.

RonnieBoy82 commented 4 years ago

You also need to do “npm install” in the console for the packages to install.

harlekinrains commented 4 years ago

Works. Thank you so much. :)

edit: Here is a short write up for everyone else trying to get it to work. Create an account with repl.it (or use your github account to authenticate).

Click on 'My Repls', '+ new repl', import from github. Enter the github address ( https://github.com/OmerTu/GoogleHomeKodi ). Wait a while for the project to be downloaded and set up. repl.it will automatically identify it as a node.js project, click ok on that dialog box.

Replace the settings you would set in the .env file for a glitch.com installation in the kodi-hosts.config.js.dist file, as described above. Then rename that file to kodi-hosts.config.js

Type npm install into the shell/terminal window on screen, hit enter and wait a while.

Then hit the run button at the top of the site. At this point your 'test your connection to kodi' interface should pop up and already work. That interface sports a link at the top - this is the link you have to feed IFTTT instead of the glitch link (with /command (f.e. /playpause) at the end where necessary).

Works like a charm. :)

RonnieBoy82 commented 4 years ago

Thank you for doing that walk through. I was trying but where I worked at it then had another guy work at it over the course of 4 days I wasn’t sure if everything that was done. Collaboration gets things done. Now that walk through just needs to get put in the main instructions

outdoor720 commented 4 years ago

Works. Thank you so much. :)

edit: Here is a short write up for everyone else trying to get it to work. Create an account with repl.it (or use your github account to authenticate).

Click on 'My Repls', '+ new repl', import from github. Enter the github address ( https://github.com/OmerTu/GoogleHomeKodi ). Wait a while for the project to be downloaded and set up. repl.it will automatically identify it as a node.js project, click ok on that dialog box.

Replace the settings you would set in the .env file for a glitch.com installation in the kodi-hosts.config.js.dist file, as described above. Then rename that file to kodi-hosts.config.js

Type npm install into the shell/terminal window on screen, hit enter and wait a while.

Then hit the run button at the top of the site. At this point your 'test your connection to kodi' interface should pop up and already work. That interface sports a link at the top - this is the link you have to feed IFTTT instead of the glitch link (with /command (f.e. /playpause) at the end where necessary).

Works like a charm. :)

So does this work for any command or only play?

harlekinrains commented 4 years ago

Tested it with my custom german setup on IFTTT (using all kinds of /somethingsomething commands). Seems to work with all of them (tested /playpause /playyoutube (with a custom Kodi API key (changed in kodi-hosts.config.js ) /stop /koditestconnection - all of them worked).

harlekinrains commented 4 years ago

Only issue so far is, that the server stops running the code after a certain amount of time, so you'd have to press "run" again on the project once in a while when you want to use it.

Having the website open on a smartphone like suggested is a workaround that might be workable. :)

RonnieBoy82 commented 4 years ago

Works for all commands and leaving the site open does work.

harlekinrains commented 4 years ago

Good to know - might have been my smartphone going into deep sleep, or me connecting from a second machine in between and then letting that one (laptop) go to sleep as well.

RonnieBoy82 commented 4 years ago

Even after a few hours I refreshed the page and the run button was there again but the voice commands still work. Little lag every now and again. Free service so should expect that

harlekinrains commented 4 years ago

I had a connection interrupted message there, and the voice commands had stopped working. This might be my brand of android rom (chinese vendor, known to kill processes in the background, or at least not allow them to wake up the device radio (/wlan) in deep sleep, to save battery), or it might have been, that I loaded up the instance from a laptop in between. But it is encouraging to hear, that it stays up for several hours (and potentially more) in your case. :)

outdoor720 commented 4 years ago

Do have to create separate ifttt applets for each command?

RonnieBoy82 commented 4 years ago

That’s the way I set it up. Worth it for customizing your commands and what google home says in response. Also I already had the ability to control volume and play/pause/stop with my Xbox that I use for Kodi so I didn’t set those commands up. Only the commands I actually use.

RonnieBoy82 commented 4 years ago

I leave repl.it open in the background on my phone and even after no commands all night, still working this morning without restarting

harlekinrains commented 4 years ago

Same here (left it open in a Chrome tab on my android phone in the background over night). :) Yay. :)

Also, everyone setting this up - would probably benefit from making a shortlink to the repl.it project page (where you can press start), I did it on my own domain/website, but bit.ly or something similar would work just as well. :)

outdoor720 commented 4 years ago

I was able to get pipedream to work as well without having to have anything open or copy repository. It works through existing Glitch. And Apparently it should be not too difficult to setup with variable IFTTT command.

I just don't know coding, so need assistance on that part

Here is what i have:

// Make an HTTP GET request using axios const resp = await axios({ method: "POST", url: https://xxxxliving.glitch.me/navdown, headers: { "Content-Type": "application/json" }, data: {"token":"xxxx"} } ); await sleep(5000); await axios({ method: "POST", url: https://xxxxliving.glitch.me/navdown, headers: { "Content-Type": "application/json" }, data: {"token":"xxxx"} } ); function sleep(ms) { return new Promise((resolve) => { setTimeout(resolve, ms); }); }

Now, apparently something like the following should work with variable. Capturing the variable in pipedream and sending it off??? Again i'm not a coder, so don't really understand what all the lines are doing.

axios({ method: "POST", url: 'https://enx8tqg2l75z97k.m.pipedream.net/phrase=${event.body.myvariabletext}', headers: { "Content-Type": "application/json" }, data: {"token":"xxxx"}, });

harlekinrains commented 4 years ago

Simple answer to the last posting - I'm not a coder either. :) To send the 'dynamic' output from ifttt (words it recognized) to any other service via post/json, and then have that service (pipedream) resend the 'dynamic' output to the glitch server via post/json actual coding is needed. The part that you have doesnt do that. We dont have that. Someone would have to code that. (If the workaround IFTTT>pipedream>glitch should work with 'dynamic' voice inputs (not setting up several IFTTT applets, just using the one that dynamically parses what you say.))

I dont even know if that works. (The sending the dynamic variable from IFTTT to pipedream via post/json part).

Repl.it is preferable. (Glitch takes much longer to respond, when the project is hybernating.) I've removed all my pipedream integrations except for the last one (press info twice with a 5s delay in between) in the Kodi forum thread ( https://forum.kodi.tv/showthread.php?tid=314096&page=14 ) which I've now connected to repl.it instead of glitch.

Having to press the play button on your smartphone for repl.it once a day (or less) is the far better compromise, compared with piping IFTTT to pipedream, and then to glitch.

I'm positive.. ;)

outdoor720 commented 4 years ago

I never had a problem with glitch until it atopped workong completely

I know ifttt can send a variable to pipestream i tested it and could see it coming in within pipestream

harlekinrains commented 4 years ago

The project on repl.it stayed active for me now even two days after I just actively visited the project site (website opened in a background chrome tab on my smartphone and started from there). This solution is very workable. :)

RonnieBoy82 commented 4 years ago

I’m finding that I only have to restart if I take my phone off my wifi.

Brunathaur commented 4 years ago

Hello. I have an issue server returned a 500 in IFTTT. Can you help me please?

RonnieBoy82 commented 4 years ago

Did you use the instructions from this thread to setup on repl.it?

harlekinrains commented 4 years ago

Do you get the test page on ripl.it? Does it send commands successfully? If so, try with one of the /somethingsomething (f.e. /playpause) urls first, and set up IFTTT exactly like in the glitch tutorial, so dont forget to send the token as well.

Server url is literally the one obove the test page on repl.it - there should be no other potential sources for errors.

Brunathaur commented 4 years ago

Hello. Thanks for your help. The test page send commands successfully. It is written on my tv. Today, it's "server returned a 403" when I try "kodi play $" and "server returned a 500" when I try to play favorites.. Thanks again for your help. Best regards

harlekinrains commented 4 years ago

Make sure to also fill out the exports.globalConfig part of the kodi-hosts.config.js 👍 image

And try to set up IFTTT with a static command first - see here for /playpause: image (English instead of german is fine)

The dynamic command for play (instead of playpause) should be /playmovie?q={{TextField}}

Apart from that it should look exactly the same.

Most likely stumbling block is you actually not having filled out the kodi token part of the kodi-hosts config.. ;)

Brunathaur commented 4 years ago

Thanks. Finally, I forget to change glitch to rpl to test play.mohie. I have this message now : Unable to make web request: Error: write EPROTO 139732644448064:error:14077438:SSL routines:SSL23_GET_SERVER_HELLO:tlsv1 alert internal error:../deps/openssl/openssl/ssl/s23_clnt.c:757: I don't understand, everything worked very well with glitch...

Brunathaur commented 4 years ago

Thanks for your help, harlekinrains

harlekinrains commented 4 years ago

Open ssl error? Beats me.. ;)

Thats the https part of the repl.co address. Make sure you have written the address correctly. Try to replace https with http maybe. :) That error message would have to do with a config error on repl.co's part - which would be highly unlikely.. ;)

Also, if you have changed the repl.it config file, restart the server (start button), just to be sure the changes 'took'. :)

Brunathaur commented 4 years ago

I have created the simple request playpause in IFTTT, and when I look history in IFTTT, there is nothing though I use it several times (with no result...)...

harlekinrains commented 4 years ago

I've set it up today again from scratch and it works.

One odd thing I came across was, that the https link above the "function test" website now had two -- in it as a separator, where the first time around it seemingly had a . as a separator. (See my link in the IFTTT screenshot) - I left in the . separator version in IFTTT, and it still worked.

Maybe the sequence of doing things is important (probably not). In my case I imported the github project, clicked on ok for it being autodetected as a jquery project, then edited the kodi-hosts.config.js.extensioniforgot, double checked to be filled out correctly. Then renamed it. Then typed npm install into the command prompt (waited for the install to finish), then hit the start button up top.

Then copied the link above the functionality test window. Replaced the two -- with a . added a /playpause at the end, and set up the IFTTT command with that.

As long as you tested the setup to work from the "test window", and you filled out the kodi-hosts.config.js correctly - everything should just work with the link above the test window (maybe with -- replaced with a . if applicable in your case).

You can also try to delete the project and set it up once more, but as long as the terminal on Repl.it doesnt throw error messages, not even that should be required.

Only additional things I did was, that I used Github OAuth to create my Repl.it account (create account using Github login), and authorized a Repl.it plugin to have read/write access to my github (the one it requires to be able to clone the project directly from Omertus Github).

No extra steps, and works in my case.

RonnieBoy82 commented 4 years ago

harlekinrains you should start a new thread with the instructions you have come up with. Make it easier for people to find

outdoor720 commented 4 years ago

so is this normal?

i get this after selecting the Run button (after NPM Install)

IFTTT command does not seem to work. is there a way to test a connection right from repl.it?

/home/runner/GoogleHomeKodi/kodi-hosts.config.js:22

store your secrets and config variables in here

^

SyntaxError: Invalid or unexpected token at wrapSafe (internal/modules/cjs/loader.js:1054:16) at Module._compile (internal/modules/cjs/loader.js:1102:27) at Object.Module._extensions..js (internal/modules/cjs/load er.js:1158:10) at Module.load (internal/modules/cjs/loader.js:986:32) at Function.Module._load (internal/modules/cjs/loader.js:87 9:14) at Module.require (internal/modules/cjs/loader.js:1026:19) at require (internal/modules/cjs/helpers.js:72:18) at Object. (/home/runner/GoogleHomeKodi/config.j s:12:18) at Module._compile (internal/modules/cjs/loader.js:1138:30) at Object.Module._extensions..js (internal/modules/cjs/load er.js:1158:10) npm ERR! code ELIFECYCLE npm ERR! errno 1 npm ERR! googlehomekodi@0.0.2 start: node server.js npm ERR! Exit status 1 npm ERR! npm ERR! Failed at the googlehomekodi@0.0.2 start script. npm ERR! This is probably not a problem with npm. There is like ly additional logging output above.

npm ERR! A complete log of this run can be found in: npm ERR! /home/runner/.npm/_logs/2020-07-30T22_09_41_794Z-debug.log exit status 1

outdoor720 commented 4 years ago

unless you pay, your repl.it is public so everyone can see?

harlekinrains commented 4 years ago

Yes. (Thats what I read as well.) Privacy issue.

(Keeping my fingers crossed that no one is personally targeting people in here. Type of no security mindset here on my part.)

Probably really should shell out for another RaspPi and put the docker image on at this point.

edit: That said, my account was far too easily guessable, so I switched it. Thank you for the nudge and the reminder.

harlekinrains commented 4 years ago

@outdoor720: Yes, once you've got the module running. If you get an error message on repl (yours errors out at reading the config.js which probably means that you have mistakenly typed something in that file instead of the kodi-hosts.config.js - or that your kodi-hosts.config.js isnt set up correctly), and you hit the start button, you should see the html "test your kodi connection" interface of OmerTu/GoogleHomeKodi that you are familiar with from Glitch.

In your case the program (scriptbundle) isnt running correctly, if it errors out on repl.it

Brunathaur commented 4 years ago

I've set it up today again from scratch and it works.

One odd thing I came across was, that the https link above the "function test" website now had two -- in it as a separator, where the first time around it seemingly had a . as a separator. (See my link in the IFTTT screenshot) - I left in the . separator version in IFTTT, and it still worked.

Maybe the sequence of doing things is important (probably not). In my case I imported the github project, clicked on ok for it being autodetected as a jquery project, then edited the kodi-hosts.config.js.extensioniforgot, double checked to be filled out correctly. Then renamed it. Then typed npm install into the command prompt (waited for the install to finish), then hit the start button up top.

Then copied the link above the functionality test window. Replaced the two -- with a . added a /playpause at the end, and set up the IFTTT command with that.

As long as you tested the setup to work from the "test window", and you filled out the kodi-hosts.config.js correctly - everything should just work with the link above the test window (maybe with -- replaced with a . if applicable in your case).

You can also try to delete the project and set it up once more, but as long as the terminal on Repl.it doesnt throw error messages, not even that should be required.

Only additional things I did was, that I used Github OAuth to create my Repl.it account (create account using Github login), and authorized a Repl.it plugin to have read/write access to my github (the one it requires to be able to clone the project directly from Omertus Github).

No extra steps, and works in my case.

Thanks harlekinrains, now it works, my listening port is 8080... strange I have another issue and it's for me the more important. I am a karaoke fan, and when i used glitch i said "chanter + song title" and it worked (all the araoke songs were in favourites" but now, i have this issue (it founds the good song but it fails). can you tell me what i must to do ?

Authentication succeeded ==== BEGIN === route: /playfavourite requested favourite: comment est à peine Sending command to kodi http://xxxxxxxxxx:8080/jsonrpc: { "jsonrpc": "2.0", "id": 1, "method": "Favourites.GetFavourites", "params": { "properties": [ "window", "path", "windowparameter" ] } } best fuzzy match for 'comment est à peine' is: { item: 'Benjamin Biolay - Comment est ta peine.mp4', refIndex: 1568, score: 0.7159876105334388 } request failed route: /playfavourite query: { q: 'comment est à peine' } error: TypeError: Cannot read property 'title' of undefined at playFavourite (/home/runner/GoogleHomeKodi/helpers.js:1394:60) at /home/runner/GoogleHomeKodi/helpers.js:1419:30 at processTicksAndRejections (internal/process/task_queues.js:97:5) body: { token: '1234' } versions: { node: '12.18.2', v8: '7.8.279.23-node.39', uv: '1.38.0', zlib: '1.2.11', brotli: '1.0.7', ares: '1.16.0', modules: '72', nghttp2: '1.41.0', napi: '6', llhttp: '2.0.4', http_parser: '2.9.3', openssl: '1.1.1g', cldr: '37.0', icu: '67.1', tz: '2019c', unicode: '13.0' } ==== END === route: /playfavourite

erbasandrade commented 4 years ago

Trabalho. Muito obrigado. :)

editar: Aqui está uma breve redação para todos os outros que estão tentando fazê-lo funcionar. Crie uma conta com repl.it (ou use sua conta github para autenticar).

Clique em 'My Repls', '+ new repl', importe do github. Digite o endereço do github ( https://github.com/OmerTu/GoogleHomeKodi ). Aguarde um pouco para que o projeto seja baixado e configurado. repl.it irá identificá-lo automaticamente como um projeto node.js, clique em ok nessa caixa de diálogo.

Substitua as configurações que você definiria no arquivo .env para uma instalação glitch.com no arquivo kodi-hosts.config.js.dist, conforme descrito acima. Em seguida, renomeie esse arquivo para kodi-hosts.config.js

Digite npm install na janela do shell / terminal na tela, pressione Enter e espere um pouco.

Em seguida, clique no botão Executar na parte superior do site. Neste ponto, sua interface 'teste sua conexão com o kodi' deve aparecer e já está funcionando. Essa interface apresenta um link no topo - este é o link que você tem para alimentar o IFTTT em vez do link de falha (com / command (fe / playpause) no final, quando necessário).

Funciona como um encanto. :)

I'm using coreelec! I think I did everything but forget some detail! I'm in Brazil can I help, check my settings? Via teamviewer! Thank you.

madmax2 commented 4 years ago

@harlekinrains my repl.it project is now showing failed to connect after I successfully got it to work yesterday etc..

seems like this site is not as responsive as glitch.me..

so sadly this is not a good alternative to glitch.me

harlekinrains commented 4 years ago

Mine still works perfectly, hadnt had to relaunch the project (opened in chrome on a smartphone in a tab in the background) in nearly a month. Responsiveness for me is about on par with glitch.com - but then your results may vary depending on where in the world you are located.. ;) (Central Europe in my case.)

So for me its a great alternative. 👍

'Failed to connect.' After it worked yesterday seems like an ISP IP address change, no? ;)

Brunathaur commented 4 years ago

harlekinrains, could you just test to open a favourite on kodi to tell me if you succeed ? thanks by advance