Rule machine motion controlled lights

Keep in mind this is my first attempt at writing a rule machine rule

IF (Illuminance of Wink sensor(12) is <= 250(T) AND
Wink sensor active(T) AND
Time between Sunrise and Sunset(T) [TRUE]) THEN
On: Kitchen Light --> delayed: 0:02:00
Dim: Kitchen Light: 95
ELSE-IF (Time between Sunset and Sunrise(F) [FALSE]) THEN
On: Kitchen Light
Dim: Kitchen Light: 1
IF (Time between Sunset and 9:00 PM EDT(F) AND
Wink sensor active(T) [FALSE]) THEN
Dim: Kitchen Light: 90 --> delayed: 0:02:00
IF (Time between 9:00 PM EDT and 12:00 AM EDT(F) AND
Wink sensor active(T) [FALSE]) THEN
Dim: Kitchen Light: 70 --> delayed: 0:02:00
IF (Time between 12:00 AM EDT and Sunrise(F) AND
Wink sensor active(T) [FALSE]) THEN
Dim: Kitchen Light: 25 --> delayed: 0:01:00

You have 4 IF statements.. zero End-IF.

If's and End-If's must match.. the same way ( and ) are paired/match in english sentences.

You'll want to edit in an End-if before each of the IFs there in the middle and again as the very last line.

Would that be after the action and before another if started

This is after I edited it.

IF (Illuminance of Wink sensor(12) is <= 250(T) AND
Wink sensor active(F) AND
Time between Sunrise and Sunset(T) [FALSE]) THEN
On: Kitchen Light --> delayed: 0:02:00
Dim: Kitchen Light: 95
END-IF
ELSE-IF (Time between Sunset and Sunrise(F) [FALSE]) THEN
On: Kitchen Light
Dim: Kitchen Light: 1
IF (Time between Sunset and 9:00 PM EDT(F) AND
Wink sensor active(F) [FALSE]) THEN
Dim: Kitchen Light: 90 --> delayed: 0:02:00
END-IF
IF (Time between 9:00 PM EDT and 12:00 AM EDT(F) AND
Wink sensor active(F) [FALSE]) THEN
Dim: Kitchen Light: 70 --> delayed: 0:02:00
END-IF
IF (Time between 12:00 AM EDT and Sunrise(F) AND
Wink sensor active(F) [FALSE]) THEN
Dim: Kitchen Light: 25 --> delayed: 0:01:00
END-IF

Very very close, but the first END-IF (before the ELSE-IF) is in the wrong place.. the IF surrounds the ELSE-IF too.

you want that END-IF to be between:

Dim: Kitchen Light: 1
IF (Time between Sunset and 9:00 PM EDT(F) AND

The logic is

IF....
..ELSE-IF
..ELSE-IF
..ELSE-IF
END-IF
IF...
END-IF

Or variations of above.

I tried to put one there too after I put the one in that you said is in the wrong place and our wouldn't let me. I'll try it again after I delete that one and see if it will work. I thought maybe it was because it was an else-if

OK I was able to fix it.

On: Kitchen Light --> delayed: 0:02:00
Dim: Kitchen Light: 95
ELSE-IF (Time between Sunset and Sunrise(F) [FALSE]) THEN
On: Kitchen Light
Dim: Kitchen Light: 1
END-IF
IF (Time between Sunset and 9:00 PM EDT(F) AND

Thank you for all your help. I really appreciate it

My goals for this rule are

Sunrise to sunset
If the light level is below 250 and there is motion the lights will turn on at 95% with a 2 minute delay and then turn off.

Sunset to sunrise
Lights come on at dimmer level 1. If there is motion between sunset and 9pm dimmer will set to 90% with a 2 minute delay and then back to 1%.
If there is motion between 9pm and midnight dimmer will set to 70% with 2 min delay and then back to 1%.
If there is motion between midnight and sunrise dimmer would adjust to 25% with one minute delay and then back to 1% until sunrise.

Will this rule work and if so is it an inefficient way of doing it. Was there an easier way to accomplish this.

FYI - this action will turn on the light AFTER a 2 minute delay. Probably not exactly what you're wanting. :wink:

2 Likes

I would use Hubitat's built-in Motion Lighting App. It has a ton a features and works very well. You could also combine the Motion Lighting app with "Modes" of the hub.

Use the built-in Mode Manager App to set your home's mode based on specific times of day, and/or relative to Sunrise/Sunset. Once you have the modeof your house changing automatically, you can then base your Motion Lighting automations off of mode, and have settings per Mode.

For example...

You were right. That's exactly what it did and wasn't what I wanted

The motion lighting app would probably work if I could get it to change the dimmer level when the motion sensor was activated. Since it's already on dimmed low it won't change it. It will turn it off after the set time though.

1 Like

Is it possible to make a simple RM rule that a motion sensor would turn on a light for say 2 minutes. If there was motion during that time it wouldn't turn off for another 2 minutes and until 2 minutes passed without motion.

I said simple and I thought it would be but it sure doesn't seem simple. I've run I don't know how many little test rules and hate to admit it but it's kicking my @ss.

I know it can be done with the motion lighting app but that doesn't seem to work for my application so any help anyone may offer sure would be appreciated.
Here's a sample from my latest failed attempt with the motion sensor the trigger.

Dim: Kitchen Light: 100
IF (Wink sensor active(F) [FALSE]) THEN
Delay 0:02:00
Repeat every 0:02:00
Off: Kitchen Light
END-IF

Take a look at @bravenel's example RM4 rule that does just that...

@ogiewon Thanks for responding again. That's a little over my experience level but not sure it would work for me.

This is what I'm attempting to do. At a specified time kitchen lights come on dimmed low as night light for that side of house. Have a motion sensor to turn up lights while in kitchen and then return lights to dimmed state after kitchen is unoccupied.

This is as far as I made it. I have a simple lighting rule to turn the lights on dimmed low based on a certain time. I have the switch as a trigger that returns them to that setting whenever the switch turns off. Anytime there is motion and the lights turn on(are already dimmed) and then off after the delayed time they will re dim themselves.

I couldn't get the motion lighting app to change the dimmer setting on motion because when I checked the logs it said they were already on but would turn them off after set delay. I saw some different options for adjusting the dimmer settings with Rule Machine and thought that would work but I can get the motion part working right.

Man, didn't mean for that to be so long. :grin:

The example you showed me do the lights stay on as long as there's motion and then run down the timer?

Yes, the lights come on immediately when motion is detected. After motion stops, a 2 minute timer starts. If motion starts again before the timer ends, the timer is cancelled and the lights stay on. If the timer expires, the lights are turned off.

1 Like

I got it, somewhat anyways :smile:. I needed a cancel on truth to reset the clock when motion was reintroduced. Without it that's why all my little test rules would never last more than 2 minutes.

1 Like

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