Turn on lights once per morning

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.

Simon

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.

1 Like

Call it a draw.... :slight_smile:

1 Like

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.

Thanks for your help!

1 Like

Shame, recommending you get up earlier is taken off the table.... :slight_smile:

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.

See how you go.

Simon

1 Like

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.

1 Like

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.

@JohnRob, how does your rule set the PB to false at 1AM?

@pseudonym, does the IF condition being false prevent the trigger from affecting the actions inside the IF statement?

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.

@pseudonym, yes, thanks, I now see how that behavior of WAIT in rule machine works. I guess that was not how I expected it to work.

Does that also mean that the FADE action gets canceled?

Is there a recommended rule that could achieve the same effect?

Thanks for your help!

Brian

Simple,

Trigger:
"time = 1:00AM"

Actions with conditions:
IF (if time = 1:00 am) THEN
set PB to false

Ok, I've learned something new. :smiley:

@pseudonym, I accidentally addressed this question to the wrong person before.

In the same way that the WAIT action gets canceled, does the FADE action also get cancelled?

Thanks!

I believe the Wait being canceled on re-triggering is unique but I don't use the Fade action so I'm not sure how it's handled.

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,.

Thanks Everyone! This is my first attempt at rule machine as I step out of the most basic functionality of the Hubitat.

To achieve the desired efffect I ended up breaking the rule up into three rules.

  1. Motion pushes virtual button if the time interval is between 5-8AM AND the Private Boolean is true
  2. Virtual Button triggers the fade lights on and set the PB to False
  3. Sets the PB to TRUE at 8:01AM

Thanks!

1 Like