I just came into this site after seeing a link to remix a multiple command IFTTT trigger for Google home. I’m not new to coding, I’ve done lots of it in the past with many languages but its been a while.
Anyway my question is: rather than executing the code in the server.js script right away, is it possible to add a timer to this?
So I have used setTimeout as you suggested. I have an error popping up in the log - why is this happening? I have a feeling it’s because I’m also passing a value to waitFunction, but how do I do that without an error?
I made some changes to see if that was why the error was popping up - and it was. But the problem still remains as to how I can pass something to waitFunction. I tried to do it using a global by placing a var statement at the top (which for rid of the errors) but that was just passing undefined (I’m not used to the way variables are handled in JS any more).
I have now changed it back to how it was originally so you guys can see where I’m going wrong with this. I won’t make any changes until someone suggests something
We figured this out together. If anyone is interested, there’s an example here of how to schedule delayed callbacks with different arguments in response to an HTTP request:
It turned out the problem was because of the timer delay. The variable triggerEvent was being overwritten by the function checkForTrigger with “undefined” before the waitFunction was being called.
As a solution, I stored triggerEvent in a new variable called theTriggerEvent immediately and accessed that in waitFunction instead.
Now you can set a list of up to 10 IFTTT commands (easy to expand to more if you wanted) and they will all be done after the time limit you set with the variable timeLimit at the top.
it seems like the code you developed is the one I need! however: the link in you last message is not correct: it links to the original multiple trigger ifttt code. Do you have the correct address?