I have the following scenario that I need to program in PLEG:
Wait for a certain condition c1. This condition WILL GO AWAY and then might go through a few cycle of coming back and going away. Once it has happened I need to remember it has happened. No action will happen at that time, though.
I need to wait for a second condition c2. Note that the above condition for c1 WILL NOT be satisfied when c2 happens. They are mutually exclusive. Hence, I only evaluate if c1 every happened before c2. Now, when c2 happens then
a) if c1 DID NOT happen before then do nothing.
b) if c1 DID happen before then execute an action and reset c1.
I could do c1 with a schedule but none of the stop options seem to be appropriate to reset its state, i.e. I cannot reset c1 based on when a different conditions (c2) becomes true (or at least I have seen a way to do this). I also looked at the regular evaluations of conditions but it seems everything will reset c1 before c2 happens.
One solution would be to add a device variable to PLEG or another device that you use to indicate that the c1 event has occurred. If you define a Device Property for this variable, you can use it in your Condition.
Something like this:
Device Properties SeenX “SeenX”
Conditions c1 … Expression for event … c2 … Expression for event … c3 c2 and (SeenX != 0)
Rex, I first was going with your first approach which lead me to learn more about creating variables, naming conventions from UPnP, etc.
I finally ended doing your second suggestion, though. I created some testing environment and preliminary results indicate it works. The only thing that puzzled me is that c1 is triggered multiple times even if the input t1 for c1 did not change (t1 = More than 100W, c1 = t1 and (t1;Now>1:00) ). I thought that conditions are only evaluated when the state/input changes but that does not seem to be the case.
The only thing that puzzled me is that c1 is triggered multiple times even if the input t1 for c1 did not change (t1 = More than 100W, c1 = t1 and (t1;Now>1:00) ). I thought that conditions are only evaluated when the state/input changes but that does not seem to be the case.
Conditions are, as you thought, evaluated when one of their terms changes. Using Now in an expression will cause it to be evaluated every minute.
There is no great harm in this - the processing load is quite small. If you want to avoid it you could use a SelfReTrigger Schedule (timer) instead of Now.