Sunset App Unreliable

Hi Everyone -

Does anyone have code for a Sunset app? Its not published in the example apps on IDE. Smartthings - Can we get this published in browse code samples?

The current Sunrise / Sunset app seems to be very unreliable and looking to make it more stable.



What is it doing / not doing?


assuming he’s having the same issue I’m having, it simply doesn’t trigger the mode change like it’s supposed to. Seems to only work about half the time.

Also, has anyone noticed that the app doesn’t always update to show the correct current mode? For example, I’ll get a notification that says “SmartThings changed the mode to xxx because xxx…”, and then I open the app and it doesn’t show that it’s in that mode when I swipe to see the sidebar. It actually takes me killing the app and restarting for it to show correctly.

So the problem is that it doesn’t consistently display mode changes, or it doesn’t consistently execute mode changes?

The sunset app doesn’t consistently turn on the switches at sunset. In fact, it typically only works once or twice a week. Checking the logs for the switches, looks like the sunset app doesn’t even run.

However, I have a once a day setup to turn them on/off after sunset just in case, but by then its dark out.




I have had the problem before and ended up re-writing an app so that it first refreshed the switch status and then tried to turn it on multiple times.

Another thought is that if the app does not subscribe to the “off” event, and you manually turn off the switch the app may think its still on if you leave the app running on your phone. If you stop and restart the app on your phone, it then tries to refresh all the devices for your smartphone display and should update to “off”. The code probably has and “if not already on” that together with the previous logic fails to run as expected.

I’m probably over-simplifying a bit, but I think that is what is happening. I’ll see if I can get the code from the ST Dudes/Dudettes and figure it out for real.

Meanwhile, try killing (assuming iPhone) the app and restarting it daily before sunset.


I don’t even see the app anymore. Where did you get it?

@Twack -

Unless I’m reading the developer guide documentation wrong, the smartthings IOS/Android APP has nothing to do with actually invoking the actual script or what they call smartapps.

The script/smartapps are launched in their cloud and run from there. The hub gathers triggers from the cloud and devices locally. The IOS/Android app isn’t actually needed to run what events you create. Your phone can be powered off and your smartapps will still work.

Someone replied to my stream update, they have the sunset code here for anyone looking:

Thanks av8rdude


av8rdude replied 1 hour, 39 minutes ago

I asked this same question to support. I believe that it might not show up in the list because of the ”/” in the title? Support sent me a link to the code. Here it is:


I have the same issues. Most of the time the Sunset mode change works fine for me but the Sunrise change does not. I thought it might be linked to the issues where the Mode name had to be typed in (because support mentioned possible issues with case sensitivity). But last week they made a change which now allows you to choose modes from a pick list instead of having to type them in. Even since I went back and did this and reselected the modes, it still seems the sunrise mode change trigger is very unreliable.

Maybe something to do with current time? The time of day triggers keep giving me a lot of problems. Very unreliable right now.


I had written my own version back a few months ago and then accidentally overwrote it. It worked perfect everyday for like 3 weeks. Anyway, I edited the git version to the way I think I remember I was using for scheduling the jobs. I’ll let it run for a few days and make sure it works and then post the code up somewhere.