[Solved] Help with rule


#1

Hi,

I want to make a rule for a light with motion, I believe we are supposed to use boolean but I'm a little lost.

I want the switch to turn on with motion, turn off at 10 minutes, but if the switch was already on by manually digital or physical it will stay on until we turn it off manually by digital or physical, then the motion can work normally. It's one switch and one motion.

I know this sounds really stupid but I have retentive problems and I know I did this before but now I can't find how.

I know @destructure00 is good with rules, and @Ryan780, please help. Thanks


#2

You could write it into a restriction.
Light is On. as a restrictions.
This way the rule will be restricted if the light is on and therefore ignored.
Just a thought.
Second thoughts that won't work as it will go restricted when the rule runs and turns the light on. Oops.


#3

First crack...

Trigger 1:
Trigger: Motion inactive
Actions: Delay 10 minutes, turn off switch
Restrictions: Enable/Disable with PB

Trigger 2:
Trigger: Motion active
Actions: Turn on switch, cancel actions of Trigger 1
Restrictions: Enable/Disable with PB

Triggered Rule 1:
Trigger: Switch changes to on
Condition/Rule: Motion is inactive
Actions when True: Set PB false for triggers 1 and 2, Cancel actions of trigger 1

Trigger 3:
Trigger: Switch changes to off
Action: Set PB true for triggers 1 and 2

You might be able to condense this into fewer rules, but I personally hate using restrictions on rules because restricting a rule freezes it's current state, and un-restricting a rule does not cause the truth to be re-evaluated, so it could either be True or False when it's unrestricted. Rule actions only execute on state change, so this can cause actions not to run the next time the rule is evaluated. So I tend to split rules that I want to restrict into separate triggers.

Anyway, give this a shot and see if it works.


#4

Now that I think about this...combining Trigger 1 and 2 into a single Rule with a restriction would work in this case...PB would only be set false while motion is inactive (via Triggered Rule 1). Since motion would be the sole condition for rule truth, it would only be possible to set PB false while motion was inactive and the rule was False, which mitigates the problem I was talking about in the previous post.

So as an alternative, I think this would also work:

Rule 1:
Condition/Rule: Motion active
Actions when True: Turn on switch
Actions when False: Delay 10 minutes (Cancel on Truth Change), turn off switch
Restrictions: Enable/Disable with PB

Triggered Rule 1:
Trigger: Switch changes to on
Condition/Rule: Motion is inactive
Actions when True: Set PB false for Rule 1, cancel actions of Rule 1

Trigger 1:
Trigger: Switch changes to off
Action: Set PB true for Rule 1


#5

I'm finishing this example, thanks, question, this will keep the light on with motion? I mean, I have the Iris motion, the reset motion is 1 minute, so in 10 minutes before it turn off, if the motion triggers at 5 minutes, it will reset the count to 10 minutes again? hope you understand what i mean


#6

If you're using my first example, Trigger 2 will cancel the pending Off action from Trigger 1 if motion goes active again.

So let's say this sequence of events happens at the following times:

5:00 - motion goes active, lights turn on (via Trigger 2)
5:01 - motion goes inactive, lights off scheduled for 5:11 (via Trigger 1)
5:07 - motion goes active. Trigger 2 says to cancel the Off that was scheduled for 5:11
5:09 - motion goes inactive. Trigger 1 schedules lights off for 5:19
5:19 - lights go off

Is this what you're asking?


#7

Yes! I will test now. Thank You!!


#8

I'm not sure if you saw it, I edited the post for my first example and added "Cancel actions of Trigger 1" to Triggered Rule 1...this would cancel the Lights Off if you happened to manually turn the switch off and then back on during the time lights should have been on from motion.

image


#9

Yes, I did, Thanks again. Testing now with 2 minutes turn off.


#10

Tested your first crack, worked perfectly, thank you so much! :sunglasses:

I will test the second with another switch, then if it works, I suppose yes, I will change first switch to reduce one rule.


#11

Hello @destructure00

Using your first crack, if I want to restrict the switch to turn on only between sunset and sunrise, which of the 4 rules I suppose to modify, all of them?

Thanks so much, WAF was very high yesterday thanks to you.


#12

I'd restrict "Trigger 1" and "Trigger 2". This will prevent motion from turning the lights on or off during the day. The other ones I don't see a need to restrict, doesn't hurt anything if they run during the day.


#13

Thank you!