Scream it to the mountain tops! (Stuff you love about home automation)

Alright everyone,

Lets do something a little fun here. Lets start a thread that is all about stuff you have working in your house that you love! Stuff that you just love about your smartthings setup that makes your life easier every day! That one, or two, thing(s) that everytime you have someone over to your house you are showing off to them. I’d love to see a thread of people just sharing their stories of how they win with their house every day. Lets see what you all have!!

I’ll start.

I love my app Home/Away with Night modes. It is so cool to have my home know when it is occupied and when it isn’t and then act accordingly depending on if the sun is up or down. Then it can run a hello home phrase to do what i want it to depending on those 4 different scanarios. Then on top of that, my house arms my foscams and moves the iris to “battle ready” mode, i use ImBrians secure my foscam code for that.

Here is the code for the auto home and away…

 /**
 *  Auto Home/Away with night modes
 *
 *  Copyright 2014 Tim Slagle
 *
 *  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: "Magic Home",
    namespace: "tslagle13",
    author: "Tim Slagle",
    description: "Monitor a set of presence sensors and change mode based on when your home is empty or occupied.  Included Night and Day modes for both an occupied and unoccupied house.",
    category: "Convenience",
    iconUrl: "http://icons.iconarchive.com/icons/icons8/ios7/512/Very-Basic-Home-Filled-icon.png",
    iconX2Url: "http://icons.iconarchive.com/icons/icons8/ios7/512/Very-Basic-Home-Filled-icon.png"
)

preferences {
  page(name: "selectPhrases")
    
  page( name:"Settings", title:"Settings", uninstall:true, install:true ) {
  	section("False alarm threshold (defaults to 10 min)") {
    	input "falseAlarmThreshold", "decimal", title: "Number of minutes", required: false
  	}

  	section("Zip code (for sunrise/sunset)") {
   		input "zip", "decimal", required: true
  	}

      section("Notifications") {
        input "sendPushMessage", "enum", title: "Send a push notification when house is empty?", metadata:[values:["Yes","No"]], required:false
        input "sendPushMessageHome", "enum", title: "Send a push notification when home is occupied?", metadata:[values:["Yes","No"]], required:false
  	}

    section(title: "More options", hidden: hideOptionsSection(), hideable: true) {
    		label title: "Assign a name", required: false
			input "days", "enum", title: "Only on certain days of the week", multiple: true, required: false,
				options: ["Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday", "Sunday"]
			input "modes", "mode", title: "Only when mode is", multiple: true, required: false
		}
  }
}

def selectPhrases() {
	def configured = (settings.awayDay && settings.awayNight && settings.homeDay && settings.homeNight)
    dynamicPage(name: "selectPhrases", title: "Configure", nextPage:"Settings", uninstall: true) {		
		section("Who?") {
			input "people", "capability.presenceSensor", title: "Monitor These Presences", required: true, multiple: true,  refreshAfterSelection:true
		}
        
		def phrases = location.helloHome?.getPhrases()*.label
		if (phrases) {
        	phrases.sort()
			section("Run This Phrase When...") {
				log.trace phrases
				input "awayDay", "enum", title: "Everyone Is Away And It's Day", required: true, options: phrases,  refreshAfterSelection:true
				input "awayNight", "enum", title: "Everyone Is Away And It's Night", required: true, options: phrases,  refreshAfterSelection:true
                input "homeDay", "enum", title: "At Least One Person Is Home And It's Day", required: true, options: phrases,  refreshAfterSelection:true
                input "homeNight", "enum", title: "At Least One Person Is Home And It's Night", required: true, options: phrases,  refreshAfterSelection:true
			}
            section("Select modes used for each condition. (Needed for better app logic)") {
        input "homeModeDay", "mode", title: "Select Mode Used for 'Home Day'", required: true
        input "homeModeNight", "mode", title: "Select Mode Used for 'Home Night'", required: true
  	}
		}
    }
}

def installed() {
  init()
  initialize()

}

def updated() {
  unsubscribe()
  initialize()

  init()
}

def init() {
  subscribe(people, "presence", presence)
}

def uninstalled() {
unsubscribe()
}

def initialize() {
    runIn(60, checkSun)
	subscribe(location, "sunrise", setSunrise)
	subscribe(location, "sunset", setSunset)
}

def checkSun() {
  def zip     = settings.zip as String
  def sunInfo = getSunriseAndSunset(zipCode: zip)
 def current = now()

if (sunInfo.sunrise.time < current && sunInfo.sunset.time > current) {
    state.sunMode = "sunrise"
   setSunrise()
  }
  
else {
   state.sunMode = "sunset"
    setSunset()
  }

log.info("Sunset: ${sunInfo.sunset.time}")
 log.info("Sunrise: ${sunInfo.sunrise.time}")
 log.info("Current: ${current}")
log.info("sunMode: ${state.sunMode}")

 if(current < sunInfo.sunrise.time) {
  runIn(((sunInfo.sunrise.time - current) / 1000).toInteger(), setSunrise)
  }

  if(current < sunInfo.sunset.time) {
  runIn(((sunInfo.sunset.time - current) / 1000).toInteger(), setSunset)
 }
}

def setSunrise(evt) {
  state.sunMode = "sunrise";
  changeSunMode(newMode);
  sendNotificationEvent("Setting Sunrise Mode")
}

def setSunset(evt) {
  state.sunMode = "sunset";
  changeSunMode(newMode)
  sendNotificationEvent("Setting Sunset Mode")
}


def changeSunMode(newMode) {
  if(allOk) {

  if(everyoneIsAway() && (state.sunMode == "sunrise")) {
    log.info("Home is Empty  Setting New Away Mode")
    def delay = (falseAlarmThreshold != null && falseAlarmThreshold != "") ? falseAlarmThreshold * 60 : 10 * 60 
    runIn(delay, "setAway")
  }

  if(everyoneIsAway() && (state.sunMode == "sunset")) {
    log.info("Home is Empty  Setting New Away Mode")
    def delay = (falseAlarmThreshold != null && falseAlarmThreshold != "") ? falseAlarmThreshold * 60 : 10 * 60 
    runIn(delay, "setAway")
  }
  
  else {
  log.info("Home is Occupied Setting New Home Mode")
  setHome()


  }
}
}

def presence(evt) {
  if(allOk) {
  if(evt.value == "not present") {
    log.debug("Checking if everyone is away")

    if(everyoneIsAway()) {
      log.info("Nobody is home, running away sequence")
      def delay = (falseAlarmThreshold != null && falseAlarmThreshold != "") ? falseAlarmThreshold * 60 : 10 * 60 
      runIn(delay, "setAway")
    }
  }

else {
	def lastTime = state[evt.deviceId]
    if (lastTime == null || now() - lastTime >= 1 * 60000) {
  		log.info("Someone is home, running home sequence")
  		setHome()
    }    
	state[evt.deviceId] = now()

  }
}
}

def setAway() {
  if(everyoneIsAway()) {
    if(state.sunMode == "sunset") {
      def message = "Performing \"${awayNight}\" for you as requested."
      log.info(message)
      sendAway(message)
      location.helloHome.execute(settings.awayNight)
    }
    
    else if(state.sunMode == "sunrise") {
      def message = "Performing \"${awayDay}\" for you as requested."
      log.info(message)
      sendAway(message)
      location.helloHome.execute(settings.awayDay)
      }
    else {
      log.debug("Mode is the same, not evaluating")
    }
  }

  else {
    log.info("Somebody returned home before we set to '${newAwayMode}'")
  }
}

def setHome() {

log.info("Setting Home Mode!!")
if(anyoneIsHome()) {
      if(state.sunMode == "sunset"){
      if (location.mode != "${homeModeNight}"){
      def message = "Performing \"${homeNight}\" for you as requested."
        log.info(message)
        sendHome(message)
        location.helloHome.execute(settings.homeNight)
        }
       }
       
      if(state.sunMode == "sunrise"){
      if (location.mode != "${homeModeDay}"){
      def message = "Performing \"${homeDay}\" for you as requested."
        log.info(message)
        sendHome(message)
        location.helloHome.execute(settings.homeDay)
            }
      }      
    }
    
}

private everyoneIsAway() {
  def result = true

  if(people.findAll { it?.currentPresence == "present" }) {
    result = false
  }

  log.debug("everyoneIsAway: ${result}")

  return result
}

private anyoneIsHome() {
  def result = false

  if(people.findAll { it?.currentPresence == "present" }) {
    result = true
  }

  log.debug("anyoneIsHome: ${result}")

  return result
}

def sendAway(msg) {
  if(sendPushMessage != "No") {
    log.debug("Sending push message")
    sendPush(msg)
  }

  log.debug(msg)
}

def sendHome(msg) {
  if(sendPushMessageHome != "No") {
    log.debug("Sending push message")
    sendPush(msg)
  }

  log.debug(msg)
}

private getAllOk() {
	modeOk && daysOk && timeOk
}

private getModeOk() {
	def result = !modes || modes.contains(location.mode)
	log.trace "modeOk = $result"
	result
}

private getDaysOk() {
	def result = true
	if (days) {
		def df = new java.text.SimpleDateFormat("EEEE")
		if (location.timeZone) {
			df.setTimeZone(location.timeZone)
		}
		else {
			df.setTimeZone(TimeZone.getTimeZone("America/New_York"))
		}
		def day = df.format(new Date())
		result = days.contains(day)
	}
	log.trace "daysOk = $result"
	result
}

private getTimeOk() {
	def result = true
	if (starting && ending) {
		def currTime = now()
		def start = timeToday(starting).time
		def stop = timeToday(ending).time
		result = start < stop ? currTime >= start && currTime <= stop : currTime <= stop || currTime >= start
	}
	log.trace "timeOk = $result"
	result
}

private hhmm(time, fmt = "h:mm a")
{
	def t = timeToday(time, location.timeZone)
	def f = new java.text.SimpleDateFormat(fmt)
	f.setTimeZone(location.timeZone ?: timeZone(time))
	f.format(t)
}

private getTimeIntervalLabel()
{
	(starting && ending) ? hhmm(starting) + "-" + hhmm(ending, "h:mm a z") : ""
}

private hideOptionsSection() {
	(starting || ending || days || modes) ? false : true
}

Code for secure my foscam… Thanks imbrian!

/**
 *  Name: Secure My Foscam
 *
 *  Author: brian@bevey.org
 *  Date: 9/25/13
 *
 *  Simply turns on the alarm for any Foscam custom device.  This is intended
 *  to be used with the Foscam custom device type with a camera set up for FTP
 *  or email uploading based on motion detection.
 */


