Automatic events at sunset conflicting with away status

I have a couple of events setup on my system that seem to be conflicting. Was wondering if anyone has a workaround.

  1. At sunset, set the mode to “night”. Do not perform this if I am set to “away”.
  2. When I leave the house, set to “away”. When I return, set to “home”.

The issue is (if it’s not already obvious) when I don’t get home until after sunset. My house is then set to “home” and not “night”. This is an issue because I have a number of other events that only fire when the mode is in “night”.

I suspect there’s an event that fires at sunset that looks like this:

if (mode != away && sunset)
{
     mode = night;
}

what I think I need is something else that looks like this:

if (mode.changed() && mode == home)
{
    if (time > sunset && time < sunrise)
    {
        mode = night;
    }
}

Basically, a check to see if we missed the event to change the mode to night.

Does anyone have a way to do this?

I am afraid this is one of those instances where SmartThings is not very smart. We all want different behavior when we are away, but upon returning, we want our homes behavior restored to NOT away behavior, and any settings that are appropriate for being “not away” at any given time that may occur.

But for now, you’ll need to abandon the ‘stock’ apps for one that supplies this additional conditional. Have a look at the ‘Sunrise/Sunset’ example for calculating those times, and add them to a mode change SmartApp with that other conditional.

Gotta go play golf right now so don’t have time to look into it for you, but if no one beats me to it I’ll have a look after I get back. In the meantime, you might want to consider anything else you might want to do on arrival other than setting the proper mode at the proper time.

Thanks for the reply! Don’t spend too much time trying to write anything - I’m a software engineer so I can (hopefully) do it myself. I just wanted to see if a solution existed before I started digging.

Good luck on the golf course!

Despite a 5 hour round, shot an 86 (which is pretty good for me).

There are a number of samples that should show you what you need to concoct, but just ask if you get stuck.

I know this is an old thread but I wanted to respond that I setup 4 modes - Day-Home, Day - Away, Night Home, Night -Away.

This helps me trigger different settings for each of the modes as it switches.