Routine for door sensor to control garage light?

I need assistance creating a routine in ST. The door sensor is the trigger.

I will open and then close the door to the garage to turn on the light switch. When I return to the house I open and close the door and the light switches off. How do I structure the routine to accomplish this task?

How are you triggering the door to open? Are you doing it manually via a garage door opener? Do you want the Routine to trigger the door to open/close when you arrive/leave home? Are you using Location Modes to track whether you are home are not?

The challenge here is that opening/closing the door is not sufficient triggering/bounding conditions to determine whether to turn the light on or turn the light off since there is nothing to indicate whether you are leaving or coming home. In either case, the door will open and the door will close. You need something more like:

If “I’m Home” (pre-condition)
Garage door sensor opens
Then Turn on light

If “I’m Away” (pre-condition)
Garage door sensor opens
Then Turn off light

1 Like

I have a door sensor on the door leading to our garage. My current routine will function just fine if we leave the door ajar. When the door is opened the ceiling light comes on via a smart switch. When we come back in and close the door the lights are turned off. The preference is to open the door and go into the garage and shut the door behind us. Currently when the door is closed the light will shut off. Hope you have a suggestion on how this routine should be structured.
Thanks, Mike

To solve a similar problem, I put a motion sensor in my garage and the light is turned off when no motion is detected for X minutes.

1 Like

Tyler has the best suggestion.

This was the very first automation I created when setting up SmartThings almost 5 years ago.

If you can install “Smart lighting”, then it’s one automation to turn light(s) on when motion detected and turn them off if no motion for x minutes.

If you can’t access Smart lighting, I think you’ll need two Routines.

Blockquote

oh…

1 Like

All good if you’re rigidly in that pattern.

What happens if a second person comes out while you’re still out? Or if you know you’re only going to be in the garage for a few seconds so you don’t close the door until you go back in the house? Or if you come out to the garage, then drive away?

2 Likes

I would guess you would need to evaluate your situation and do something that suits you.

Forgive my attempt at a potential framework of a solution. I will not do that again.

I appreciate your attempt to assist me but your avalanche buried me for a while. It seems that I was making the process too complicated. My routine that I have now works fine as long as I leave the door ajar while we are in the garage.

Thanks again, Michael.

I don’t have a perfect solution either. I might have to consider the other recommendation to add a motion sensor in the garage.

In our case, I have an open/close sensor on the door from the house to the garage. I also have a tilt/vibration sensor on the roll-up garage door.

The logic I have is if the interior door is opened and the light is off (precondition), turn on the garage light and set it to turn it off after 10 minutes.

Opening or closing the roll-up garage door will also turn the light off.

So if someone enters the garage to look for something or to get in the car to leave, the light will turn on for them. The light will stay on for other people coming into the garage. Then if we open the garage door to drive away, the light goes off.

This doesn’t handle the case of going back in the house. So far we have just trained the last person to open the door into the house and then either close the garage door (light goes off) or turn off the light manually. Also, if someone forgets, it will still turn off after 10 minutes.

If someone needs to work in the garage for longer than 10 minutes, they can go into the garage, then turn the light off and on. This will stop the 10 minute timer from turning off the light.

1 Like

My routines run a bit differently. I am using the Smart Lighting App. This requires that you have a smart garage door opener, or a sensor on the door to know its state (open/closed).

When my garage door opens, I turn on the garage light and the inside light. I use a motion sensor in the garage, in a different automation to turn the garage light off. You could also use a timer.

When I open the back door to the garage, it turns on the garage light. I limit this to between sunset and sunrise.

1 Like

Sorry to bombard you with too much info. The basic issue with what you want to automate is that there is no way to tell the difference between opening/closing the door to go into the garage and opening/closing the door to go back into the house. There needs to be something to discern the difference or you have to make some assumptions about behavior, as in the example of closing the door a second time means the light should be turned off.

Other than your current solution, I agree with the other suggestions of adding a motion sensor in the garage to detect when someone is in the garage for determining when the light should be on/off.

1 Like

Sorry to see you’ve deleted the Rule code that you suggested, as I was starting to look at it for a similar, but not identical situation I have.
I’m just getting into the rules API, although I find it heavy going not being a programmer. I can find my way around javascript etc type script but I find that the use of JSON in this case is so visually unfriendly and open to multiple errors, but there you go…I suppose there must be a good reason for it.
I find that a community is all the stronger if there are many and varied contributions, which all go towards improving the knowledge base.
So, just to let you know that I for one found it interesting and am sorry you’ve taken it down.

If you click on the pencil in his post, the rule is still visible.

Thank you, didn’t know that!

1 Like

Hi, did you solve your problem yet?? If not please take a look at this video on YouTube: