Smarter-er lighting


(James Elsenburg) #1

I want to integrate my front porch lights with my presence fobs.  Like when the wife arrives home and its dark the front porch lights come on, but not when its daylight.  Is this already in there?  and I just can’t locate it?


(Andrew Urman) #2

There’s not one made yet. We’re working on one to grab sunset time by location or one that uses a light sensor. Main priority is to continue building IDE features for developers to make their own apps.


(James Elsenburg) #3

I messed around a bit more last night…  looks like a I can create a sunset-sunrise portion.  That would work with the exception of those really stormy days…or a total eclipse of the sun.


(Gray) #4

@jelsenburg: I think you could rig up a workaround for the last case with a motion detector.  I can see the documentation now:

 

In the event of a total eclipse of the sun: Turn around, bright eyes.

(Ken) #5

I wrote something to this effect, though I could not figure out the time element and just cut it out.  By doing, well, something with “def startTime = timeToday(timeOfDay)” and “now()” you should be able to check if it is after your “lights on” time.  I got frustrated and just cut it out since I couldn’t figure out what the error was in my original code.

This code is also designed to handle controlling indoor lights for two presence fobs, which may not be ideal for you (for me, if the lights are turned off and someone’s home, I want it to leave them off if a new person arrives while you may want the opposite for porch lights).

<code>

/**
*  Turn It On When I’m Here and off when we’re not
*
*  Author: Ken
*/
preferences {
section(“When I arrive and leave…”){
input “presence1”, “capability.presenceSensor”, title: “Who?”
}
section(“Or when [other person] arrives and leaves…”){
input “presence2”, “capability.presenceSensor”, title: “Who?”
}
section(“What time should lights start to be on?”) {
input “timeOfDay”, “time”, title: “Time?”
}
section(“Switches:”){
input “switch1”, “capability.switch”, title: “Switch 1?”, multiple: true
}
}

def installed()
{
subscribe(presence1, “presence”, presenceHandler)
subscribe(presence2, “presence”, presenceHandler)
}

def updated()
{
unsubscribe()
subscribe(presence1, “presence”, presenceHandler)
subscribe(presence2, “presence”, presenceHandler)
}

def presenceHandler(evt)
{
log.debug "success!  we have managed to do the most basic of things"
def current = evt.value
def me = presence1.latestValue(‘presence’)
def other = presence2.latestValue(‘presence’)
def startTime = timeToday(timeOfDay)
log.debug now()
log.debug “$startTime.time is time to start”

if (current == “present” && (me == “present” && other== “present”))
{
log.debug “a change that leads to two people here is irrelevant”
}
else if (current == “present”)
{
log.debug "but a change where one person came and now there is one, is relevant"
sendPush(“Someone has arrived at the apartment and the lights have been turned on.”)
settings.switch1.on()
}
else if (current == “not present” && (me == “not present” && other == “not present”))
{
log.debug "nobody is home now!"
sendPush(“Everyone has left at the apartment and the lights have been turned off.”)
settings.switch1.off()
}
else
{
log.debug “one of two people left”
}
}

</code>

 


(Mweston) #6

One of the things I noticed with sunset/sunrise settings while using my Belkin Wemo device is that it would be much better to be able to specify a time +/- sunset time. For example, if sunset is at 7pm, the sun is usually just going down and its still not dark enough to need the lights on so a better setting would be “1 hour after sunset”


(Todd Wackford) #7

I think I have what you guys want already running. See: http://build.smartthings.com/projects/nightlightsavingstime/

It uses a zip code to update real sunrise/sunset times with a plus/minus padding that the user can input (optional). It does not calculate eclipses or anything like that though. However, it will detect the apocalypse and will not turn on the lights that day :slight_smile:

Anyway, I’ll post the code on the project blog when I get a few minutes to clean it up.

Twack


(Aphex5) #8

twack, is your code available?


(Todd) #9

ST forums and site not working for me right now (twack). Hence the reason for the alter ego (todd). Once it’s fixed I’ll post.

Twack (todd)