Using Timestamps in Groups

Hi Patrick, I’d like to be able to use the timestamps of devices with mathematical operators < >
in order to test direction of travel between sensors. ie t1 > t2 or t1>t2>tx
The Sequence operator is one the most useful operators in PLEG, I’d now like to start changing over my logic to Reactor and can see how it can be done using timestamps but need some help in how to achieve it.
The timestamp of the device is returned when True (Tripped) and is shown in the group information as a Unix Timestamp, so it should be possible to make these comparisons.

I’m not seeing anyway that it can be used in a comparison conditions, can it be done or am I asking the impossible of Reactor?

Click the downward-pointing arrow in the group of three buttons on the right of the condition row. That opens the condition options, where there are bunch of fun little knobs you can turn to “tune” the behavior of the condition output (it applies to groups as well, since groups are just conditions with other conditions in them, except the root group).

More info here: Condition Options - Reactor

The one you are specifically interested in for this task is the “Only After” sequence restriction, and you’ll likely want your condition to be testing the Tripped flag rather than the LastTrip timestamp because you don’t approach this from timestamps in Reactor (it does internally, of course, but I try not to expose that to the user), you approach it from the state itself.

Edit: fun fact… the timestamps returned by luup.variable_get() are not durable across restarts. They are not stored in userdata and are not persistent. Every Luup reload, they are reset to the time of the reload for every state variable in the system. That means that if you relied on timestamps alone, you could not accurately and reliably sequence events across reloads/restarts. FYI, Reactor does not rely on Luup’s timestamps for sequencing, and its sequences are durable across reloads.

+1
Now to workout why my outside awnings open after 3 sec’s of Reactor tripping…