Help with a conditional rule

Guys,

I need a rule to turn on a light when motion is detected, and then turn it off after 3 minutes, but these are the conditions.

  • only between sunset and sunrise, certain time or based on illuminance. (I'm using aqara motion sensor and I'm not sure if it is capable of measuring illuminance)

  • run the rule only if the light state is off

Thanks

Try something like this ....

Trigger:

When motion is *active*
OR
Certain Time

Actions:

IF (Lights On): Exit Rule
IF (Certain TIME) OR (Motion is active AND Time is between Sunset and Sunrise) THEN
    On: Light
    Off: Light --> delayed 0:03:00 
END-IF
2 Likes

Thanks @aaiyar,

But wouldn't it be AND instead of OR ?

There is no AND in triggers.

Also, there is an inherent contradiction in your description so I have interpreted it as such:

Lights are turned on under two conditions:

  1. When it is a certain time (and lights were not previously on)
  2. When motion is active AND when the time is between sunset and sunrise (and lights were not previously on)

Under all conditions, lights are turned off after 3 minutes.

Is this interpretation correct?

Edit: I should add - "Certain time" means a very specific time like 6:23 PM.

1 Like

What I need is to turn on the light automatically if someone walks in my living room only if it's dark and light is off and then turn it off after 3 minutes.
Sorry for my poor English.

Ah - ok. Then we can forget about the certain time. I don't know if the Aqara sensors do lux, but if they do ......

Trigger:

When motion is *active*

Actions:

IF (Lights On): Exit Rule
IF (Illuminance > 100): Exit Rule
IF (Time is between Sunset and Sunrise) THEN
    On: Light
    Off: Light --> delayed 0:03:00 
END-IF

Replace the 100 with whatever lux value is appropriate for your needs.

2 Likes

What if motion becomes active again? Do you want to cancel the off?

2 Likes

Thanks @aaiyar
@JNS sure, I need it to still on for as long as motion is detected.

I don't want to steal @aaiyar thunder :grinning: Do you want to post that or should I?

2 Likes

Nah do it - I'd originally started out with motion is changed but then decided that it wasn't the right time ....

3 Likes

Before I post that is there any reason you're not using the Motion Lighting app for this?

1 Like

Well, no reason.
Actually I started with rule machine to practice and learn and didn't know about Motion Lighting app.

@jmarcim

@JNS makes a good point - that is a better choice for this application.

2 Likes

Fair enough. I'll post it for Rule Machine but Motion Lighting is the way I would go for this. Select 'Apps' and then 'Add built-in app' select Motion Lighting apps. There are restrictions for Lux and Time in that app.

1 Like

I'm already having a look at that and it looks great, even though I need to learn making rules.

Try search for Lights on motion pluss app and install that. It's an easy one, if you give up RM. :wink:
I have this app running in the living room and here is my rule. Change to 3 minutes instead of my ten, you find under restriction part. Good luck.


RogerThat

2 Likes

Lights on Motion Plus is another option. Try them both and see what works for you. I tried and didn't care for Lights on Motion Plus.

I would stick with the built-in apps first so you know what's available out of the box and then try the other app. That is just my preference. Do whatever makes sense to you.

Here is the RM actions. Depending on how you want this to respond you could move the Cancel delayed actions before the IF statement.

4 Likes

Great @JNS, I'm trying it.
Thanks a lot guys.
I'm loving my Hubitat thanks to this community.

4 Likes

Hmm,
I can’t see this rule turn off the light until next morning when the lux is above set value, if triggered after dark? Does it?
I guess a switch or dashboard tile is used for that, for this one?

The goal I had was to fully automate the light, without any switches, and at the same time minimize the agressiveness and need to keep moving in the room, more than natural. And to be honest, there is not so much movement when laying on the couch and wathcing TV, even with 2 people in the room.
But one motion sensor looking at the room from one side, close to entry points, and another one in the window closer to the U-shaped couch, seems to work pretty well to achieve this. Both with catshing arm movements and the right time to turn on the lights based on outside darkness. Its a tuning thing, so it takes some tweeking, for usre. :slight_smile:

Hope you manage well!

RogerThat

OMG. There is an exit rule command? See you just never stop learning. Lol.

3 Likes

Download the Hubitat app