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.

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.

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.


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.

Okay. Haven’t done something like this before. Is this done in Rule Machine?

Yes, that is a Rule Machine rule.