Simple And Condition for trigger

I'm new to HE making the transition from ST and so far it's been great. I'm having one problem trying to figure out how to get one thing to happen that I'm sure is more about my lack of HE knowledge.

I have a foye with a door and sensor on each end. The concept is when you open either door the light goes to 100% and when BOTH are closed it returns to 5%

From what I can see in RE the issue seems to be an OR statement instead of an AND statement which I have not been able to figure out how to change. Any help would be greatly appreciated.

Triggers cannot be AND because that would require that both triggers happen simultaneously and that is virtually impossible. It's a common misunderstanding that many of us, incl. myself, have made. Instead, your trigger is that either door changes.

Then, in Actions, you have to use a conditional that if Door A OR Door B is open, then lights go on 100%
If Door A AND Door B are closed, then light goes on at 5%.

3 Likes

You may also want to look at the built in lighting apps to start with, if you haven't already

3 Likes

That was the solution, it works perfectly now. I guess it's a question of where all the buttons and switches are.
Thanks for all of your help.

Does this mean that there is no possibility to block/allow a rule trigger at a specific MODE (home/away..) or even a semi-static variable ???

How is this acceptable? This minimal functionality for home automation! What am I missing?

Cheers, Ronald (fairly new to HE after transition from ST)

Technically, you won't be blocking the trigger, you are blocking/allowing actions based on a conditional IF statement.

So, for example,your Trigger is that motion is detected and under Actions, you start with a conditional of If Mode is Home, turn on Front Porch Light.

1 Like

This rule would looks something like this

Trigger: door1 or door2 open

Turn light to 100%
Wait for condition door1, door2 all closed
Turn light 5%

Appreciate your reply.
If I understand correct this basically means that I may have to make multiple rules to operate a single device/variable.
For instance I have a variable "DAY" which I want to set if any of my door contacts is opened (but only after 6:00AM) OR if motion is detected in the bathroom (but only if outside illumination >500) OR if illumination gets above 500 (but only if AWAY).
I then need 3 rules to set the variable DAY:
rule1 = trigger: (any) door contact -> open => set variable DAY:= true IF condition= time>6:00AM
rule2 = trigger: motion in bathroom => set variable DAY:= true IF condition= illumination>500
rule3= trigger: illumination>500 => set variable DAY:= true IF condition= mode=away

Is my understanding correct that the use of these 3 rules is the best/only method via the rule machine?

It is typically the HE Staff's recommendation that multiple small rules are better than one complicated one.

1 Like

Three rules might be the best option but not the only. You could have each of the events as triggers and then use off statements and the %device% variable determines which device triggered the rule and then apply additional conditions to that.

However it take processing power to calculate all of those if statements.

I donā€™t have the link handy but there is a video on what they have called the KISS method.

Fast forward to about the 2:20 mark for Bruce's Keep It Simple Stupid method explanation.

What your missing is a little history. What you are describing is called a restriction. Some apps have restrictions, see for example Simple Automation Rules. You can have a restriction that says something like "Only if mode is X or Y". Rule Machine used to have this type of restriction.

What isn't perhaps obvious about restrictions in general is that they are really hidden conditional actions that run for every activation of that rule. Every time it is triggered, it has to check to see if its restricted or not. There is no magic here, some piece of code has to do the test about is there an applicable mode restriction. So, every rule carried that overhead by allowing restrictions.

A change was made with Rule-4.0 to remove restrictions, and to instead make them explicit instead of hidden. The test can be the same, but only a rule that needs the test pays for it. For example, one can do this Simple Conditional to get 'Only if mode is Day':

IF(NOT Mode is Day) Exit rule

You don't need to create multiple rules to do what you asked about above.

Trigger: door opens (any selected)
Actions:
   IF(--the complex conditional you showed--) THEN
      Set Day: true
   ELSE
      Set Day: false
   ENDIF
2 Likes

Thanks for your replies and the KISS :wink:
It seems that I need let go of some learned (probably: bad) habits from WebCore under ST. I actually just installed WebCore under HE -grabbing back to a known environment- but apparently I need to give the rule machine another try now its possibilities/principles got more clear to me.

Cheers