Help with this rule

Hi, dummy question here, I followed a hubitat tutorial online for the Halloween Rule. I’m just having a hard time to only run the rule between specific times. Also can I lower the motion sensor range? I have it aiming to my front door but it looks like everything triggers the rule. Thanks!

Add a 'Required Expression' at the top of the rule:

  • Turn on 'Required Expression'
  • Define Required Expression
  • New Condition
  • Between Two Times

Couple are issues that will probably give you problems.

Every time there is motion the rule will trigger. Don't know how long your sound is, but that could mean restarting the sound over and over before it finishes. Along with the required expression for time you probably should use the private Boolean. Below is how I would do it

Required expression: Between time AND Private Boolean True

Trigger: Motion Active

Set Private Boolean FALSE(This will stop the rule from triggering again until current run of sound is done.)
Play sound
Wait for event and stays inactive for 2 min?(adjust the time as necessary, turn on the and stays slider when creating action, this will wait for no motion but it must remain inactive for the time specified.)
set private Boolean TRUE. (Rule can now trigger again)

1 Like

1 Like

That should do it. What @terminal3 mentions about the Private Boolean is worth adding to stop it triggering quickly in succession. On top of that, you might want to add something else in there depending on how quickly your motion sensor goes to inactive, so that the light stays at that colour for a little while rather than going off immediately. It could be that your visitor triggers the motion sensor while at your door and then is still, in which case the light may turn off too quickly. To get around that you can edit your actions. If you click the action in the table for "Wait for event - motion inactive", you can click the switch for "and stays", then set that 10 seconds for example. Then once triggered the Private Boolean would ensure that the rule runs all the way to the end before it can trigger again and the 'and stays inactive' stops the light going out and the rule finishing while there's still someone stood at the door.

Thanks again, I went to forums to find out a bit more about PB, I’m still confused. But I hope I did it right.

It’s wrong but simple to fix. I struggled with the concept when I first started with Rule Machine.

The very first action should be to set Private Boolean false (not true). Then you need to add as the very last action to Set Private Boolean back to true again. Also for those actions to do anything, you need to add Private Boolean True as an ‘and’ to your required expression.

The Private Boolean is True to start off. We make it part of the required expression- the rule cannot run unless it is true AND between your two times. The rule triggers (motion) - because the first action in the list is to set it False, the required expression goes false also. It means that someone dancing in front of your motion detector can’t continuously trigger the rule again and again. Once the other actions have completed, the last action sets it true again. That then sets the required expression true again (as long as it’s still between your two times) so that the rule can trigger again if motion is detected again.

1 Like

How about now ?

You need to add PB=true to your required expression (see last sentence of johnwill's 2nd paragraph above)


Yeah - without adding the 'Private Boolean Tree' to the required expression ('Time between 6;00PM and 10;00PM AND Private Boolean True) switching it False and True in the actions won't disable and enable the rule triggering as you want.

Still can’t get this to work. Im lost.

Did you add the Private Boolean to the Required Expression?

I removed the bulbs (Sengled) I had some issues besucase I don’t that I have the bes zigbee mesh. So I’m going with the speaker only.

This is what I would do, originally I mentioned using a wait for event, but I think a wait for expression with a duration would be better. I think either would work but IMO just waiting for the motion to stay inactive for a time period would be best.

Private Boolean should be true not false in the required expression.

Thanks for the help! Still don’t understand the use of PB.
Why even when I’m selecting “true” in define expresión still showing “false”? And when hit false shows “true”.

That looks about right now with 1 (possibly 2) exceptions:

I think you're clicking the value in the box shown in the image below. That manually switches the PB which you shouldn't normally need to do (as the rule running will set it true/false correctly) To manually correct the PB, beneath the rule actions you will see the below box - click where it says 'false' and that will manually change it to 'true'. You shouldn't need to touch that afterwards.

This bit can be confusing until you know how to read it:

Screenshot 2022-10-30 at 08.57.52

In order of what is shown in parenthesis/brackets:

  • (false) is the current state of the Private Boolean
  • (F) is how the expression 'Private Boolean is True' has been evaluated - false
  • [FALSE] is how the entire required expression (time between sunset -30 and 11;00PM AND Private Boolean is true) has been evaluated.

You have your wait until inactive time set at 5 minutes. When your rule is triggered by motion it will run and play your track, but then will wait until there has been no movement for 5 minutes, before it can run again. I guess it depends on how long you expect a caller to be at the door as to how long that wait time is set to.


This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.