Minutes before/after Sunrise/Sunset Control

So this feels like something that should already be created and probably already talked about in some post but I haven’t found it in the amount of time that I feel like investing in this and I’m sure someone knows SmartApp that does this…

I want to turn a switch on or off x mins before or after sunrise or sunset. Belkin Wemo does this surprisingly well.

I’m sure I could figure this out but I’m sure someone else has already, and tested it fully.

Thanks for any replies!

I too would like an offset capability before/after either sunrise or sunset. For instance, in winter it’s getting pretty dark in the house well before sunset. It would be nice to turn the lights on some preset time before sunset.

1 Like

It already exists in the happens automatically part of a standard Hello Home Action. NOT the controls for the individual light. No custom code required. Not sure that meets your use case, of course.

See the following topic for screenshots.

Did you see the Sunrise/Sunset app under Convenience category (click the + at the bottom of your mobile app dashboard). It has the offset option you are talking about. I use it on a driveway post light switch, not to change modes. Hasn’t failed to turn on/off yet.

@JDRoberts and @Dlee Thanks for the replies. I guess that might suit my needs but I don’t necessarily want to offset the entire mode change. It’s just one light I’m trying to offset as it is in the basement where it is much darker.

I’m not really using modes yet so I guess it could help but I would hate one light in my basement to dictate when my mode changes.

Any more ideas / Developer SmartApps community?

The one I mentioned can change the mode, but doesn’t have to. It’s just a regular Hello Home Action. So you could just set up a HHA to turn on one light triggered by x minutes before sunset, for example. No mode change. Or you could set up a HHA to just change the mode, no device actions. Or multiple actions on multiple devices, with or without mode change. Anything that’s available when creating a new HHA within the standard mobile app.


Ok I see that now. Thanks I think this fits my needs.

I didn’t realize hello home could do things without affecting mode…

Another example of the confusing interface… Still love ya ST!


Well, here it is March 2019, and the sunset offset option still doesn’t work. Sunrise off/on and sunset off/on works but the offsets don’t.


which app? what exactly are you trying… something like 30 minutes before sunrise? are you using -30 in that scenario?

Hi jkp,

I am using Samsung SmartThings “Classic” with a month-old (purchased) new-in-box SmartThings V2 hub running firmware version 000.024.00020. I suppose the firmware is (or has been) automatically updated.

I am trying to turn a Samsung SmartThings Smart Outlet off at 2 hours after sunset. It will, in fact, turn off AT sunset, but it does not acknowledge the 2-hour offset.

The + or – notation is not necessary because the Automation routine lets me specify (1) the length of the offset, and (2) whether the offset is Before or After sunset. The offset simply doesn’t work.

“Device Health” is OFF. If it is turned ON, I get the “Device Not Available” message.

I have done a hub “power off, wait 60 seconds, and power on” reset with hub batteries permanently removed. That improved my overall connectivity but it did not solve the offset problem.

Thanks for your response.

Are you using smart lights or routines in the Classic app?

No smart lights. No complicated routines. Just an automation for 1 Smart Outlet. I suppose that would qualify as an Automation routine.

By the way, i know many people say to turn off device health.

By I leave on device health.

Devices for me are never “not available” unless there is a mesh problem and messages are being dropped.

The devices that show unavailable, are they zigbee or zwave?

If zwave, are you able to run a clean zwave repair in the web based IDE under “list events”?

The one device that showed “not available” was a zigbee Samsung Smart Outlet that responded favorably by turning off Device Health. It’s still off.

The mesh problem (sometimes a long delay in response) was solved by a hub “power off, wait 60 seconds, and power on” reset with hub batteries permanently removed. That, apparently let the mesh and its devices rediscover themselves.

I did a z-wave repair, but my only z-wave device is a garage door opener, and it was working fine anyway.

The only remaining problem (that I know of, anyway) is the Sunrise/Sunset | On/Off time offset. Sunrise/Sunset | On/Off works ok as long as there is no time offset employed.


I have had no problems with the SmartThings outlets.

I do not have the newer Samsung outlets.

Never had one show offline.


This is how I have managed to turn on a kitchen light switch (WEMO) one hour before sunset using webCoRE.

I am using a similar approach to turning the light off after midnight.

Hope this helps.

1 Like

That was most helpful. Thanks.

I have come up with a perfect solution to trying to trigger a fixed time before/after sunrise/sunset.

The earth is 360 degrees around and revolves once per 24 hours.
That’s 15 degrees per hour or 0.25 degrees per minute.

The sun angle of a different location/city that is at the same latitude (North/south) as you, but 15 degrees to the East (longitude) of you will match yours exactly one hour before hand.
A city 15 degrees west will match an hour later.

So, if you want your light to come on 15 minutes BEFORE sunset at your location, find a city/place that is at your latitude, but 3.5 degrees East (longitude) of your location.

Interesting. Why wouldn’t you just use the following: