Perform action when it's dark only

First off, I love the new actions feature. Thank you for adding that!

I want to perform an action only when it’s dark, as determined by sunset/sunrise times, or a luminosity sensor. For example, turn on lights when someone arrives at home, and the mode is not already set to Home (can already do that, awesome!), but only do so if it’s dark.

Is there anyway I can file a feature request for that, or am I missing something, and this is already implemented?

I’m on android, so I’m not sure if this feature is baked into their new setup, but I built this app to do exactly that:

@imbrian, Thanks for sharing!

I do have an app for that. Mine is much less powerful than yours. It’s exactly for that reason that I was hoping to convert it to an action, instead.

@florianz, here is an app I wrote to do that - it turns on lights when a contact opens, but only does so between sunset and sunrise:

/**
 *  Turn It On For 5 Minutes
 *  Turn on a switch when a contact sensor opens and then turn it back off 5 minutes later (but only if it's night).
 *
 *  Author: Steve Sell steve.sell@gmail.com
 */
preferences {
	section("When it opens..."){
		input "contacts", "capability.contactSensor", multiple: true
	}
	section("Turn on these switches for 5 minutes..."){
		input "switches", "capability.switch", multiple: true
	}
}

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

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

def contactOpenHandler(evt) {
    def sunRiseAndSunset = getSunriseAndSunset()
    def timenow = now()
    if (timenow > sunRiseAndSunset.sunset.time  || timenow < sunRiseAndSunset.sunrise.time) {
    	log.debug "$timenow is not between sunrise: $sunRiseAndSunset.sunrise.time and sunset: $sunRiseAndSunset.sunset.time"
		switches?.on()
		switches?.off(delay: 300000)
    }
    else {
    	log.debug "$timenow is between sunrise: $sunRiseAndSunset.sunrise.time and sunset: $sunRiseAndSunset.sunset.time - Ignorning"
    }
}    
    

def initialize()
{
    subscribe(contacts, "contact.open", contactOpenHandler)
 }

I try this and like it. I have a question it seems to work only when I put smartthing hub into night mode? is that correct? I thought that if it using sunset to sunrise it should work in any mode? can it work in any mode or just night???

@llcanada, there’s nothing in the code (at least in my code - I’m not sure which one you were referring to). As with any app, when you install the app and configure it, the last option is “Set for Specific Mode(s)” - if you select “All Modes” (which is the default) then it will work in all modes.