Motion Lighting

I have a rule for garage motion. I have been using the Motion lighting App but it seems to not turn off the lights when already on. New condition. So. I have a RM set up.
My goal. Tune on lights, if night, when motion if detected. Wait for motion to be inactive for 30 minutes.

Should this rule run even if the light was left on or turned on manually ? What I’m having issues with is that if the light was manually turned on and/ or left on before night. They stay on all night and seem to ignore motion inactive.

Can you post the full rule from RM? It will be easier to help.

Recommend to use Room Lighting. Here is one of mine with both motion and a switch-based timer.

The rule itself is fairly straightforward using a conditional of night and motion. One example:

Required Expression: Night
Triggers: Motion active; Motion inactive and stays for 30 minutes
Action: If Motion, turn on light
Else, turn off light.

Your issues will continue to happen as long as there is no event to trigger the rule during night. One way around this is to have a second rule that checks the status of the light and motion when night happens. Something like:

Trigger: Night
Action: If Motion inactive, turn off light.

The second rule turns off the light when night happens if there is no motion in the garage. This will then set up your first rule to work as normal.

Sorry. I meant to attach when I posted. It’s been updated and attached.

Your rule looks fine; though, it might need a slight modification to prevent it from running multiple times. You might want to use a Private Boolean as true in the required expression. Then, your first action is set the Boolean as false and your last action after the light goes off is to set it to true. This way, your rule only runs once.

With that said, my suggestion of a second rule would help set everything up. Have the trigger be sunset-20 and check the status of the light and motion sensor. If the light is on and motion sensor is inactive, have this rule turn off your light.

IF I was out in garage, the rule shall wait for the event " no motion" .. Then trigger off after the set time period.

What would make the rule fire more than one? Curious-- learning process.

Not quite. If you stood perfectly still so that the motion sensor went inactive, the rule would trigger again with any motion. Now this would cancel your original wait due to the rule retriggering. Basically, it would reset your rule. If this is desired, then you do not need to add the Private Boolean. Some folks do not want this behavior, and as such, add the Boolean to prevent the rule from triggering again.

ahhhhh- Gotcha- I have this on my front door motion... to prevent false triggers during storms..

I have added this - I also added another RM to turn the light off, when no motion is detected.... for back up so this rule shall run as it is intended. I would think I could put something In this rule to serve the same purpose... Not sure how.. " This is a rabbit hole" LOL

The issue is related to your required expression and having it be a time period. How does this light behave during your other time periods? Do you have a different rule for day time?

I use the light manually during day time. This rule is intended for light to turn on when garage door is opened, or you enter garage at night through walk in door.

The time period will always cause issues with your rule depending on the status of the light as you transition into and out of the period. Since Hubitat is event driven, you need an event during the time period for your rule to run. Without a motion active during the time period, your light will always stay on unless you set up a second rule to check the status of the light and sensor at the beginning of the time period.

With the above said, I do agree with @bill.d that Room Lighting is probably going to be your best option rather than rule machine. It can cover both use cases and does not need to be configured for a time period. His example is something would work work as it contains options for Activation (either motion or manually selecting the switch) and turning off (motion inactive or manually turning off the switch).

Understood. I was under the impression that apps, such as room lighting, are based off the same architecture of RM. is that not really the case ? Just curious and a sponge ATM.

Room Lighting is independent of other apps. As you may see by now, Room Lighting has a lot of light specific functionality in a single app that would require multiple Rule Machine apps. Rule Machine and Button Controller have a lot of shared code/functionality. More or less a button controller app uses the button push as a trigger to run a rule.

Everything in Hubitat is based off the idea of an event happening and this event causing something else to happen. It does not matter whether you use Basic Rules, Rule Machine, Room Lighting, or anything else. An event triggers and then some action occurs.

If you look at the Room Lighting example and apply it to your own wants, you'll notice there are two actions/events for turning on the light: manually turning on the switch or motion on your sensors. Either one of this events will turn on the Room Lighting instance and have your light turn on. Then, there are two actions/events that turn off Room Lighting and your light: manually turning off the switch or motion inactive and stays. Room Lighting will always turn off your light if you manually turn it off or you forget to and the inactive/stay triggers. There is no need for time periods unless you want to activate the light at different levels for day and evening.

Now, if you really want to use Rule Machine and only have one rule, here is how I would set it up. First, I would install Zone Motion Controller | Hubitat Documentation and combine your motion sensors into one virtual motion aggregation zone with an activity timeout of 30 minutes. This virtual sensor is key as it allows you to combine all the real sensors into one and it will only show inactive after 30 minutes of no motion. From there, you could set up a rule like:

Required Expression: Sunset-20 to Sunrise
Triggers: Sunset-20; Sunrise; Motion on virtual sensor, Inactive on virtual sensor
Actions:
If sunset-20 and light on and virtual sensor is inactive, turn off light
else-if sunrise and light on and virtual sensor inactive, turn off light
else-if motion, turn on light
else-if inactive, turn off light
End-if

The above rule will only run between 20 minutes before sunset and sunrise per the required expression. From there, at 20 minutes before sunset, it will check to see the status of the light. If the light is on, but there is no motion on your virtual sensor, it will turn off the light; otherwise, it will do nothing at this time. At the end of your time period, it will check again and potentially turn off the light. It will not turn off the light if it is already off or there is motion in the garage (which assumes that someone will manually turn off the light since we are now at sunrise).

With the required expression dealt with, the rest is fairly straightforward. Motion will turn on the light and Inactive will turn it off. This rule also covers a fringe case of turning on the light and forgetting to turn it off. It will either turn off the light at sunset-20 or when the virtual motion sensor goes to inactive. The latter happens because it registers as an event, but is now in the time period required expression allowing for your rule to run.

Found it, was a little overwheling at first but I see the idea behind it. I moved this to that app. I was buidling others based off wait events, with mutiple steps in-between. Im slowly moving them to the Room lighitng now, for its function wihtout building, and testing, detailed rules.

Would be cool to add more features for thsoe whoe have very detaile rules with Boleans.

Thank you for all your help.

Got it orkin- I added that messign with it.. I deleted t he APP and reinstalled this room.

One thing I noticed, if it only activates during night, does this mean the if the switch is manully tuned on, it will not turn off if mpotion is not present durign the day?

Remove the ā€œdon’t activate if turned off manuallyā€ option. This is preventing the motion sensors from triggering if the last time your turned off the lights was manual. You want to have basically the same options selected that was in the example.

I added that while messing around with it.

I’m in the garage now and the sensors do not show active in the app. In the devices, they are.