Newbie question here: I have defined three global boolean variables that are set in rules triggered by motion switches. I would like to have a new rule trigger of the sort "if Var1=true and (Var2=false or Var3=false) then trigger=true, else false". When I enter multiple trigger conditions in the Rule Machine, they are automatically "OR-ed", and I see no way to get an "AND", let alone making a general boolean expression with parentheses. Hope this is possible, but I can't find anything about it. Anyone have a suggestion of where to look?
You don't perform that logic in triggers, you perform it in actions.
Define your triggers (the 3 variables changing their state).
Then in actions, you create an IF/THEN/ELSE that will test for the conditions that you require and then perform the required action.
I have several rules that work like this myself.
The above is correct and is one way to handle this. I would suggest looking at the documentation or other examples to learn more, including how the different components of a rule work:
So, I ended up with this rule:
Am I on the right track? Thanks by the way for you quick suggestions...
Probably not; when a required expression is false, trigger events do not matter. Your trigger events are such that your required expression is likely to be false any time they happen (events are normally state changes, though sometimes you can get sequential events with the same value). Also, a required expression becoming true does not so anything on its own; not sure if that is what you are expecting.
So, I guess that means you'll need to think about what you actually want to happen and when. It's not clear from your description above if you care about any changes or just certain changes when certain conditions are already true. FWIW, the suggestion above was to use the "Conditional Actions" feature in your rule actions, not a required expression, but either could work for different cases, so it depends on what you want.
Yes, I confused Required Expression with Conditional Actions, and the above rule did not work. So I moved the above Required Expression logic to a Conditional Action, but I didn't see a way to turn the lights off only if the Conditional Action evaluated as true.
My use case if very complex, so I did not provide a description of it, but here goes:
Before I bought my Hubitat, I had an installed base of 12 Kasa WiFi devices in my house. The Hubitat Kasa app worked beautifully to automatically capture all of these devices and make them available for use by the Hubitat Hub. I have an L-shaped workshop in my garage with two doors that are out of view from each other. Near each door is a Kasa wall switch with an integrated motion detector (call them SwitchA and SwitchB), each controlling one bank of overhead lights. These switches have internal logic that turns its bank of lights on if motion is detected, and then keeps them on until no motion is detected for a settable delay time. I wanted the Hubitat to turn on both banks of lights if motion was detected by either switch, and then turn them off only if no motion was detected by both switches. My first attempt at doing this used the Lighting app, and it properly turned on both banks if, say, SwitchA detected motion. It left them on as long as I stayed in the field of view of SwitchA. However, if I moved out of the field of view of SwitchA, it issued a command to turn all lights off, even if I had entered the field of view of SwitchB. This is why I was attempting to use a more sophisticated Rule to do properly.
OK guys, with your help I have a solution that seems to work. First the requirements:
(a) If Switch1 turns off with Switch 2 already off, then turn off the lights.
(b) If Switch2 turns off with Switch 1 already off, then turn off the lights.
(c) if both switches turn off simultaneously, then turn off the lights. While this circumstance may seem unlikely, recall that I'm using Kasa WiFi switches that are only polled every 5 seconds.
I met these requirements using three corresponding rules. The rules for (a) and (b) have a single trigger test with the required condition that the other switch is already off. The rule for (c) has two trigger tests that both must be true to perform its action. All actions turn off lights only if they are on. Mission accomplished, and thanks again for your guidance.
This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.