How to customize lighting switch with sensor?

Here’s what I would like to happen.

If the smart light switch is manually turned on,
Then have the light on until the user manually switched it off regardless if the sensor detected motion or not.
Else, if the sensor detected motion,
Then turn on the light for 10 minutes if the weather is cloudy, rain, snow, or between sunset and sunrise.

How do I accomplish the above scenario?

What’s the brand and model of the switch? Different models have different reporting patterns, so it does make a difference. There are even some Wi-Fi models that don’t report if they are turned on manually at the wall.

2 Likes

You need one virtual switch and let’s call it VS-ON.

Routine 1 - If the smart light switch is turned on by a routine, then turn on VS-ON
If the smart light switch is On and VS-ON is off, then you know this would have been turned on manually.
Routine 2 - Turn off VS-ON at night shutdown / end of day so this will act as a reset
Routine 3 - If motion detected and VS-ON is on and Weather is cloudy, rain etc. then turn on light and turn off after 10 min

1 Like

Thank you so much for the input. That does make sense and it might work in my situation; however, I don’t think that can be done from within Samsung’s SmartThings iOS app. In the past I have played around with webCoRE but lately I have heard that webCoRE is going away and will not work with SmartThings. What’s your recommendations? Thank you.

Can you answer to JD’s question on the brand and model of the switch please?

1 Like

It’s been a long time and I don’t remember the brand and model. I’ll have to look. It’s not listed on the SmartThings app either.

By the way, I just found out that I do have the vEdge Creator V2.94 installed. I looked into the SmartThings Labs but for some reason iOS app do have switch creation available.

So, looks like I’ll be exploring the vEdge Creator.

@2Charlie, Exactly that and you are on the right track. You need to install the driver and create an alexa switch and follow what I said. Do you have a smartthings hub?

1 Like

Another quick question, does the current SmartThings app have the capability to creae IF-then-Else routines?

Okay, I couldn’t figure out how to do this routine. In the “If”, how do I specify if it’s turned on by a routine? The condition does not have option to select routine.

Not in the basic routines offered in the app.

This can be done with a third-party app, sharptools, which is easy to use and has a lot of features. It’s very popular in the community.

I believe you can also do it with the official rules API in SmartThings, but that has a pretty steep learning curve and isn’t well documented. So it’s a lot more like programming. There are a few community members using it, but not too many. There is a special section of the forum for it:

I was reading in another thread that SharpTools runs from the cloud and rules API runs locally. However, I was watching a " Create IoT Automation Using SmartThings New Rules API" video and it seemed that the execution of the JSON is also from the cloud. So if both are executed from the cloud then I think SharpTools is the way to go.

1 Like

Depending on the devices connected the Rules API rules can run either locally or in the cloud.

SharpTools is always in the cloud, but it is easy to use and reliable.

3 Likes

If your light switch supports “Toggle Up” as a trigger in Routines, that can be used to determine if the switch was manually turned on or not. If not, you can use motion to determine if the switch was turned on via a Routine vs manual and use a virtual switch to track that state. You would need four Routines to do what you want:

If Light is off (precondition)
   Weather is Cloudy/Rain/Snow (precondition)
   Motion Detected
Then
  Turn on Light
  Turn on Virtual Switch

If Light is off (precondition)
   Between Sunset and Sunrise (precondition)
   Motion Detected
Then
  Turn on Light
  Turn on Virtual Switch

If Light is on (precondition)
   Virtual Switch is on (precondition)
   No motion for 10 mins
Then
  Turn off Light
  Turn off Virtual Switch

If Virtual Switch is on (precondition)
   Light turns off
Then
  Turn off Virtual Switch

The last Routine is needed to turn off the virtual switch in the event that the light switch is turned on by motion but 10 mins has not elapsed and the light is turned off manually.

Assuming both the motion sensor, light switch, and virtual switch run locally, the above Routines should all run locally.

1 Like

Not as far as I am aware. You would need two routines for this; one for IF and the other for ELSE

This is why you need to set the virtual switch to On in the previous routine indicating that the smart light has been turned on by the routine. In the second routine, if the Virtual switch is on, then you know the smart light switch has been turned on by some routine so you just need to put your condition and check if the virtual switch is off

Yes, sharptools can do the trick but you may need to pay for this which is why I suggested to do this in Smartthings routines which is free.

Thank you so much for the detailed steps by steps information, much appreciated! I’ll give that a try tonight.

You can use the SharpTools rules engine for free unless you want to use variables and/or have http access.

If you need a simple on/off type variable you can create a virtual switch in SmartThings and use it as a variable for free.

With free rules engine you can use IF, Then and Else. It is quite logical.

It can also build automations between multiple ST locations which is not possible with ST rules.

2 Likes