Using Restrictions in webCoRE

In webCoRE restrictions are conditions that can be applied to either the entire piston, or to a statement within the piston.

  • As they only include condition comparisons, they do not cause the piston to execute (there is no automatic subscription to condition comparisons in restrictions)

  • Note, you do not need to use the 'restrictions' syntax in webCoRE, your own if statements can handle restrictions you want.


In the IDE, restrictions may not be initially visible:

Screen Shot 2022-02-19 at 11.04.05 AM


If you select the funnel in the tool bar (or 'Show restrictions' under 'Options') they are visible (as 'Only When' section):

Screen Shot 2022-02-19 at 11.06.10 AM


There are two types of restrictions:

  • for entire piston

  • for a statement


Piston restrictions:

Screen Shot 2022-02-19 at 11.10.29 AM


Are evaluated when the piston begins execution
  • if true, allows the piston to execute

  • if false, the piston does not execute

    • but a dummy run is done to update variables for future executions (much like after saving or resuming a piston)

      • this ensures future executions with trigger comparisons work properly
  • You do need to be careful when you use piston restrictions:

    • if the logic of your piston is to turn things on and off, it is possible for something to be turned on, then the restriction becomes active, and then the turn off will not be executed.

    • this is a case that coding the restrictions into your if statements may be better than restricting the entire piston execution


Statement restrictions

Screen Shot 2022-02-19 at 11.25.12 AM

Shown at line 15

  • the restriction evaluation determines whether the statement is executed

    • you can think of it as an if statement to determine if to execute the statement or not.
  • You do need to be careful when you use statement restrictions:

    • it can affect processing of trigger comparisons (that the statement controls)

    • for example the statement (or has sub-statements) being restricted contains an if using a trigger comparison for a device

    • In this case it would be better to not use the restriction on the [ if ] statement, and add condition comparisons to the if clauses

Do note:

  • in these examples, the piston does not subscribe to any events

    • so while showing the syntax of restrictions, these pistons would never run on their own as they do not subscribe to any events.
6 Likes

Future reserved

Download the Hubitat app