Rule for motion detector

Hello, my rule for motion detection turns the light off after 2 minutes.
It after two minutes still motion in the place it turn light off too.
Is thera a way to turn the lights only off, if there is no motion?
here is my rule:
rule “Bewegung_Flut_True”
Item BewegFlur changed


  if (DayNight.state == OFF){

var Timer boilerTimer = createTimer(now.plusMinutes(2), [ |

      if (DayNight.state == OFF){


Thank you for Help!!!

This is a very basic requirement. See [Deprecated] Design Pattern: Motion Sensor Timer if you want to implement this yourself. If you’d like to just instantiate and configure something, see Debounce [;].

At a high level you’ll create an Item that is linked to the light. The Item linked to the motion sensor is added to a Debounce Group. That Item needs the Debounce metadata (see the link for details).

Properly configured, the light will turn ON immediately upon the first motion detection and OFF only when no motion has been seen for a given amount of time.

You could remove the timer and use the expire metadata thingy. That would be the simplest solution I think.

1 Like

Expire only works on a single Item. You can’t expire on one Item and control another Item. So Expire will only work if the only way that this light can be controlled is through the motion sensor. If it can be independently controlled Expire won’t work.

Yes I use the expire all the time.
I have the expire on the light and a rule that says if motion then turn on the light.
If there is motion before the light expires then the expire time gets reset automatically.
No need for time rule I just let expire take care of it.
Screenshot from 2024-01-23 08-54-08

Screenshot from 2024-01-23 08-55-45

Ah yes, if you set expire on the light, it will turn off even when you wanted to turn it on longer by manually turning it on (e.g. a switch on the wall).

This is a case I specifically handled in my Motion Trigger DSL.


  • Pre-action can be specified for each light, e.g. to adjust dimmer level
  • When the relevant light(s) were turned on manually (not by the motion sensor), or by another unrelated rule, specify a longer duration (I call it manual_duration for the lack of a better name) to turn it off. The default is 1 hour but it’s configurable, or disabled, on a case-by-case basis. This avoids the annoying premature darkness when working in the room whilst being still. This ensures that lights will eventually turn off even when manually turned on and forgotten.
  • Debounce feature, to prevent immediate re-triggering after the light was turned off manually.
  • Other (and multiple) sensors or events can trigger the same light if desired, e.g. motion, door opening, arrival/departure, camera, basically any Switch or Contact item.

Yes the only downside is if you want the light to stay on when not triggered by the motion sensor.
In my case I don’t need that.