How to use Motion to trigger something only once

I have a motion sensor on my stairs which triggers certain lights to go on between 4:30 am and Sunrise +30. Some of these same lights are told to go off by another automation.

The problem is that they get turned off by the second automation and then get turned on by further motion detection.

Is there some way to tell the motion triggered automation to run only once?

So you only want motion to work once after 4:30 AM (until the following day)? If so, how you'd do that depends on how your existing motion automation is set up. It's something you'd do on the app side of things and not the device side, so I'd suggest sharing how you have that automation set up.

If the problem is that you want motion to work after the other automation turns the light off (but it doesn't), you're probably running into the situation where motion hasn't had time to "reset" to inactive so that real-world activity will actually generate an event (motion active). This is something I've seen people run into occasionally, but it sounds like your question is not related--just mentioning in case it is and I misunderstood. :slight_smile:

1 Like

Assuming youā€™re using the motion and mode lighting app to turn the lights on with motion, Iā€™d create a virtual switch that is configured to disable the motion rule when on, and use the same automation that turns the lights back off to turn on that virtual switch. Use another trigger (like a mode change) to turn the virtual switch back off once itā€™s okay for the motion trigger to fire again.

1 Like

Maybe in the conditions have motion active AND private boolean is false.

In the actions after turn light on set PB to true.

Have a trigger for certain time set to 04.15.
Have a statement in the rule IF time is 04.15 set PB to false.
Rule will then only be true once a day for turning the light on.

1 Like

Iā€™m relatively new to HE some Iā€™m learning some of itā€™s capabilities. This is about the fanciest thing Iā€™ve setup so far. Hereā€™s what Iā€™ve set up:

The motion sensor triggers certain lights to go on if it detects motion between 4:30 am and 30 minutes after sunrise. A separate routine is set to turn a subset of these lights off at 31 minutes after sunrise. Unfortunately, it appears that further motion is turning the subset of lights back on after the second routine has turned them off.

Is the difference of 1 minute not enough or is something else going on?

If I could simply have the motion trigger the lights only once that would fix it but Iā€™m unclear on how to get this done.

Thanks,

The first thing to ask is "do you want the lights to trigger just once, and no more, during 4:30 and 30 minutes after sunrise". If motion is detected a second time during that interval the lights must not turn on?

If so, I can show you a rule to do this.

Could you setup a variable or virtual switch and use it as a condition to turning on the light?

If Motion active, and variable = false and time is before 31+sunrise
    Turn on light
    Set variable to true

Then every day at 4:30am, reset the variable.

Sorry if my logic is confusing, I just migrated from ST, so I do a lot of webcore.

Edit: This might be simpler, if I understand you correctly here:

It sounds like you want the lights to come on, and stay on until sunrise +30 minutes.

Could you just add a condition that the motion sensor automation doesn't run if the time is sunrise + 31 minutes and not before 4:30am?

This is my second attempt at RM:

If you only want it to turn on once during that time, this should work for you.

1 Like

Okay. Havenā€™t done something like this before. Is this done in Rule Machine?

Yes, that is a Rule Machine rule.

bobbles,

Is this it?

image

1 Like

Personally I would change the trigger and the first IF time to 04:25 so that it is done before the 4:30 to sunrise window just in case you should trigger motion at exactly 4:30.

Thanks, but Iā€™m really not worried about that.

Bob,

The automation worked perfectly this morning.

Is there a way to edit these rules once you've made them or do you have to rebuild it from scratch?

Thanks for your help.

Glad it worked ok.
Just select the rule in the UI and it will open up.
You can edit the rule when it opens.

1 Like

As @bobbles notes yes there is. Editing rules in RM can be a little confusing so take it slow and explore a little. :slight_smile:

This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.