Either a wait command or a command trigger by no activity by Ring


#1

I am trying to create a new script for IFTTT. I currently have the weather app set to turn on the porch light at sunset with the light color being yellow to avoid bugs. I have another weather app set to turn off the porch light at sunrise. I also have my RING doorbell change the light to white if it detects motion. The problem is there is no way to change it back to yellow.

So basically what I need is some sort of wait command. This way when RING detects someone with its motion sensor it would trigger:

If during the hours of sunset and sunrise change the porch light to white

Wait 10 minutes

Change the porch light to yellow


#2

You could use setTimeout() to call a function later. Waiting 10 minutes will be problematic though, as Glitch projects sleep after 5 minutes of inactivity, but it sounds like it might be alright to reduce it in the use-case.

e.g.

function waitFunction() {
    // all the stuff you want to happen after that pause
    console.log('this should 3 seconds later');
}

// called after 3 seconds
setTimeout(waitFunction, 3000);

#3

hey i tried your code using the setTimeout. it doesn’t seem to work.


#4

It does work, I’d check your implementation of it. For reference, here’s a working example: https://glitch.com/edit/#!/gentle-wilderness


#5

hey this code is not working

> setTimeout(triggerEvent=process.env.IFTTT_EVENT_2, 10000);

if(trigger===2)
setTimeout(triggerEvent=process.env.IFTTT_EVENT_3, 20000);
if(trigger===3)
setTimeout(triggerEvent=process.env.IFTTT_EVENT_4, 30000);


#6

It’s recommended to put the code you want to call in a function, like in the example I supplied (Either a wait command or a command trigger by no activity by Ring).

Also, it looks like you’re working with our IFTTT example projects. The code you’re using isn’t likely to have the effect I think you want it to - all you’re doing is setting the triggerEvent value to a different one after x seconds, not actually running the trigger. So the updated value won’t been used until another POST request is received. If you’re trying to run additional events after a delay, you want to instead call checkForTrigger with the event ID you want in setTimeout.