A possible feature request (Exit actions)

I saw a comment on another thread and instead of taking that topic off course I decided to start a new one. Here is the comment:

This statement made me wonder how powerful or effective “exit actions” could be. Basically an action for when a condition is true with another action when it becomes false (exit action). This is already a concept in the android app Tasker and I’ve used it a lot.

Potential use:
Smart switch style lighting…
Condition: motion sensor detects motion
Action: turn on light
Exit action: turn off light (perhaps with one ore more delays like actions have)
Discussion,: while you could do this with 2 pleg conditions this would just make it easier

I’m sure there are more but that is the one that pops into my mind right off the bat.

Sent from my Nexus 7 using Tapatalk

I’ve already seen one flaw in my example above…SS is proabably smart enough to reset it’s timer if a motion sensor goes off, then goes back on before the delay is up. The PLEG exit action probably wouldn’t unless it always did that which might not be so intuitive. I’m going to try and think of some more use cases for this and see what I come up with. I’m still a noob with PLEG and I don’t do a lot with it, but I have a feeling this could be a very nice addition and I would think it would be theoretically easy to implement (but I have no idea since I didn’t write PLEG!!)

The timer for a smart switch would be implemented with a Self Retritgger schedule.
Any time you have motion you would (Re)Trigger the timer. In fact you can have different time values for different triggers.

You them do the appropriate actions when the Timer goes false.

So are you saying that perhaps exit actions are not needed as I could just write another condition for when the timer is false? (which is totally fine with me, I’m still a new to PLEG)

I know the SS example was simple, but my thinking was that someone has a very complex condition it would be easier to have an action for when it was true and one for when it was false, but I guess at the same time, you allow for using conditions in other conditions, so then I guess it makes my “feature request” moot. Is that correct? So:

Condition1 = really complex string of checks and balances that eventually will just return true based on any number of factors. Ok, i’m just really making a long string to simulate a long condition.

Condition2 = !Condition1

Sorry, I’m a programmer by trade, but I wasn’t even considering the above when I suggested exit actions. I was more thinking of a way to have less conditions by allowing for entry and exit actions for every condition. In hindsight that might make the actions tab a bit more complicated, but at the same time, it is just “numbers of actions” on that tab, so it would merely be another column (or columns).

Anyways, it was just an idea and I wasn’t sure it was even a great one :slight_smile: Just something that popped in my head.

Yes, it is very easy to have a separate set of actions on !Condition.

Another twist, if the Condition is Binary and the Actions are binary, like turn on/off a light.
You can do it with one condition

LightCondition SomeLogicExpressionWhenTrueTurnOnLightOtherWiseTurnOffLight

The action for LightCondition could be
SetTarget {(LightCondition ? “1” : “0”)}

So you can put some expression in the the arguments for the Action.
You need to use the Advanced Tab of the Action Editor to do this.

Well there you have it :slight_smile: You’ve thought of it all!! (well at least all that I’ve thought of). I guess I really need to just wrack my brain on the best way to use this. I think I may try and replace SmartSwitch with this since I want some other options not currently in that plugin.

When you are done … post back your Example of Using PLEG as a Smarter - Smart Switch !