Wait until something happens?


#1

Hey peeps,

Is there a way to WAIT UNTIL something happens?

What I’m trying to do is:
Turn light on in the morning.
Wait until front door is unlocked,
then wait until it locks,
which will then turn off the light after 2 minutes.

I don’t need anything to happen while the piston is waiting.

Advice is appreciated. :slight_smile:


#2

I have something similar.

Why not use either a Smart app or another piston to turn on the light based on your described conditions. Have a separate piston that monitors for the door to be unlocked, again with your conditions, and then turns off the light?

I have gotten to the point of having more specific pistons, or pistons that have multiple conditions or tests, but not nested.


#3

Give this a try


The variable (Activated) will make it so the door locking only activates the 2 minute countdown before turning off the light IF the light was switched on by the piston at 06:50.

If you don’t have contacts enabled you will either need to enable them. (Follow the link below) or change it to “send notification” and obviously edit the message to send from my test version.


#4

Thanks. I’ll try it out in the morning and see how it goes.
I still say it would be nice if there was a WAIT UNTIL function. Could come in very handy.

Also, technically wouldn’t the WHILE just keep circling (even though it’s doing nothing) until the condition is met?


#5

It probably would just do nothing but if you look closely at your original piston you will notice that you have 2 while loops and both of them do nothing. So therefore while your lock is unlocked it will do nothing and while it’s locked it will also do nothing. Seeing as it can only be locked or unlocked it will always just do nothing and never even get to the bit with the wait and turn off. ??


#6

Wouldn’t the first WHILE just keep looping until door is becomes unlocked, since it’s only looping WHILE LOCK IS LOCKED?
Then once it’s unlocked, the condition no longer exists, therefore the WHILE is done, move to the next command… which is another WHILE. When the conditions change for that one (now LOCKED) the loops becomes broken and goes to the next command in the piston?

Unless I’m not understanding how the WHILE works?

BTW… your routine worked great this morning. :slight_smile:


#7

I’m seeking something similar, but different.
I want the following:

IF condition (a) is met,
Start a timer. Say one hour.

IF condition (b) is met within that hour,
Do “lights on”.

If condition (b) is not met within that hour,
Do nothing.

I am obviously going to need a loop of some sort.
I’m thinking:

  • set variable X to zero

For x=1 to 3600

  1. check to see if (b) has been met
  2. if not, wait one second
  3. Increment X by one
    Next

I’m just unclear on the best way to implement this in webcore.
EDIT; got it. Will post later.


#8

Ok, here we go. The following, based on ecobee geofencing plus notification from Chamberlain that the garage is open, unlocks the front door and turns on the light outside that door.
The key is to have a unique cooling setpoint (or some other unique setting) for each user. 77 is my wife.

If the cooling setpoint was not 77 but becomes 77, it then checks every 15 seconds, for the next 20 minutes, to see whether the garage has opened.
If the garage does open during those 20 minutes, it presumes my wife is the one opening it and unlocks & lights for her.

//
/* */
/
/

execute
if
ecobee’s coolingSetpoint was different than 77°F for at least 20 minutes
and
ecobee’s coolingSetpoint is equal to 77°F
then

for ($index = 0 to 80 step 1)
do
if
Garage’s contact was closed for at least 20 minutes
and
Garage’s contact is open
then
with
Front Door Lock
do
Unlock;
end with;
with
Front Door Bulb
do
Turn on;
end with;
else
Wait 15 seconds;
end if;
end for;
end if;
end execute;