Lights on when arriving after sunset?

Door sensor is not activating lights in my app, but it’s a good idea.

I have something I wrote simmilar to this, I use actions to trigger different modes, for example I have a mode called arriving that is triggered by a hello home change when someone arrives, and then it changes to home when he door opens… And so on.

The app I wrote is Master Mode Lighting, (github.com/zpriddy) and it allows you to set up lighting for each mode, including hues. It also allows you to have different setting for each mode depending if the sun has gone down or not, this way you don’t need home day and home night, you just have home and let the app take car e of that for you. There is also an option to allow the app to transition between the night and day settings on its own.

@625alex I’ve updated my copy to only activate when nobody is home already (lights are off because the TV is on for instance). Also I am able to check for a luminance of 0 LUX by not using falsy. Finally, it sends a notification to hello home.

I am new to SmartThings v2 (got it yesterday) and I don’t know java or groovy at all. I’m a C# dev, so forgive me if this doesn’t look right. I tested it in the simulator. Can’t test IRL right now because it’s too bright.

Thanks for the head start. I sent a pull request on GitHub in case you’re interested in my changes.

@cbenard , Welcome!
I recommend to search for Rule Builder or Rule Machine. My smart app is pretty trivial, but the mentioned projects will give you more flexibility.

My new and improved version supports setting the luminance value (defaults to 1500 lux) and whether or not all the people need to be gone (on/off switch) before a person arriving triggers it. The user can now set these. Additionally, the notification to hello home will show the person who arrived and the action taken.

I sent @625alex another Pull Request. I don’t think it takes anything away and only adds capabilities. He’s free to not accept it of course. I’ll try to track any changes he makes if the changes aren’t accepted upstream.

1 Like

I will accept the pull request when I’m there.

Check out the other apps too.

I think I figured it out. I took a little bit of code from here and there and created a smart app which will turn on selected lights, when selected people arrive home when its after sunset. Anyone want to give this a try?

definition(
name: “Lights on Arrival after Sunset”,
namespace: “Joshuab2185”,
author: “Joshua Beitler and friends”,
description: “Turn lights on when arriving if it’s after sunset.”,
category: “Convenience”,
iconUrl: “https://s3.amazonaws.com/smartapp-icons/Convenience/Cat-Convenience.png”,
iconX2Url: “https://s3.amazonaws.com/smartapp-icons/Convenience/Cat-Convenience@2x.png”)

//I cannot take all the credit. I took some code from many other apps and brought it together to do what I wanted
preferences {
section(“When one of these people arrive”) {
input “people”, “capability.presenceSensor”, multiple: true, title: “When who arrives?”
}
section(“Turn on these lights…”) {
input “switch1”, “capability.switch”, multiple: true, title: “Turn on what?”
}
section(“and change mode to…”) {
input “HomeAfterDarkMode”, “mode”, title: “Change Mode to?”
}
}

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

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

unsubscribe()
initialize()

}

def initialize() {
subscribe(people, “presence”, presenseHandler)
}

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 ((evt.value == "present") && (setTime.before(now))) {
    	log.trace "Turning on switches: $switch1"            
                switch1.on()
        log.trace "Changing house mode to $HomeAfterDarkMode"
				setLocationMode(HomeAfterDarkMode)
    }
}