How would you do this?

I want to define a rule that always runs at a specific time of day OR when switch A is turned on BUT only if switch B is already on. In either trigger scenario I want it to test switch C condition and have true and false actions depending on that.

I can get a triggered rule to run at the specific time or when switch A is turned on, but can't find a way of adding the switch B state condition to the trigger part.

Is it going to have to be 2 rules ? I'd like it to be one rule because the true/false parts of it are quite complex and I didn't really want to duplicate them.

Here's an example where switch B must be on for switch C to activate. If it is, and the time is also between 10pm and 10:30pm EDT in my example, then the rule is true and switch C turns on. If it is not between 10pm and 10:30pm EDT, but switch A was turned on, then the rule would also be true and switch C will turn on.

Since you always want Switch B to be the deciding factor as to whether time of day or switch A will activate switch C (or whatever you want to activate), then it is important to make sure that when you build your rule, switch B must always proceed the AND operator. If it does not, then whatever proceeds AND must always have a TRUE condition, otherwise, the evaluation of the rule will be immediately false, so it won't go on to evaluate any conditions that follow the OR operator.

@bravenel explains it very well in the Rule Machine Introduction.

Thanks for the reply but I don't think that does what I want. I probably didn't explain it very well.

I want the rule to trigger when either:

It's a specific time (regardless of any switch)

Or

Switch A is turned on when Switch B is already on

When the rule triggers I want it to carry out true or false actions based on the state of switch C.

OK. That will need two rules for me. Maybe @bravenel can tell you how to do it in one.

[Edit] Switch B must be part of the evaluation for either Switch A condition or time of day. If it's not then when it's not that time of day or switch B is not on, then the rule won't be evaluated further.


Thanks again fir your help. It certainly looks to me like I need (at least) 2 rules for this. I think what I might do is make the complex parts relating to switch C into separate rules. Then have one triggered rule for the time, and another for the switch A & B logic, both calling the same rule for true/false relating to switch C.

1 Like

That's what I would do too. You end up with three rules, but then you don't have to re-write your complex bits, you just use the private boolean trigger and you also won't have to worry about switch B being active for the time of day trigger to work.

1 Like

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