Can a single rule be run concurrently?

The problem is I need to do multiple thinks conditionally on the private boolean being toggled. Ideally I could have a single "if false" check that runs multiple commands under it:

  • If private boolean false
    • set private boolean true
    • capture devices
    • change devices

If I just set the private boolean to true first then I can't conditionally capture and change as well.

Maybe I need an additional global boolean so I can use the private boolean as my mutex and the global boolean to track capture state.

No, you wouldn't. You're overthinking it.

I'm not sure what you are referring to. Are you saying I can set the private bool to true as the first step and still have conditional checks on the previous state of that bool?

Why do you need conditional checks of the bool? Just enable the restriction.

I need conditional checking so that when the action is re-run before the delay timeout it won't re-capture the device state or re-do the dim set.

Lets say my new Action looks like the following and has a restriction to only run when private bool is false:

  1. set private bool true
  2. capture device state
  3. set dim 100
  4. delay 5m then restore device state
  5. set private boolean false

If this triggers on door unlock and then triggers 3 minutes later on presence arrival the second run will capture the device at "dim 100" overwriting the captured state I want restored. What I'm going to try is:

  1. set private bool true
  2. if global is_captured is false: capture device state
  3. if global is_captured is false: set dim 100
  4. set global "is_captured" bool to true
  5. delay 5m then restore device state
  6. delay 5m then set global "is_captured" bool to false
  7. set private boolean false

That gives me both a mutex for rule execution and prevents re-capture of the device state.

Again, you are overcomplicating it. Private boolean is a restriction that is built into RM. You don't have to use a conditional check. PB was around long before conditional actions. It's right here, under restrictions:

@bravenel does an excellent job summarizing it:

So how do I ensure steps 2 and 3 are only run if there isn't currently a delayed action without the conditional check? If you are sure you understand my requirements do you have an explicit suggestion on an alternative approach?

Do you understand how PB works?

Apparently not, but terse answers won't help me understand it. Can you please explain or am I supposed to just deduce it from questions?

I linked to an explanation. Did you read it? LOL

You want your run to run what, once every 5 minutes let's say. So, at the end of your actions, you would put two actions:
Set PB false for this rule.
Set PB true for this rule after a delay of 5 minutes.

Then you would enable the PB restriction for the rule, in the picture I posted earlier from within the RESTRICTIONS area of the rule , and you're done. The rule will only run once every 5 minutes. But, this also means that the false action will not run. No action of the rule will run while the PB is false.

If you are trying to use some other type of behavior, i would use a boolean global variable instead of the PB. The private boolean is only for that rule while the GV can be read anywhere.

I did read that tutorial and it describes exactly what I'd expected.

Going back up a level the highest level goal is:

  • Lights turn on when: a door is opened, lock unlocked, someone comes home.
  • Lights revert back to previous state 5 minutes after: the last door is closed, or lock unlocked, or someone comes home.

I need the action to re-run on each triggering event to reset the 5 minute delayed restore. Simply blocking action execution for 5 minutes means the light restore runs 5 minutes after the first trigger, not the last trigger.'re confusing your terms. There are triggers which trigger on events. And there are rules which look at conditions. You have a rule. So there is no trigger event. There are conditions that the rules look at. Okay?

So, I still don't understand what you are trying to accomplish. Once someone is present, the rule isn't going to go false until they leave again. You don't want a rule, you want a trigger.

And I still don't understand what you are trying to accomplish. If someone has just arrived, why do you have to trigger on the door opening? And if you are triggering on the door unlocking, why do you also have to trigger on it opening? Presumably it had to be unlocked before it could be opened, right? I think you are trying to get too broad with it.

I don't know what you mean by:

Do you mean that the 5 min delay should reset?

If you look at the first post I linked the three rules. I have an Action which is run either by a Condition (used for door open state) or a Trigger (used for unlock and arrival events).

I have a broad set of actions because they are the things I want to act on. If I drive up to my house at night and my presence changes to present lights should turn on. If I unlock the door my intent is likely to go outside, so my lights should turn on, I could just wait for the door to open here but triggering on unlock makes it more likely that the lights are on by the time I open the door and get outside.

Okay...and what about the other questions I posted? I'm trying to help you here man but if you don't want it, just say so and I'll leave you alone. LMAO

After a 5 minute delay restore the captured state. See bullet #5 in comment 9 what's the problem then?!? You can't just repeat the same words and expect me to understand you the second time you say it! Like, oh, i didn't understand it the first time i read it but now that you've typed it again.....

Are you trying to get the 5 min delay to reset so that it only happens once? Because if you have separate rules and triggers with independent delays, and you trigger it twice, the actions are going to happen twice. So, if you have one trigger that happens at time zero and has a delay of 5 minutes and it happens again at time 2mins. The actions will take place at 5 minutes and 7 minutes. Are you saying that you only want the action to happen at 7 minutes? Maybe if you were more descriptive about 2 things: what is current state (what are you seeing) vs what do you want to happen. And a simple breakdown, rather than a summary, would be helpful. And not what you are putting in your rule but what you want to happen out here in the real world.

Sorry man, not sure how I can be more clear. My two requirements are:

  • Lights turn on when: a door is opened, lock unlocked, someone comes home.
  • Lights revert back to previous state 5 minutes after: the last door is closed, or lock unlocked, or someone comes home.

The problem I'm having with the set of rules in my original post is the Action is getting run more than once concurrently resulting in the 2nd run capturing the state of the lights set in the first run so when the Restore happens the lights don't restore to their original state.

I believe using the private boolean as a mutex and a global boolean to track if the lights should be captured will resolve the problem. I'm working on those updates now and will post a solution once I've verified it.

Okay, let me see if I can be more clear. What I am looking for is not a summary of what you want to happen but an example. So, look at the following:

Time 0: I arrive home, lights turn on.
Time 1min: I unlock the front door
Time 2min: I open the front door.

Now, do you want the lights to turn off at 5 mins, 6 mins and 7 mins or ONLY at 7 minutes.

Example 1:
T0: I arrive home, lights turn on.
T1: I unlock the front door
T2: I open the front door.
T8: I close the front door.
T13: lights off

Example 2:
T0: I arrive home, lights turn on.
T1: I unlock the front door
T2: I open the front door.
T3: I close the front door.
T4: Wife arrives home
T9: lights off

Example 3:
T0: I unlock the front door, lights turn on.
T5: lights off

5 minute after the last trigger (arrival, unlock) or condition (all doors closed) lights turn off.

Download the Hubitat app