// Automatically generated. Make future change here.
definition(
    name: "Secure My Foscam",
    namespace: "",
    author: "brian@bevey.org",
    description: "Secure your foscam",
    category: "Safety & Security",
    iconUrl: "https://s3.amazonaws.com/smartapp-icons/Convenience/Cat-Convenience.png",
    iconX2Url: "https://s3.amazonaws.com/smartapp-icons/Convenience/Cat-Convenience%402x.png"
)

preferences {
  section("Change to this mode to...") {
    input "newMode", "enum", metadata:[values:["Alarm On", "Alarm Off"]]
  }

  section("Move to this preset...") {
    input "newPreset", "enum", metadata:[values:[1, 2, 3]], required: false
  }

  section("Change these Foscam modes...") {
    input "foscams", "capability.imageCapture", multiple: true
  }
}

def installed() {
  subscribe(location, changeMode)
  subscribe(app, changeMode)
}

def updated() {
  unsubscribe()
  subscribe(location, changeMode)
  subscribe(app, changeMode)
}



def changeMode(evt) {
  if(newPreset) {
    def preset = new Integer(newPreset)

    log.info("Preset: ${preset}")
    foscams?.preset(preset)
  }

  if(newMode == "Alarm On") {
    log.info("Alarm: on")

    foscams?.alarmOn()
  }  

  else {
    log.info("Alarm: off")

    foscams?.alarmOff()
  } 
}

