Conditions and Triggers: The difference?

difference
faq
conditions
triggers

#134

I have created a control piston that pauses and resumes a piston for the Low Heat climate. When the piston is resumed in registers itself and starts working. Now there is now triggers at all when they are not necessary. I designed it like calling a subroutine. The control piston enables the Low Heat piston. the Low Heat Piston Pauses itself when the Low Heat climate is no longer in effect.

Works like a champ.


#135

First, I want to thank all who have contributed to this thread. I am brand new to webCoRE and just trying to learn as I go. After reading through the majority of this thread, I think I understand that triggers are what cause a piston to execute and conditions limit the task that occur when the piston is executing. Triggers automatically subscriber, conditions do not. You shouldn’t have more than one trigger in a piston because 2 triggers can not be true simultaneously and if you have no triggers, conditions will act like triggers.

What I am missing is how do I distinguish a trigger and condition in a piston that I am writing? I know this may be an obvious noob question, but I am a noob. Does the lightning bolt indicate the trigger? I have written a few simple pistons to do a few things. They all appear to be working as intended. I have pasted green versions below I would appreciate it, if someone could highlight for me the triggers and conditions. Any other comments on making these pistons better or more efficient would also be appreciated.

This piston, turns on a light when the doorbell is pressed as long as it is dark outside and then turns it off after 10 mins.

This one turns on 2 lights when a door is opened and it is dark outside, then turns them off 3 mins later.

This final one exercises the Water Main shut off valve. Once each month it, closes the valve and then reopens it, sending me SMS messages indicating the progress and completion.

I really appreciate any information that you can provide.


#136

Each device will display a bit differently, but basically, in the drop down, conditions are at the top, and triggers are farther down the list…


Yes, but the lightning bolt will also indicate a condition that is acting like a trigger.


#137

Piston umyjm:
Line 20 is a trigger

Piston ezc5m:
Line 20 is a condition acting as a trigger

Piston chwv6:
Line 17 is a time-based trigger


Essentially, a condition is vague, and can be true for hours at a time…
A trigger is precise, and only true for a brief moment…


#138

Thanks WCmore. That is really helpful.


#139

I’m having issues understanding the difference as well. I think the big reason for that is that when you want to add a new statement on a piston, you have 2 choices: if block or action:

If you go to if block, you have the option of adding a condition (which makes sense, since this is the regular terminology for a “if” in programming):

A condition requires a device and a comparison. A comparison can be a condition or a trigger (condition again).

That leads me to a couple of questions:

Question 1: a trigger makes me think of something that perform an action. I’m not sure if triggers in this context relates to the action displayed on the 1st pic. I believe it doesn’t. Does it?

Question 2: when you talk about a condition on this thread, is the condition as the comparison (first rectangle on the 3rd pic)? Or a condition in general (2nd pic), regardless of the comparison type?

Thank you!


#140

Hi Newbe question,
I searched the forum but could not find an answer. I want to turn on a light for X seconds and then turn it off. The trigger is activating a routine.
The thing is that I want that X will be different each time. I’m trying to find a way to pause the piston , ask the user to input X in a popup window on smartthings app, and continue with the piston. Is that possible ? This is what I did for now , but how to input the X parameter ?


#141

You are correct, it does not relate to the actions in your first picture.

In the context of this thread conditions and triggers relate to what is in your third picture. Triggers (second rectangle) will be indicated by a lighting bolt in the left margin. Triggers will start a piston running (which is why they are called triggers) whereas conditions (first rectangle) are just logic elements to determine which code to execute. Typical structure for a piston is to have a trigger to get the piston running followed by conditions to more finely determine the appropriate action.


#142

There is no way to do this I am aware of. You can do a JSON request through. website and get a parameter that way but I’m not sure webcore can wait too long for a user response. More likely, you would have to set a global variable somehow before you turned on the light.


#143

I use webCoRE and Alexa to accomplish this…

  • WebCoRE prompts me with a question…
  • I answer verbally to Alexa…
  • The same piston does things differently, based on my answer.

Feel free to play around with my method.

That thread only shows 3 three possibilities of “X”, but there is nothing stopping you from adding more options.


#144

Hi I have a question related to this.

I have 2 fans and a motion sensor. I want the fans to come on when motion is detected and turn of when motion stops. (I accomplished that) however I want to add a condition that if my lights are on and motion stops fans should stay on.

This is what I did:

If motion changes to active
Then
With switch 1 and 2
Turn on
If motions stays inactive for 3 mins
And light X is under 10%
Then
With switch 1 and 2 (fan)
Turn off

But it don’t seem to work. I can’t seem to find the condition of light status so.i used this.

Thanks for any help in advance.


#145

You should post questions like this in the piston design help but I think to do what you want you should make your light condition a separate if within the inactive trigger:

if motion stays inactive for 3 minutes
then
  if light X is under 10% then
     with switch 1 and 2
        turn off
     end with
  else
     with switch 1
        turn off
     end with
  end if
end if

#146

Ok let me try and if the light is power but off would that count as being under 10%


#147

I don’t know as I don’t have this type of bulb. I think off would be 0% but you can change the condition to switch is off or whatever accomplishes your desired outcome.


#148

Ok I been messing around with it last few days will try what u said. Another quick question I don’t really have a switch for it I control it with a button. It more like a toggle. So when it says switch is off does it mean the device is off? Or the smart switch that controls it is off?


#149

I used the switch status and it worked thanks for Ur help


#150

There are three answers to this question:

(1) IF your light is on at (let’s say) 50%, and then you send a command to “Set level to 0%”, then the answer is “No”. The bulb will be off, but the bulb will still show 50%.

(2) IF your light is on at 50%, and then you send a command to “Turn off”, then the answer is still “No”. The bulb will be off, but the bulb will still show 50%.

(3) IF your light is on at somewhere between 1 and 9%, then the answer is “Yes”…
(Regardless if the bulb is on or off)


#151

That’s great, JAA2666. But your PM left us all in the dark. Why was the ANY and ALL logic not working at first, and what did c1arkbar tell you that got it to work?


#152

I’m so sorry man. This was a couple years ago and I’m no longer using the piston. To tell you the truth I don’t even remember what it was used for


#153

I want to monitor an outlet of a PC. If the PC draws less than 100w for 3-5 min it means it’s idle and I want to turn it off.
Would I best monitor this with just a trigger, just a condition or a combination of trigger and a condition?