4 * Copyright 2014 Physical Graph Corporation
6 * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
7 * in compliance with the License. You may obtain a copy of the License at:
9 * http://www.apache.org/licenses/LICENSE-2.0
11 * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed
12 * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License
13 * for the specific language governing permissions and limitations under the License.
19 namespace: "smartthings",
20 author: "SmartThings",
21 description: "Use Jawbone sleep mode events to automatically execute Hello, Home phrases. Automatially put the house to bed or wake it up in the morning by pushing the button on your UP.",
22 category: "SmartThings Labs",
23 iconUrl: "https://s3.amazonaws.com/smartapp-icons/Partner/jawbone-up.png",
24 iconX2Url: "https://s3.amazonaws.com/smartapp-icons/Partner/jawbone-up@2x.png"
28 page(name: "selectPhrases")
32 dynamicPage(name: "selectPhrases", title: "Configure Your Jawbone Phrases.", install: true, uninstall: true) {
33 section("Select your Jawbone UP") {
34 input "jawbone", "device.jawboneUser", title: "Jawbone UP", required: true, multiple: false, submitOnChange:true
37 def phrases = location.helloHome?.getPhrases()*.label
40 section("Hello Home Actions") {
42 input "sleepPhrase", "enum", title: "Enter Sleep Mode (Bedtime) Phrase", required: false, options: phrases, submitOnChange:true
43 input "wakePhrase", "enum", title: "Exit Sleep Mode (Waking Up) Phrase", required: false, options: phrases, submitOnChange:true
50 log.debug "Installed with settings: ${settings}"
54 log.debug "Subscribing to sleeping events."
56 subscribe (jawbone, "sleeping", jawboneHandler)
61 log.debug "Updated with settings: ${settings}"
65 log.debug "Subscribing to sleeping events."
67 subscribe (jawbone, "sleeping", jawboneHandler)
73 // TODO: subscribe to attributes, devices, locations, etc.
76 def jawboneHandler(evt) {
77 log.debug "In Jawbone Event Handler, Event Name = ${evt.name}, Value = ${evt.value}"
78 if (evt.value == "sleeping" && sleepPhrase) {
80 sendNotificationEvent("Sleepy Time performing \"${sleepPhrase}\" for you as requested.")
81 location.helloHome.execute(settings.sleepPhrase)
83 else if (evt.value == "not sleeping" && wakePhrase) {
85 sendNotificationEvent("Sleepy Time performing \"${wakePhrase}\" for you as requested.")
86 location.helloHome.execute(settings.wakePhrase)