Lets hear what everyone else has going!!! Im excited to see what else everyone in this rockin community has going on!

1 Like

Night light + Security: I have a light that turns on at sunset, stays on until 10pm. After that, it is motion activated (stays on for 5 minutes) until sunrise.

Whole House Fan: My nasty hack job of a whole house fan is hooked up to a smart switch. Once the thermostat turns off (which happens when I open a window) and the outside temp is less than the indoor temp, the fan will kick on. It will keep running until the indoor temp reaches my set temp (or the conditions aren’t true anymore).

Thermostat Auto Away: I have a Nest thermostat. When both of us leave the geofence (done with tasker instead of ST app), the thermostat changes to away.

i have an app for this too. its awesome!!!

it’s like my house is alive!

Jawbone UP24… the ability to lay in bed and hold the button (when it works) to shut the house down raise the NEST, turn off lights and lock all my doors is sick. Again when I wake up in the morning doing the same thing from bed, lower the AC and unlocking doors. Even turn on a light or 2 with my TCP bulbs.

Hello Home Action - “I’m gone”… when everyone leaves the geofence the doors lock up and the AC jumps to 81 not using AC and saving on my electric bill. This works really good when we go to the store for a couple hours or maybe to the beach the AC isn’t running and I don’t need to remember to turn down the NEST. This is probably my favorite feature right now!!

