Hi, can you help me fix this rule. The objective is to fade on the kitchen cabinet lights once in the morning when motion is first detected. A second motion should not activate the rule.
This rule uses a Private Boolean to prevent second triggers from activating the rule.
I think the problem is in the wait time being outside the conditional time rage, but I think the condition should only limit when the action is triggered not when a triggered event actually occurs.
Here is the rule. The problem is that the Private Boolean isnāt flipping back to TRUE
IF (Time between 5:00 AM EST and 8:00 AM EST(F) AND
Private Boolean is true(F) [FALSE]) THEN
Set Private Boolean False
Dim: Sink Cabinet Lights, Stove Cabinet Lights: 10 --> fade: 0
Fade Sink Cabinet Lights, Stove Cabinet Lights up to 80 over 30 minutes with 60.0 seconds interval
Wait for event: When time is 8:01 AM EST
Set Private Boolean True
END-IF
Rather than an ELSE-IF, which would rely on the rule being triggered a second time in the 5-8 timeframe, what if you close off the IF after turning on the lights and put a delayed action to set the private boolean to false? E.g.
IF (Time between 5 - 8am and Private Boolean is false) THEN
Set Private Boolean True
Fade closet (ct) up to 80 over 30 minutes with 60.0 seconds interval
END-IF
Set Private Boolean False (delay 3 hours)
EDIT: Actually that is essentially what is in the original post.... Hmmm..
@Brian123 - Is the private boolean not being set back only when motion occurs after 7:30am, or always? Reason being, I would expect the rule to only move on to the Wait for event.... action when the fading of the lights for 30 minutes completes, so if motion occurs at 7:45am you would be past 8:01am before starting to wait for it.
You are correct, I should have read it more closely. It would only be the very rare chance of not triggering it again outside of the 5-8 timeframe which would mean the boolean is not reset. So in reality either option would work, including the one you put forward.
Hi sburke781, typically the motion trigger happens at 6AM and Iāve confirmed that the PB flips to FALSE. That would leave plenty of time for the 30min FADE before the action at 8:01AM to set the PB to TRUE. Do you think the action at 8:01AM isnāt happening because of the condition in the IF statement that limits the action to between 5-8AM? If so is that how youād expect the logic to behave?
I came up with that logic expecting that the triggered chain of events would execute as long as the trigger happened while the conditions were true.
Shame, recommending you get up earlier is taken off the table....
I would expect the actions to happen in sequence and so expect your version of the rule to work. Only suggestion I can make is to try the couple of variations @furom and I suggested to try and zero in on where the issue may be. Apart from a few slight tweaks to the IF-THEN-ELSE setup we came up with, the other adjustment we suggested was to use a delay. I didn't suggest that with any knowledge of any issue with the wait for event, mostly because I had used the delays myself.
What is likely happening is the rule is being trigger again. This will cancel the wait and not execute any subsequent action. Since the PB in now false, the condition fails and the wait for 8:01 isn't rescheduled.
Looks like you are right @pseudonym. The last paragraph in Bruce's post below confirms that the waits are cancelled, unless something has changed in the meantime.
I have a similar requirement. I set a PB to "true" when the lights go on in the AM. In the same IF statement I check for PB to be "false" else it won't complete execution.
The set the PB "false" at 1 AM (or whatever time you think is the next day.
Why aren't you just using a virtual switch for this, instead of of PB? As long as the switch is on, the motion sensor can trigger your routine. As endpart of the routine, the switch is toggled off and turned back on at a specific time.
Let me see if this answers your question. Re-triggering a rule creates another instance of the rule actions. Any Wait from a previous instance will be canceled. It doesn't matter if that Wait was part of an IF condition that is false during the re-trigger.
i am not sure what your end goal is but i have a similar rule not based on motion that resets the brightness in the morn (since the last use based on motion in the middle of the night has the brightness low). My rule looks like this,.