Help with a Scenario

Hi all,

New to the forum so first post for me as just looking for some guidance for this particular scenario to see if the SmartThings app could be the solution for me…


  • Porch lights controlled by a sonoff switch and set up via eWeLink app.
  • Ring video doorbell
  • Echo and Alexa app

Desired scenario:
When motion is detected on the Ring doorbell between the hours of sunset & sunrise, turn the porch lights on. When no further motion detected for 5 minutes, turn the lights off.

I currently have this working via Alexa routines BUT just from a set time period, as I cannot find a way to integrate the sunset/sunrise time in the “IF” conditional side of things.

I am hoping the SmartThings app and the knowledge of the devs on here can help me :slight_smile:


In the SmartThings app, in the If section, choose Add Condition.

Choose Time

On the next page…

  • choose “Period of Time” at the top.
  • below that, highlight “Start”
  • below that, highlight the “Night” tab

The Start time should now say “Sunset” and the End Time should now say “Sunrise”, but there’s a bug in the app (current iOS app on iPhone 11 Pro) where that will show as “Sunrise” for both the Start and End times. However, just ignore that and assume it means “Sunset” as the Start Time and “Sunrise” as the End Time. (Maybe @blake.arnold or @Lars can have someone fix that display bug. Same thing happens if you choose the Day tab, as it will display “Sunset” as both the Start and End time, when the Start should display Sunrise but incorrectly shows Sunset for both Start and End). Later in the automation editing process you should see it showing correctly as Sunset to Sunrise.

Click Save, then you’ll get what seems like an error, that it can’t save the automation. This message explains that “Period of Time” must be used along with other conditions”. Click OK, then add your motion sensing condition.

The above post explains how to set the Sunset-Sunrise time period for the Automation condition.

You can set up something like this:

However, I’m not entirely sure of the best way to set up the automations to accomplish exactly what you want, because I’m not totally sure how SmartThings treats motion sensors and the timers associated with them.

Using a single automation, as shown in the screenshot above, should mostly work. But, I would assume that it would turn off the light 5 minutes after the point when motion is first detected (when the light turned on), EVEN if there’s been frequent motion since then. At the 5 minute mark, the light would shut off and you’d have to have new motion to turn it back on.

Another way to do this might be to have 2 automations: one that turns the light on when motion is detected (but never shuts it off), and a second automation that turns it off when there’s no motion detected for 5 minutes. Then, it will turn on at the first sign of motion but won’t turn off until the motion has subsided for 5 minutes.

Thanks @jamesdvb for your help here.

I had started having a play around with the sunset/sunrise time period and I couldn’t get it to do what I wanted. It all makes sense now that you have told me about the bug on iOS… I’ll give that another go.

So the next sticking point for me is how do I go about switching on my sonoff receiver, as this device type doesn’t seem to be supported on SmartThings? Would I need to create a virtual sensor for Alexa to pick up (as Alexa can control the sonoff). If so - how do I do this?

With regard to switching the lights off after a period of inactivity - I think two routines sounds a good idea. Once I get the above working I’ll give that a go.

Thanks again

1 Like

I have just found the topic about creating a virtual switch so will have a look through this now

Just to say I have now managed to create a virtual switch and this has been detected in Alexa. Just putting the routine together now. This is perfect for what I need! :sunglasses:

As a footnote, I’m so glad I stumbled across the SmartThings app. Probably like most people out there using home automations in this day & age - I can’t quite believe the limited features in most smart apps, especially when it comes to multiple ‘IF’ logic.

Combining sunset/sunrise periods with at least one other ‘IF’ seems pretty elementary to me, yet Alexa et al. don’t have this feature.

Looking forward to seeing what I else I can now do with SmartThings.

1 Like

I believe you can accomplish that easily with the Smart Lighting app

Find Apps on the home screen in the upper left hand corner and clicking on the “hamburger icon”