Using Followed by in webCoRE

When writing comparison statements, common methods when using multiple comparisons is to use and / or to join the comparisons.

  • as previously mentioned, with multiple trigger comparisons typically one uses or,
    or you have a single trigger with and along with condition comparisons
    (because only a single trigger event can be true on a single execution of the piston (event))

webCoRE for condition groups supports 4 operators

  • and
  • or
  • logical exclusive or (xor)
  • followed by

Followed by is interesting because it lets you join multiple trigger events into an ordered series.

Here is an example piston that uses followed by to deduce if one is traveling up the stairs, or down the stairs.

  • In this case there are two motion sensors - one at the top of the stairs and one at the bottom. In my house they are positioned that the bottom one only senses motion at the bottom of the stairs, and the top one only at the top of the stairs.

Notice that each if statement (line 23, and line 30) has two trigger events, joined together with followed by

  • each trigger after the first has a timer that is the window in which that subsequent trigger needs to fire and details on how strict/loose the match is.

Followed by requires that all the comparisons are trigger comparisons, so that the event ordering / timing can be tracked/checked.

  • as such, use of followed by should be at level 1 (looking left to right - ie do not nest trigger comparisons below then or else statements)

While this example shows two steps, there can be many steps in the followed by sequence.

If you want to use followed by, do ensure you are up to date with the latest webCoRE release on Hubitat. Earlier releases (and ST release) have some issues in proper operation.


Alternative approach

For simple two step sequences, there are other ways to achieve similar results with a single trigger and condition comparison.

  • This involves making the trigger on the 2nd item of the sequence, then checking that the first item occurred recently with a condition comparison:

Screen Shot 2022-04-15 at 2.01.32 PM

4 Likes

Reserved

I think these tutorials are fantastic! Thank you.

Download the Hubitat app