2 * Switch Activates Hello, Home Phrase
4 * Copyright 2015 Michael Struck
7 * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
8 * in compliance with the License. You may obtain a copy of the License at:
10 * http://www.apache.org/licenses/LICENSE-2.0
12 * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed
13 * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License
14 * for the specific language governing permissions and limitations under the License.
16 * Ties a Hello, Home phrase to a switch's (virtual or real) on/off state. Perfect for use with IFTTT.
17 * Simple define a switch to be used, then tie the on/off state of the switch to a specific Hello, Home phrases.
18 * Connect the switch to an IFTTT action, and the Hello, Home phrase will fire with the switch state change.
23 name: "Switch Activates Home Phrase",
24 namespace: "MichaelStruck",
25 author: "Michael Struck",
26 description: "Ties a Hello, Home phrase to a switch's state. Perfect for use with IFTTT.",
27 category: "Convenience",
28 iconUrl: "https://raw.githubusercontent.com/MichaelStruck/SmartThings/master/IFTTT-SmartApps/App1.png",
29 iconX2Url: "https://raw.githubusercontent.com/MichaelStruck/SmartThings/master/IFTTT-SmartApps/App1@2x.png",
30 iconX3Url: "https://raw.githubusercontent.com/MichaelStruck/SmartThings/master/IFTTT-SmartApps/App1@2x.png")
38 dynamicPage(name: "getPref", title: "Choose Switch and Phrases", install:true, uninstall: true) {
39 section("Choose a switch to use...") {
40 input "controlSwitch", "capability.switch", title: "Switch", multiple: false, required: true
42 def phrases = location.helloHome?.getPhrases()*.label
45 section("Perform the following phrase when...") {
47 input "phrase_on", "enum", title: "Switch is on", required: true, options: phrases
48 input "phrase_off", "enum", title: "Switch is off", required: true, options: phrases
55 log.debug "Installed with settings: ${settings}"
56 subscribe(controlSwitch, "switch", "switchHandler")
60 log.debug "Updated with settings: ${settings}"
62 subscribe(controlSwitch, "switch", "switchHandler")
65 def switchHandler(evt) {
66 if (evt.value == "on") {
67 location.helloHome.execute(settings.phrase_on)
69 location.helloHome.execute(settings.phrase_off)