Smart App to run sequence of Hello Home commands

Is there a Smart App that will run a sequence of Hello Home commands?

I have four modes. If I come home late at night, I have it set to go from Out-Late mode straight to night (because I have night mode set to automatically trigger at a specific time which is usually after I get home). The only problem is that this alerts me to every door I open. I’d like to get an app that when it senses my presence, it changes to Home mode for 3-5 minutes. Then, it automatically switches to night mode.

So the basic idea is Presence Sensor detected, run Hello Home command 1, delay (optional timing hopefully), run Hello Home command 2.
(With the usual run only in modes…)

Does something like that exist? Or something perhaps close enough that I might be able to figure out how to modify it?

Ok, I modified the Greetings Earthling code… Simulator is down, but does this look close to right? (First attempt at even modifying this kind of code.) Thanks!

/**

preferences {

section(“When one of these people arrive at home”) {
input “people”, “capability.presenceSensor”, multiple: true
}
section(“Change to this mode”) {
input “newMode”, “mode”, title: “Mode?”
}
section(“False alarm threshold (defaults to 10 min)”) {
input “falseAlarmThreshold”, “decimal”, title: “Number of minutes”, required: false
}
section(“Set Delay”) {
input “delayChangeTime”, “decimal”, title: “Number of minutes”, required: false
}
section(“Then change to this mode”) {
input “finalMode”, “mode”, title: “Mode?”
}
section( “Notifications” ) {
input “sendPushMessage”, “enum”, title: “Send a push notification?”, options: [“Yes”,“No”], required:false
input “phone”, “phone”, title: “Send a Text Message?”, required: false
}

}

def installed() {
log.debug “Installed with settings: ${settings}”
log.debug “Current mode = ${location.mode}, people = ${people.collect{it.label + ': ’ + it.currentPresence}}”
subscribe(people, “presence”, presence)
}

def updated() {
log.debug “Updated with settings: ${settings}”
log.debug “Current mode = ${location.mode}, people = ${people.collect{it.label + ': ’ + it.currentPresence}}”
unsubscribe()
subscribe(people, “presence”, presence)
}

def presence(evt)
{
log.debug “evt.name: $evt.value”
def threshold = (falseAlarmThreshold != null && falseAlarmThreshold != “”) ? (falseAlarmThreshold * 60 * 1000) as Long : 10 * 60 * 1000L

if (location.mode != newMode) {

  def t0 = new Date(now() - threshold)
  if (evt.value == "present") {
  	def person = getPerson(evt)
  	def recentNotPresent = person.statesSince("presence", t0).find{it.value == "not present"}
  	if (recentNotPresent) {
  		log.debug "skipping notification of arrival of ${person.displayName} because last departure was only ${now() - recentNotPresent.date.time} msec ago"
  	}
  	else {
  		ChangeMode(person.displayName,newMode)
  		def modeDelay = delayChangeTime * 60
  		runIn(modeDelay, ChangeMode(person.displayName,finalMode))
  	}
  }

}
else {
log.debug “mode is the same, not evaluating”
}
}

def ChangeMode(dn,md)
{
def message = “${dn} arrived at home, changing mode to ‘${md}’”
log.info message
send(message)
setLocationMode(md)
}

private getPerson(evt)
{
people.find{evt.deviceId == it.id}
}

private send(msg) {
if ( sendPushMessage != “No” ) {
log.debug( “sending push message” )
sendPush( msg )
}

if ( phone ) {
log.debug( “sending text message” )
sendSms( phone, msg )
}

log.debug msg
}

error java.lang.IllegalArgumentException: Name cannot be null. @ line 76

This is the error I’m getting when I run the above code in the simulator. That line is:

def modeDelay = delayChangeTime * 60

Which is also the only part of the code not working… It executes both mode changes, but it does so in rapid succession. Yet, I added a logging entry for that line, and it shows:

debug Delay set to ‘180’ seconds

Which is right because 3 (what I set delayChangeTime to in the install preferences) times 60 is 180. That means the math is right and the variable is being set correctly. Is there something else I have to do to get the RunIn function to work? In the code I borrowed that section from, it didn’t look like it was defined anywhere.

Any help would be appreciated!

@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.")

}   

}