Is it me or schedules not firing this evening?

Is it me only or scheduled events are not firing this evening? Sunset lights on didn’t trigger.

Haven’t missed any scheduled events as of yet, but the IDE has been running incredibly slow this evening for me.

My sunset events for my outside lights fired as expected. I’m good.

Ok… Thanks guys may be an isolated event for me tonight. Sunset event didn’t trigger.

My sunset actions did not trigger either. My network is functioning perfectly and my manual commands are working, so this appears to be a server issue with Smartthings. This seems to be a persistent problem and is getting very tiresome.

I did launch a ticket last night as my lights were not working with motion and the Good Morning didn’t work either. The response from ST was to push the 000.013.00013 firmware and ask me to monitor the situation.

Exact same behavior here… Manual triggering is fine but scheduled events not triggering.

My lights triggered at sunset but things were really slow when I was setting up a few pushbullet devices.

I just scheduled one to trigger at specific time and will check. Opened a ticket and everything is very slow. Internet, network is blazing fast. Manual triggering is fine. Mine was sunset event which didn’t work which worked for weeks. Of course the hub has been rebooted.

last night mine didnt fire either

Specific time triggered which I scheduled as a test. So its sunset broken again.

I moved my light schedules to the Hue bridge! Now I know my lights will come on when they need to. (c;

2 Likes

At times I feel like stealing your grey cells among others! :slight_smile:

I’m not sure if this is true. This is just from experiential observations. If you are running a sunset or sunrise app only in a specific mode, it may not fire. My theory is if you have it running only during your “Home” mode, then when you’re in “Sleep” mode and your app is supposed to schedule a sunrise or sunset time, the app won’t schedule those times.

For me to make it work, I have two modes for each mode. For example: “Home” and “Home - Dark”, “Away” and “Away - Dark”, etc… Then I have an app that runs in all modes to run a sunset and sunrise schedule and just switches between the mode sets. Here’s the app that I wrote for it:

/**
 *  Better Sunrise/Sunset
 *
 *  Copyright 2014 Eric Roberts
 *
 *  Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
 *  in compliance with the License. You may obtain a copy of the License at:
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 *  Unless required by applicable law or agreed to in writing, software distributed under the License is distributed
 *  on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License
 *  for the specific language governing permissions and limitations under the License.
 *
 */
definition(
    name: "Better Sunrise/Sunset",
    namespace: "baldeagle072",
    author: "Eric Roberts",
    description: "Better sunrise/sunset with more options",
    category: "Mode Magic",
    iconUrl: "https://s3.amazonaws.com/smartapp-icons/Convenience/Cat-Convenience.png",
    iconX2Url: "https://s3.amazonaws.com/smartapp-icons/Convenience/Cat-Convenience@2x.png",
    iconX3Url: "https://s3.amazonaws.com/smartapp-icons/Convenience/Cat-Convenience@2x.png")

//setup

preferences {
	page name:"setupInit"
	page name:"setupConfigure"
	page name:"setupModeTypes"
}

def setupInit() {
	TRACE("setupInit()")
	if (state.installed) {
		//return setupModeTypes()
        return setupConfigure()
	} else {
		return setupConfigure()
	}
}

def setupConfigure() {
	TRACE("setupConfigure()")

	def textNumOfHelp = 
		"You can switch between two modes for each type. How many types " +
		"do you have?"

	def inputNumModeTypes = [
		name: 			"numModeTypes",
		type: 			"number",
		title: 			"How many mode types?",
		defaultValue: 	"3",
		required: 		true
	]


	def pageProperties = [
		name: 			"setupConfigure",
		title: 			"Number of Mode Types",
		nextPage: 		"setupModeTypes",
		uninstall: 		true
	]

/*
	def pageProperties = [
		name: 			"setupConfigure",
		title: 			"Number of Mode Types",
        install: 		true,
		uninstall: 		false
	]
    */
	return dynamicPage(pageProperties) {
		section("Number of Mode Types") {
			paragraph textNumOfHelp
			input inputNumModeTypes
		}

		section ("Sunrise offset (optional)...") {
			input "sunriseOffsetValue", "text", title: "HH:MM", required: false
			input "sunriseOffsetDir", "enum", title: "Before or After", required: false, options: ["Before","After"]
		}
		section ("Sunset offset (optional)...") {
			input "sunsetOffsetValue", "text", title: "HH:MM", required: false
			input "sunsetOffsetDir", "enum", title: "Before or After", required: false, options: ["Before","After"]
		}
		section ("Zip code (optional, defaults to location coordinates)...") {
			input "zipCode", "text", required: false
		}
        section("Light Sensor (optional)") {
        	input "lightSensor", "capability.illuminanceMeasurement", title: "Which Light Sensor?", required: false
            input "lightLevel", "number", title: "Light Level?", default: 500
        }
        /*
		section( "Notifications" ) {
			input "sendPushMessage", "enum", title: "Send a push notification?", options: ["Yes", "No"], required: false
			input "phoneNumber", "phone", title: "Send a text message?", required: false
		}
        */
	}
}

def setupModeTypes() {
	TRACE("setupModeTypes()")

	def textDayHelp =
		"This mode will be active during the day"

	def textNightHelp =
		"This mode will be active at night"

	def textOnSunriseHelp =
		"These switches will turn on at sunrise"

	def textOffSunriseHelp =
		"These switches will turn off at sunrise"

	def textOnSunsetHelp =
		"These switches will turn on at sunset"

	def textOffSunsetHelp =
		"These switches will turn off at sunset"
	
	def pageProperties = [
		name: 		"setupModeTypes",
		title: 		"Configure Mode Types",
		install: 	true,
		uninstall: 	state.installed
	]

	return dynamicPage(pageProperties) {
		for (int n = 1; n <= numModeTypes; n++) {
			section("Mode Type ${n}", hideable:true, hidden:true) {
				paragraph textDayHelp
				input "m${n}_dayMode", "mode", title: "Day Mode", required: true
				paragraph textNightHelp
				input "m${n}_nightMode", "mode", title: "Night Mode", required: true
				paragraph textOnSunriseHelp
				input "m${n}_sunriseOnSwitches", "capability.switch", title: "Sunrise On Switches", multiple: true, required: false
				paragraph textOffSunriseHelp
				input "m${n}_sunriseOffSwitches", "capability.switch", title: "Sunrise Off Switches", multiple: true, required: false
				paragraph textOnSunsetHelp
				input "m${n}_sunsetOnSwitches", "capability.switch", title: "Sunset On Switches", multiple: true, required: false
				paragraph textOffSunsetHelp
				input "m${n}_sunsetOffSwitches", "capability.switch", title: "Sunset Off Switches", multiple: true, required: false
			}
		}
	}
}

// installed/updated/init

def installed() {
	log.debug "Installed with settings: ${settings}"

	initialize()
}

def updated() {
	log.debug "Updated with settings: ${settings}"

	unsubscribe()
	initialize()
}

def initialize() {
	TRACE("initialize()")
    
    state.installed = true
    
    if (settings.zipCode == null) {
    	settings.zipCode = location.zipCode
    }
    
    state.numModeTypes = numModeTypes
    
    state.sunriseArray = []
	state.sunsetArray = []
    state.modeTypes = []
    
    for (int n = 1; n <= numModeTypes; n++) {
    	setupModeType(n)
    }
    
    //log.debug("init modeTypes ${state.modeTypes}")
    if (lightSensor) {
    	subscribe(lightSensor, "illuminance", lightHandler)
    }

    scheduleSunriseSunset()
    TRACE("End init")
}

def setupModeType(n) {
	TRACE("setupModeType($n)")
	def modeType = [:]
	modeType.dayMode = settings."m${n}_dayMode"
	modeType.nightMode = settings."m${n}_nightMode"
    
	state.modeTypes.push(modeType)
    state.sunriseArray.push(modeType.nightMode)
    state.sunsetArray.push(modeType.dayMode)
}

def getModeTypeDevices(n) {
	if (n >= state.numModeTypes) {
    	return null
    }
    n++
    
    def devices = [:]
    
	devices.sunriseOnSwitches = settings."m${n}_sunriseOnSwitches"
	devices.sunriseOffSwitches = settings."m${n}_sunriseOffSwitches"
	devices.sunsetOnSwitches = settings."m${n}_sunsetOnSwitches"
	devices.sunsetOffSwitches = settings."m${n}_sunsetOffSwitches"
    
    return devices
}

// schedule

def scheduleSunriseSunset() {
	TRACE("scheduleSunriseSunset()")
    def srOff = sunriseOffset()
    def ssOff = sunsetOffset()
    log.debug("srOff: $srOff , ssOff: $ssOff")
	
	def sunriseSunset = getSunriseAndSunset(zipCode: settings.zipCode)
    
	def sunriseTime = sunriseSunset.sunrise
	def sunsetTime = sunriseSunset.sunset

	def sunriseScheduleTime = getSunriseWithOffset(srOff)
	def sunsetScheduleTime = getSunsetWithOffset(ssOff)

	log.debug("sunriseScheduleTime $sunriseScheduleTime , sunsetScheduleTime $sunsetScheduleTime")
    
    def localData = getWeatherFeature('geolookup', settings.zipCode as String)
    
    def timezone = TimeZone.getTimeZone(localData.location.tz_long)
    
    log.debug( "Sunset today is at $sunsetTime" )
    log.debug( "Sunrise today is at $sunriseTime" )
    
    unschedule()    
    schedule(sunriseScheduleTime, sunrise)
    schedule(sunsetScheduleTime, sunset)
    schedule(timeTodayAfter(new Date(), '01:00', timezone), scheduleSunriseSunset)
}

def getSunriseWithOffset(srOff) {
	def srOffTime = getSunriseAndSunset(zipCode: settings.zipCode, sunriseOffset:srOff)
    //log.debug(srOffTime)
    return srOffTime.sunrise
}

def getSunsetWithOffset(ssOff) {
	def ssOffTime = getSunriseAndSunset(zipCode: settings.zipCode, sunsetOffset:ssOff)
	return ssOffTime.sunset
}

def sunriseOffset() {
	//log.debug("settings.sunriseOffsetValue ${settings.sunriseOffsetValue}")
    //log.debug("settings.sunriseOffsetDir ${settings.sunriseOffsetDir}")
	if ((settings.sunriseOffsetValue != null) && (settings.sunriseOffsetDir != null)) {
		def offsetString = ""
		if (settings.sunriseOffsetDir == 'Before') {
			offsetString = "-"
		}
		offsetString += settings.sunriseOffsetValue
		return offsetString
	} else {
		return "00:00"
	}
}

def sunsetOffset() {
	//log.debug("settings.sunsetOffsetValue ${settings.sunsetOffsetValue}")
    //log.debug("settings.sunsetOffsetDir ${settings.sunsetOffsetDir}")
    //log.debug((settings.sunsetOffsetValue != null) && (settings.sunsetOffsetDir != null))
	if ((settings.sunsetOffsetValue != null) && (settings.sunsetOffsetDir != null)) {
		def offsetString = ""
		if (settings.sunsetOffsetDir == 'Before') {
			offsetString = "-"
		}
		offsetString += settings.sunsetOffsetValue
		return offsetString
	} else {
		return "00:00"
	}
}

// events

def lightHandler(evt) {
	log.debug "Light Level: ${evt.value}, Set: ${lightLevel}"
}

def sunrise() {
	TRACE("sunrise()")
	def currentMode = location.mode
	def n = state.sunriseArray.indexOf(currentMode)
    log.debug("currentMode $currentMode sunriseArray ${state.sunriseArray}")
	if (n >= 0) {
		def modeType = state.modeTypes[n]
        log.debug("sunrise modeType $modeType")
        def devices = getModeTypeDevices(n)
        def onSwitches = devices.sunriseOnSwitches
        def offSwitches = devices.sunriseOffSwitches
		if (onSwitches != null) {
        	onSwitches.on()
        }
        if (offSwitches != null) {
        	offSwitches.off()
        }
		changeMode(modeType.dayMode)
	}
}

def sunset() {
	TRACE("sunset()")
	def currentMode = location.mode
	def n = state.sunsetArray.indexOf(currentMode)
	if (n >= 0) {
		def modeType = state.modeTypes[n]
        def devices = getModeTypeDevices(n)
        def onSwitches = devices.sunsetOnSwitches
        def offSwitches = devices.sunsetOffSwitches
		if (onSwitches != null) {
        	onSwitches.on()
        }
        if (offSwitches != null) {
        	offSwitches.off()
        }
		changeMode(modeType.nightMode)
	}
}

def changeMode(newMode) {
	if (newMode && location.mode != newMode) {
		if (location.modes?.find{it.name == newMode}) {
			setLocationMode(newMode)
			log.debug("has changed the mode to '${newMode}'")
		}
		else {
			log.debug("tried to change to undefined mode '${newMode}'")
		}
	}
}

// debug

def TRACE(msg) {
	log.debug msg
    //log.debug("state $state")
}

It’s been working for me for over a month. Let me know if this works for you.

1 Like

Not sure if related, but none of my Hello, Home events have triggered during the past 24 hours.

Let’s forget about the custom apps for a second. Plain and simple scheduled hello home actions are not firing for the past 24 hrs. @tyler, @urman any updates on this? @duncan?

BRILLIANT! I added your app, and have experience my “sunset” events firing for the first time EVER! I’ve forwarded this to Support to see if it uncovers a bug in their base code.