Pantry Lights Automation

I am completely lost with rule machine, I am afraid I absolutely don't get it. I wrote my own smartapps in ST for various situations and I am trying to re-create my automations in rule machine.

I have a contact sensor on my pantry door (sliding barn style doors) and I added a motion sensor because many time the kids leave the door open and the lights would never turn off.

This is what I am trying to do:

If the pantry door opens, turn the lights on
If the pantry door closes turn the lights off
If the door is left open and there is no motion turn the lights off after 5 minutes
If the door is open and there is motion turn the lights on

Thank you for help in advance.

you could just use simple lighting for this but:

triggers:
contact sensor changes
motion sensor changes

If Pantry door open
and
motion is active
then
turn on pantry light
cancel delayed action
else-if
pantry door is closed
then
turn off pantry light
else-if
pantry door is open
and
motion is inactive
then
turn off pantry light delay 10 minutes cancelable
end-if

There's a hundred ways to do this right. this was my first thought. I'd probably end up revising it a time or two to make it more efficient. But here's a start.

[Edit]
I'm just going to add that KISS is better. If it can be done simply, then it'll run better. Like @Brandon is suggesting motion lighting. Good advice.

2 Likes

Motion Lighting with Bruce's contact as a motion sensor works great for this.

1 Like

Also here is my rule for completeness.

I’ve got this exact rule written.

Here’s how I do mine:

Edit: this rule has been through a lot of changes and trial/error to see if there were any performance differences. If (when) I write it again, I’d write the actions as:

  1. Cancel delayed actions
  2. If Open
    A. Light: On
    B. Turn off Light > Delayed & Cancelable: N minutes
  3. Else
    A. Turn off light
  4. End If
2 Likes

Thank you for the answers, I ended up doing it with the built in motion lighting app.

2 Likes