Update step-notifier.groovy
[smartapps.git] / official / coffee-after-shower.groovy
1 /**
2  *  Coffee After Shower
3  *
4  *
5  *  Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
6  *  in compliance with the License. You may obtain a copy of the License at:
7  *
8  *      http://www.apache.org/licenses/LICENSE-2.0
9  *
10  *  Unless required by applicable law or agreed to in writing, software distributed under the License is distributed
11  *  on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License
12  *  for the specific language governing permissions and limitations under the License.
13  *
14  */
15 definition(
16     name: "Coffee After Shower",
17     namespace: "hwustrack",
18     author: "Hans Wustrack",
19     description: "This app is designed simply to turn on your coffee machine while you are taking a shower.",
20     category: "My Apps",
21     iconUrl: "https://s3.amazonaws.com/smartapp-icons/Convenience/Cat-Convenience.png",
22     iconX2Url: "https://s3.amazonaws.com/smartapp-icons/Convenience/Cat-Convenience@2x.png")
23
24
25 preferences {
26     section("About") {
27         paragraph "This app is designed simply to turn on your coffee machine " +
28             "while you are taking a shower."
29     }
30         section("Bathroom humidity sensor") {
31                 input "bathroom", "capability.relativeHumidityMeasurement", title: "Which humidity sensor?"
32         }
33     section("Coffee maker to turn on") {
34         input "coffee", "capability.switch", title: "Which switch?"
35     }
36     section("Humidity level to switch coffee on at") {
37         input "relHum", "number", title: "Humidity level?", defaultValue: 50
38     }
39 }
40
41 def installed() {
42         subscribe(bathroom, "humidity", coffeeMaker)
43 }
44
45 def updated() {
46         unsubscribe()
47         subscribe(bathroom, "humidity", coffeeMaker)
48 }
49
50 def coffeeMaker(shower) {
51         log.info "Humidity value: $shower.value"
52         if (shower.value.toInteger() > relHum) {
53                 coffee.on()
54     } 
55 }