Virtual switch to change hello, home mode

I just “wrote” this one yesterday. Based on some other code that someone sent me. I added some settings in, where the old code was a fixed mode change. You will need to create the dummy on/off button tile switch in the IDE. You will turn on the switch to change the mode and the app will turn it back off. I use it with Ifttt to do location based mode changes.

Please let me know if it gives you any issues so i can try to fix it. I havent had it published in the smartthings site so I would have to update it manually and send it to you.

Use a switch to change modes

Already answered. I wrote a smart app for it in this thread and published it to the IDE shared apps.

1 Like

His solution looks to be more in line with what you are looking for

thank you tslagle13 and CCSturgis both replies were really helpful. I finally got the app running and working with IOS homescreen. Here is a pic. Wife loves the button on the IOS homescreen instead of muddling through the app. Thanks again =)

Only issue I have currently is figuring out a way to automate the closing of the browser window since all i did was use a link from the endpoint example and save it as a bookmark to my homescreen.

Good stuff @patelvtp!

Could you post the code please? Thanks!

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

Thanks again @patelvtp!

I asked you to post because I’m going to do something similar using Ruby on Rails. Your code will help tremendously. Cheers! Nice job on your app as well.

@Ben @urman - This is an example of another great feature type for future revisions - “Big Button to Homepage” integration. Create a dedicated iOS/Android homescreen page for ST shortcuts. Essentially, a dashboard on your mobile home screen. At my home, that’s a big feature for my wife and kids.

1 Like

Could you explain more detail on Step 5? Clicking on the link doesn’t take me to the page shown in Step 6. Thanks for your work!

NEW UPDATE!, Since the iphone recently came out with a jailbreak for 7.1.1, I have a new method of activating hello, home.

What you will need to install --> Activator & Activator Command (both are in the cydia app store and are free) - PS the pro version of activator command adds icons (not tested)

Using the same link from step 6 above. Continue on:

  1. Copy the link from step 6 and email/text/imessage yourself the link
  2. Copy the link on your iphone
  3. Now you need to have Activator & Activator Command installed for the next step. Click settings and scroll down to Activator Command. Scroll down to the bottom and click show titles and (if you like show output command). Now back to the first and click title 1 (label with hello, home phrase). Then click the command line. FIRST, type in: curl -k -s then paste the link. so it would look like: curl -k -s https://blahblahblah. IT IS CASE SENSITIVE!
  4. Now simply go to activator (this is were we can assign a trigger on the phone to trigger the hello, home phrase.
  5. I simply assigned anywhere -> status bar -> double tap left (goodnight) & double tap right (I’m awake).
  6. Exit program and double tap the right or left on the status bar and BOOM! hello, home phrase should be triggered!
  7. Enjoy. =)

Hey @dawz2 So the link on step 5 should be done on your home network while your connected to the smart things hub. It will open a link to the developer site where you will have to register your smart hub, if you have not done so. After registering your device and making a user name. Click the link again and login, it will let you select what switches you want to have access to from the link that are located on your smartthings hub. Click authorize and you should be in at step 6. Hope that helps =)

I’m having the same trouble with Step 5. I’m on my home network, but clicking the link just takes me to the landing page for the IDE.

1 Like

All I can do from the link is login to my developer page. Where do I to from there?

try this link http://labs.smartthings.com/exampleOauth.php @seanatki @dawz2

Huzzah! Thanks for the clarification!

I followed the steps up to 3, but my smartsetup doesn’t show a My Apps section. I did try going to “convenience” since that the app’s category, but I didn’t see it there. Am I missing something?

FYI - I’m running the app on an Android, Samsung G3.

it should be either under the convenience section or modified it can be changed to my apps section (my personal preference). I would close out the app and reload it. I would also check under the hub in the developer mode website and check to make sure you see it listed under your smartapps. If its not listed, add the smartapp again and be sure to save it.

Sorry to be so late to this topic, but I just found it. I have been trying to follow your instructions and got stuck on the step with this link. When I click it, I get a blank page. No error notice or anything. Just a white page.

Any idea what I am doing wrong?

Thanks!

Hey DCrates

Give this one a shot and tell me what happens.

https://graph.api.smartthings.com/oauth/authorize?response_type=code&client_id=myclient&scope=app&redirect_uri=https%3A%2F%2Fgraph.api.smartthings.com%2Foauth%2Fcallback

It takes me to a page where it asks me to grant “myclient” access to my Smartthings. When I select my hub, it asks me to grant IFTTT access to various switches. When I click authorize, it takes me to a page that says “page does not exist”

Here is a screen shot.

Select the link below in this topic and click app endpoint example. Hopefully that works. let me know either way

I have successfully done this and it is awesome. I made myself a checklist to get through it though, maybe it will help you:

1. Online> Add device in IDE as momentary tile https://graph.api.smartthings.com/device/list  
2. Mobile> configure device +1 but no settings
3. Make sure there is a Hello home action ready
4. Mobile> +> My Apps> Big Switch for Hello Home Actions set up tile
5. Authorize new device  https://graph.api.smartthings.com/oauth/authorize?response_type=code&client_id=ab0528dd-9710-42f2-9712-ba7702e9f85c&redirect_uri=http://107.20.127.54/smartthings/exampleOauth.php&scope=app  
6. Find the right one and rt click copy link from on, copy to reference sheet
7. Send link to phone via evernote (or whatever)
8. Mobile> Open MyClips Pro app
9. Develop home page tile
10. done!
2 Likes