Complex rules? Rules that enable/disable other rules?

Just getting started with my Webthings system.

I’m trying to do things that I would’ve assumed were easy but I’m having trouble figuring it out.

One problem I’m having is with the Clock. How does one use the “while” operator? Seemingly it currently does the same thing as the “if” operator. I’m assuming there’s something basic I’m missing.

Is there a hidden “between” operator for the Clock that I’m not seeing? There are many rules I want to be active for a specific time of day.

Ex:

I have a smartswitch that controls floodlights on the exterior of my house. I want a motion sensor to turn on the switch for five minutes, but only at certain times of the day/when it’s dark outside. I’m having a hard time coming up with a way to make this work.

Is there a way to have an evaluation of a Rule control the enabled/disabled state of another rule? If I could do that then I could have two clock events, one that enables the Motion Sensor-Switch Rule and one to disable it.

Also related making a Motion Sensor-Switch/Light Rule, I’m currently using a Pulse to keep the Switch/Light enabled for a couple minutes rather than disabling as soon as a No Motion signal is sent. Are there plans to integrate Pulse/Sustain/Delay/etc into the Rule engine?

How does one use the “while” operator? Seemingly it currently does the same thing as the “if” operator. I’m assuming there’s something basic I’m missing.

You can think of if as a one-shot trigger, so the effect would only occur at the time of the input event. while is a constant effect, so for the entire time the input is true, do the output.

Is there a hidden “between” operator for the Clock that I’m not seeing? There are many rules I want to be active for a specific time of day.

You’ll want to use the DateTime add-on to do things like that, as you get hours/minutes/etc. as separate properties (as well as “Dark”, sunrise, and sunset), which you can then use as rule inputs.

Is there a way to have an evaluation of a Rule control the enabled/disabled state of another rule?

No. Just make sure your rules are mutually exclusive.

Are there plans to integrate Pulse/Sustain/Delay/etc into the Rule engine?

Not at this time.

while is a constant effect, so for the entire time the input is true, do the output.

So while, when applied to a Clock input always be exactly one minute, correct?

You’ll want to use the DateTime add-on to do things like that, as you get hours/minutes/etc.

I’ll give it a shot, thanks.

make sure your rules are mutually exclusive.

Sorry, I should be clearer. When viewing my list of rules I see they have an enabled/disabled state. I can manually enabled/disable a rule by throwing it’s switch. I would like the ability to add Rule X to the output of Rule Y to be able to change the enabled/disabled state of Rule X.

Yes.

That is not supported. Seems like it could get you into some weird states.

I agree that there is need for more complex rules. I also want to be able to do one of the examples given of turn lights on by a motion sensor and keep them on for 5 minutes, but only if it is dark.

I also have a case where I want to turn a light on at sunset (easily doable), but then turn it off an hour later.

Another need is a toggle function. It shouldn’t require two rules to turn a light on and off from a push button. It should also be possible to allow that light to turn on only if it is between sunset and sunrise.

The need for these kinds of rule should be intuitive.

You can do this by combining a pulse (from the Pulse add-on) or a timer (from the Timer add-on) with the Dark property of the DateTime add-on.

Same recommendation as above.

Agree the rules should be complex, even with the ability to string together more than two items. So instead of only having “Input --> Output” it would be glorious to have multiple levels of this, such as “Input --> Output —> Input --> Output” IMHO. To provide a better example, “MotionOn --> Datetime (=night) --> Do_Something”.

The timers are especially confusing until you get your head around their logic. For example, I have motion sensors to turn on both my living room overheads, and in my garage, the workbench overheads. It takes two rules. Rule #1 the motion sensor resets a timer every time motion is detected. This assures the lights will stay on while you are occupying the room. Rule #2 turns the lights off once motion is NOT detected for the remainder of the timer. In my case, 90 seconds in the living room, 30 minutes for the garage.

To the original poster, you can feasibly do what you want with the rules as they exist, however it will take multiple rules to do it. I have many things that occupy 2-3 rules just to get it down properly. Makes it a bit of a headache to keep things in order, just use very specific naming conventions to avoid confusion.