I can’t show this off enough when freinds come over!!! YELLLLLLING AS LOUD AS I CAN!!

Hello home is so awesome!

1 Like

All these Hello Home actions are the key to ST’s if used right. It’s literally taken me 2 days to perfect all my actions. Now with the Jawbone UP24 it’s ridiculous what I can do. Once ST’s gets a new release on the TCP lights so they all work without a hiccup it’s over johnny!!!

BOOOOOOOOOOOOOOOOOOOOM…LOL

I have played around with a few fun twists.

When we built the house, we put Schlage locks on the doors. No brainer to have them lock up when we leave and unlock when we come home. I never have to pull out the key.

The fun part was our alarm system. My husband does not want to deal with it, but I feel better if it is on when we are not home. I got an appliance module on ebay for 10.00 and a 5.00 relay from Radio Shack. I wired the mains voltage from the appliance module to the control circuit on the relay. then I took a wire loop from an alarm zone to the relay and back. I set this zone to be a key so that the alarm is armed when relay is activated and disarmed when the relay is released.

Added this to turn on when no one is home and to turn off when anyone is home.

No need to arm or disarm the alarm and hubby is happy, And the alarm is on only when no one is home, so I am happy!

Awesome!!! Love how awesome this community is!!!

And we now have the “HAF”… Husband acceptance factor. So we officially not have WAF and HAF… We are equal opportunity in the SmartThings community!

1 Like

@tslagle13 I was thinking the same thing on the HAF! Those are a rare find!

2 Likes

We need to start an acronym thread that’s a sticky post at the top of the forum!

1 Like

How about:

1 Like

I posted about this some place else literally minutes before you posted the list! Thanks @ben.

Update!!!

Bought some new toys recently and now my house is practically living! Here are some of the new things my home does:

  1. When i open a door and its about to rain smart things lets me know; as well as when i have a door/window open and its going to rain it will let me know, so i can “button up”
  2. If i have any doors/windows open and my thermostat wants to turn on smartthings won’t let it and if it is cooling/heating and i open a windows/door for longer than a minute it will turn my thermostat to off! So cool!
  3. My thermostat also knows what the temp is outside thanks to a smart sensor on ym garage and it will turn on/off the thermostat if it gets too hot or too cold. if its in a comfortable zone the termostat is turned off.

Smarthtings rocks!!!

Lets make it awesome!!!

1 Like

Awesome work Tim!! Time for me to hit the ST’s store soon!! haha