WebCode - Retrieving Piston State in Condition

I’m trying to do something that I would normally consider very basic - retrieve the current state of an object (i.e., piston). I have figured out how to set the piston state, but I can’t figure out how to retrieve it in an “IF” condition.

The use case if straightforward: I have a piston that is either Armed, Unarmed, or Overridden. It is Armed if all doors are closed during specified modes and the related virtual override switch in SmartThings is off. Then, if the state is Armed and one of the doors (contact sensors) opens, trigger an action (e.g., siren).

This is all within the context of a single piston because I couldn’t find a way to make a separate call like “If PistonName.State = Armed, Then sound alarm)”. I’m not sure if WebCore lacks a full object model for setting and getting properties or if I just haven’t figured out how to do it. In any event, please let me know how to access the current piston state when the piston executes (i.e., the current piston state prior to a new event occuring).

Hi Robin,

I’m a bit confused. Are you saying that there is a delivered variable called $State that represents the delivered piston state attribute?

The piston currently evaluates and sets the Piston’s state attribute through existing evaluation rules each time the piston is triggered - that works. I’m trying to retrieve that attribute in a condition statement so that I know the prior state and then determine what action to take based on the current event that caused the piston to execute.

Thanks Robin. It appears that did the trick.

Do you know if there is documentation of all system variables and their meanings? I haven’t been able to find anything like that.

Thanks - I saw that but some of them don’t appear to have values ($State is one unless I’m missing something). Others are hard to differentiate based on name (I.e., $State vs. $currentState).

I’d be happy to help, but I’d just be guessing in many cases - that wouldn’t make for useful doc.

Thanks again for your help. At least in this case, I appear to be working.

Regards…Greg