@jsulliweb I actually have the solution for you. My house is set to change from Away to Home mode when someone arrives, regardless of the time. Now here’s the key: I have a smart app that fires when a door (likely your front door) is open in Home mode. It checks the sunset and if it’s after that time it changes into Evening mode AND will optionally turn on some lights so you’re not walking into a dark house. Here’s the code. Enjoy.
/**
*
- Lights On When Door Open After Sundown
-
- Based on “Turn It On When It Opens” by SmartThings
-
- Author: Aaron Crocco
*/
// Automatically generated. Make future change here.
definition(
name: “Lights On When Door Opens After Sundown”,
namespace: “MacStainless”,
author: “Aaron Crocco”,
description: “When the front door opens after sundown, turn the lights on and switch the house to a set mode. This is an enhancement of the ‘Turn It On When It Opens’ SmartApp.”,
category: “My Apps”,
iconUrl: “https://s3.amazonaws.com/smartapp-icons/Convenience/Cat-Convenience.png”,
iconX2Url: “https://s3.amazonaws.com/smartapp-icons/Convenience/Cat-Convenience%402x.png”,
iconX3Url: “https://s3.amazonaws.com/smartapp-icons/Convenience/Cat-Convenience%402x.png”)
preferences {
section(“When the door opens…”){
input “contact1”, “capability.contactSensor”, title: “Where?”
}
section(“Turn on these lights…”){
input “switches”, “capability.switch”, multiple: true
}
section(“and change mode to…”) {
input “HomeAfterDarkMode”, “mode”, title: “Mode?”
}
}
def installed()
{
subscribe(contact1, “contact.open”, contactOpenHandler)
}
def updated()
{
unsubscribe()
subscribe(contact1, “contact.open”, contactOpenHandler)
}
def contactOpenHandler(evt) {
log.debug “$evt.value: $evt, $settings”
//Check current time to see if it's after sundown.
def s = getSunriseAndSunset(zipCode: zipCode, sunriseOffset: sunriseOffset, sunsetOffset: sunsetOffset)
def now = new Date()
def setTime = s.sunset
log.debug "Sunset is at $setTime. Current time is $now"
if (setTime.before(now)) { //Executes only if it's after sundown.
log.trace "Turning on switches: $switches"
switches.on()
log.trace "Changing house mode to $HomeAfterDarkMode"
setLocationMode(HomeAfterDarkMode)
sendPush("Welcome home! Changing mode to $HomeAfterDarkMode.")
}
}