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?
The code can be seen here
Yes, something similar came up before, you can use setTimeout().
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?
Please see this link for code.
The error is:
TypeError: “callback” argument must be a function at exports.setTimeout (timers.js:327:11)
It looks like you got past this. If you’re still having trouble, let us know.
Hi thanks for the replies.
Sorry I’m still having trouble.
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:
Thanks for the help Tim.
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.
Tim that was such a bad way to do it anyway. I have done the same thing in a much cleaner way like this
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?
I am trying to activate a trigger, wait for 5 seconds, and activate another trigger. Is this possible? I am a freshman with glitch.
Thank you very much