Wait going to pending after time expires piston never starts again

time

#1

1) Give a description of the problem
I have a wait that starts after a button is held. The timer either will not release and let the piston start or it runs until motion is detected.

2) What is the expected behaviour?
I expected the wait would cause the piston to stop until the wait count was completed. After completion the piston would start again.

3) What is happening/not happening?
The wait A) starts counting down goes pending then starts to count up and never lets the piston start again. B) starts timing but the motion sensor picks up motion and the timer stops and the piston starts to function.

4)

5) Attach logs after turning logging level to Full
I’m really new and don’t know how to record a log.


#2

below the piston look for Logging level - by default it is set to None. Change it to Full Logging and also enable Trace above that. run the piston to generate logs and create a new image of the piston to show the trace :slight_smile:


#3

If we take a moment to zoom in on your last block (lines 37-47):

It triggers when the button gets held, flashes a light, and then turns it off. At that point, you have a WAIT, but nothing is programmed to happen after the WAIT.


For some reason, your browser is not showing the trigger icons (trigger) in the left margin.

In a nutshell, your piston has two triggers:

  • Sensor 1’s motion (Line 20) and
  • Keypad 2’s button (Line 38)

What this means is, each and every time that any of these events happen:

  • Sensor 1’s motion changes to active
  • Sensor 1’s motion changes to inactive
  • Keypad 2’s button gets pushed
  • Keypad 2’s button gets held

… then the piston will start at the top, and run thru the entire code, top to bottom. It will execute anything that is not blocked by conditions. It is important to note that adding a WAIT anywhere will never prevent the next trigger from firing the piston again, and starting all over at the top.


#4

Makes sense. How can I block an action with a condition. Say while the timer is running I do not want the motion sensor to turn the light on.

What I am trying to do is turn a light on by motion in a bedroom. I have that part down. Then I am trying to do use the wait is to take the motion sensor off line for a period of time should someone go to bed early.


#5

Variables may seem daunting for new users, but essentially:

When timer begins, set variable to X
When timer ends, set the same variable to Y

Then in the motion sensor piston:

IF Sensor's motion changes to active
Then
    IF variable is Y
        Then Turn on light
    END IF
END IF

With this code, the light will never be touched during the timer (when the variable is X).
(just keep in mind that ALL changes in the motion sensor will still re-trigger the piston)

Because of this, I usually keep the motion sensor triggers in a separate piston from the timer piston.
(and use @global variables)


#6

@WCmore That’s awesome!!! Thank you!! Was just sitting here trying to figure out how I was going to make that work. I wish I knew more of the higher level programming.


#7

There are alternatives too…
Sometimes I use a (free) Simulated Switch in place of the variable.

  • When timer begins, Turn on SimSwitch
  • When timer ends, Turn off SimSwitch

Then in the motion sensor piston:

IF Sensor's motion changes to active
Then
    IF SimSwitch is off
        Then Turn on light
    END IF
END IF

Same concept.