Virtual switch to change hello, home mode

Hey @dawgonking, no special code needed.

Here are the steps.

  1. First use the link from @tslagle13 and make a smartapp. I modified the smart app only to have a on switch with no off switch. But you could easily set it up to toggle if you wanted to.

[code moved to bottom of post]

  1. Next create a switch under my devices (+ new device). Type the name of the hello, home phrase as the name of the switch (easier to select) and select for type momentary button tile. (use whatever name for the network name)

  2. Next, go to the go to the smart things app, it will have already have a blue (+) for the new switch. Simply click the setup new switch and name it. Do not assign any function to it.

  3. Next, go to smartthings smartsetup and go to the my apps section and you should see “big switch from hello home phrases” (from step 1)

  4. Follow the app instructions

  5. Click this click to setup and authorize endpoint example --> http://labs.smartthings.com/exampleOauth.php

  6. Next you will get a page that looks like this:

  7. Right click the desired switch and copy link, here you have the selection of using on switch, off switch, and toggle. (this is why I modified the original smartapp from @tslagle. This way I only need to use the switch once for each hello, home phrase.

  8. Simply send the link to your phone.(email/text). Copy the link (press and hold on the link)

  9. I used “MyClips Pro” 0.99 cents in the app store or you could use the free version. And create the the app following the simple instructions. Paste the link under url and follow steps and use hello, home phrase for the event as the title. Then click Add to home Screen. Follow steps from the app. Done.

Okay, wow. Sorry, for the long post. if I missed a step (my bad) but I think that covers everything I did. Seems tedious…because it is, but it works very well. Next thing will be integration with windows media center and xbmc. Will post on updates for today for that. =)

/**
 *  Big Switch for Hello Home Phrases
 *
 *  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: "Big Switch for Hello Home Phrases",
    namespace: "",
    author: "Tim Slagle",
    description: "Uses a virtual switch to run hello home phrases.",
    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"
)


preferences {
	page(name: "selectPhrases")

    page( name:"Settings", title:"Settings", uninstall:true, install:true ) {
    section(title: "More options", hidden: hideOptionsSection(), hideable: true) {

			def timeLabel = timeIntervalLabel()

			href "timeIntervalInput", title: "Only during a certain time", description: timeLabel ?: "Tap to set", state: timeLabel ? "complete" : null

			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.HHPhraseOff && settings.HHPhraseOn)
    dynamicPage(name: "selectPhrases", title: "Configure", nextPage:"Settings", uninstall: true) {		
		section("When this switch is turned on") {
			input "master", "capability.switch", title: "Where?"
		}
        def phrases = location.helloHome?.getPhrases()*.label
		if (phrases) {
        	phrases.sort()
		section("Run These Hello Home Phrases When...") {
			log.trace phrases
			input "HHPhraseOn", "enum", title: "The Switch Turns On", required: true, options: phrases, refreshAfterSelection:true

		}
		}
    }
}    


def installed(){
subscribe(master, "switch.on", onHandler)
}

def updated(){
unsubscribe()
subscribe(master, "switch.on", onHandler)
}

def onHandler(evt) {
log.debug evt.value
log.info("Running Light On Event")
sendNotificationEvent("Performing \"${HHPhraseOn}\" because ${master} turned on.")
location.helloHome.execute(settings.HHPhraseOn)
}


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 hideOptionsSection() {
	(starting || ending || days || modes) ? false : true
}

private timeIntervalLabel() {
	(starting && ending) ? hhmm(starting) + "-" + hhmm(ending, "h:mm a z") : ""
1 Like