Can someone modify the big switch app to call Hello Home Phrases?

What does it mean “published apps on the IDE.”? How do I get to those apps?

Create a new smart app and in the code page int he top right there is a Browse Smart Apps drop down. Click that and then click browse shared smart apps. Mine will be in the recent category. Select my app and hit overwirte. publish and install through the mobile app.

Hi Tim,

I modified your app a bit, I added the following:

  • the time selection menu was missing - found it in another smartapp from you
  • the possibility to react only on an OFF event

Thanks for the code.

/**

  • 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: “tslagle13”,
author: “Tim Slagle”,
description: “Uses a virtual/or physical switch to run hello home phrases.”,
category: “Convenience”,
iconUrl: “http://icons.iconarchive.com/icons/icons8/windows-8/512/User-Interface-Switch-On-icon.png”,
iconX2Url: “http://icons.iconarchive.com/icons/icons8/windows-8/512/User-Interface-Switch-On-icon.png
)

preferences {
page(name: “selectPhrases”)
page(name: “timeIntervalInput”, title: “Only during a certain time”, nextPage: “Settings”) {
section {
input “starting”, “time”, title: “Starting”, required: false
input “ending”, “time”, title: “Ending”, required: false
}
}

page( name:"Settings", title:"Settings", uninstall:true, install:true ) {
	section("Settings") {
		label title: "Assign a name", required: false
	}
	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 or off”) {
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: false, options: phrases, refreshAfterSelection:true
input “HHPhraseOff”, “enum”, title: “The Switch Turns Off”, required: false, options: phrases, refreshAfterSelection:true

		}
	}
}

}

def installed(){
subscribe(master, “switch.on”, onHandler)
subscribe(master, “switch.off”, offHandler)
}

def updated(){
unsubscribe()
subscribe(master, “switch.on”, onHandler)
subscribe(master, “switch.off”, offHandler)
}

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

def offHandler(evt) {
if(allOk && HHPhraseOff) {
log.debug evt.value
log.info(“Running Light Off Event”)
sendNotificationEvent(“Performing “${HHPhraseOff}” because ${master} turned off.”)
location.helloHome.execute(settings.HHPhraseOff)
}
}

private getAllOk() {
TRACE(“getAllOk - called”)
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”)
{
TRACE(“hhmm - called”)
def t = timeToday(time, location.timeZone)
def f = new java.text.SimpleDateFormat(fmt)
f.setTimeZone(location.timeZone ?: timeZone(time))
f.format(t)
}

private hideOptionsSection() {
TRACE(“hideOptionsSection - called”)
(starting || ending || days || modes) ? false : true
}

private timeIntervalLabel() {
TRACE(“timeIntervalLabel - called”)
(starting && ending) ? hhmm(starting) + “-” + hhmm(ending, “h:mm a z”) : “”
}

private def TRACE(message) {
//log.debug message
}

1 Like

So I was able to instal the smart app but I am not sure where to go from there. I can see it on my phone but I am not sre how to configure it. Any help would be appreciated. This is my first dance into smart apps. Thanks

More specifically when I click on the app from my phone the only options I have under the configure is to set specific modes and give a name.

Can you provide a screenshot?

This was exactly what I was looking for, to integrate Google Calendar with SmartThings via IFTTT. A calendar entry with a specific phrase triggers IFTTT, which switches a virtual switch, which triggers your app, which sets the SmartThings mode to Away. Thanks!

Remember I can’t read code, so forgive me if this is a dumb question.

If there are mode restrictions in the Hello Home phrase itself, are they honored when this triggers?

That is, say I have a switch to trigger my Goodbye! action which turns off the lights, but the Goodbye! is not supposed to run if the mode is Guests. Will flipping the switch cause the lights to go off or not?

Thanks!

No. :smile:


BTW, there is now an easy install version of this available through Smart Setup. No more cut and paste!

See #25 and 26 under convenience. One uses a switch to change the mode and one uses a switch to run a Hello Home Action.

Hey - @bgoodman thank you for this outstanding SmartApp.

Do you think you can modify it to not fire the Routine if the Hub is already in the to-be-activated mode? I tried to give it a shot, but it requires a method to get the mode out of a phrase, which I couldn’t figure out. If someone else knows how to do that, I’ll submit a patch :smile:

Kristopher

Thanks tslagle13… This worked perfectly. However, it did not run the HH automation in the simulator, but run fine once published??? Anyway, this is just what I wanted!!!

This is an old thread for an old smartapp and that’s Slagle’s old user ID from before he joined the SmartThings staff, so I’m not sure he’s going to see your post.

At this point, however, this smartapp is no longer needed because about six months ago they added the capability into routines themselves (“routine” is the current name for what were originally called “hello home actions”). So when you set up your routine there is an option inside the routine to have it start when a switch comes on. That should be all you need. :sunglasses:

So in the routine itself, at the end look for the “automatically perform” option

And then choose “when something turns on or off”

If for some reason you do need something from the now discontinued smartapp, @slagle is the author.

1 Like