Smart Motion Triggered Light Restore

I am struggling with building a rule that does what I need it to do. And I suspect I just don't have a clear enough understanding around the cancelable events. Here's what I need to do:

When motion is detected in the hallway (this part is easy):

  1. capture the current state of the hallway lights
  2. adjust dimmer +20
  3. wait for no motion
  4. delay for 1 minute
  5. restore the state of the hallway lights

This is what I struggle with:

  1. if the physical hallway dimmer is changed (on/off/dim setting) at any point during the rule execution, then I want to cancel the restoration. This includes while motion is active and after it has become inactive (during the 1 min delay).

I'm not sure how to accomplish #6. Also, can this all be done with one rule, or does the physical switch cancellation need to be triggered from a separate rule?

Thanks in advance.

Dan

Annotation%203

Okay...let's start to unpack what you have here.

First of all, your use of a wait with a timeout is incorrect. This will have the effect that it waill wait up to 2 minutes for motion to go inactive and then., even if it is still active, it will proceed with the rest of the rule.

Next, this is going to be a lot easier if you assign a specific level to turn the lights on to when motion is detected. Then you can simply look at the current level when motion goes inactive to see if you should turn them off. With your current setup that is possible but it becomes necessary to use variables and becomes a lot more complicated. So, if you can establish a set level, let me know. If not, we can work it with a variable.

I want the variability... basically I don’t want the light to be “shocking” when it comes on (I had considered just a long delay to avoid a shockingly bright light but a long delay defeats the purpose of instant motion triggered light). Just subtle changes is what I’m shooting for. Might sound weird, but it is a small, fairly dark, frequently used hallway. If the light was off And it was nighttime, Dimming it over 60 is super bright. But There is a single window so in the daytime, 60 isn’t that bright. I didn’t want to tie it to modes, rather the current state of the light because a human might have set the dimmer where they want it for good reason.

Dan

Okay...but if there is a window, do you need the light on during the day?

Also, I do not understand your logic for the motion active. Why do you have a motion lighting rule for lights that are already on? This logic....

image

Is the part that I don't understand. So, I am just going to ignore all of that and you can sort that out by yourself. I'll leave a placeholder in the rule I'm going to lay out for you.

So, first, your triggers should be motion changing. You also need to create a local number variable. I will call in dimmerLevel. You also need to create a local boolean variable I'll call enable. The default for enable must be true. This is what i would have for my actions:

If Motion is Active then
     Cancel Delayed action
     If enable is true then
          Capture state of the light
          SET THE LIGHT HOWEVER YOU WANT HERE
          Set variable dimmerLevel = the dimmer level of the light in question.
          Set enable to false
    End-If
Else
     Delay actions by 1 minute (cancelable)
     If dimmer level of lights = variable dimmerLevel THEN
          Restore lights
     End-IF
     Set enable to True
End-If

Now, the enable to true, I don't know how you want that to happen. Because I don't know what you would do with the lights after manually changing them and canceling the motion off. You could move it inside of the if/then with the restore and then also make another rule setting it true when the lights turn off if you want too. You would then have to make it a global variable.

I will say, this is a lot more complicated than I would expect for a hallway. There are ways that this could be vastly simplified to make it run a lot quicker. But this is what you asked for...

You also realize that by having the first else-if not contain the switch being on, that this will trigger as true if the lights are off but the last level they were set to was less than 60, correct? Also, I don't understand why you have < 60 and <50. Those are awfully close together.

Ok I see now how to do it. I will try out your solution. Thanks for taking the time to share how you would accomplish this.

Regarding my dimmer levels (50, 60) being close together, these will be updated later...it was hastily put together to get the concept configured, knowing I will optimize it later. But yeah it does look crazy to me too!

Thank you, I will report back on how it worked out.

Dan

1 Like

Okay...that means I'm not going crazy. :slight_smile: in the end, it really doesn't matter how you set the lights, as long as you capture the variable after the lights have settled. You may have to put an action of delay of 3 seconds before the capture if you are going to fade them slowly. Give them time to reach their final level.

@Ryan780 Your solution worked perfectly and I learned something along the way. Thank you for your suggestion.

Dan

1 Like