Rules question can I and in a trigger?

Hi Guys Here is my current rule, questions below:

rule "AC Filter Triggered Fire Light"
when
    //Item AcFilterClear changed and
    Time cron "0 0 0/1 1/1 * ? *" // Every hour when flag is set.
    
then
  if( ( AcFilterClear.state == ON && Kitchen.state == ON ) && ( now.getHourOfDay >  8 && now.getHourOfDay < 21 ) ) {
    Light1_Alert.sendCommand("LSELECT")
    //mappings=[NONE="None", SELECT="Alert", LSELECT="Long Alert"]
    logInfo(RuleLogName,"AcTriggered")
  }
    logInfo(RuleLogName,"Ran Cron Only in Home_triggers")
    
end

Question, can I setup a rule to say:

rule
when
Trigger A and
Trigger B

Also, can I trigger with something like when item on or an if statement? Vs item changed. I am trying to avoid having the hourly cron with the if in the body of rule. This is not a requirement but a curiosity.

Thanks!

No, you can’t. Since all triggers are based of events, the two events would have to happen at exactly the same time, which isn’t possible in practice.

Triggers are essentially compared with an OR operator. The new rule engine introduces the concept of Conditions, which are doing the same as your IF statement. There’s no benefit in using Conditions in scripts, but they are handy when creating rules in the UI. Using the Rules DSL, there’s nothing more efficient than what you are doing.

1 Like

Thanks all! I wanted to confirm!