4 * Copyright 2014 SmartThings
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.
18 namespace: "smartthings",
19 author: "SmartThings",
20 description: "Turn things off if you're using too much energy",
21 category: "Green Living",
22 iconUrl: "https://s3.amazonaws.com/smartapp-icons/Meta/light_outlet.png",
23 iconX2Url: "https://s3.amazonaws.com/smartapp-icons/Meta/light_outlet@2x.png",
24 iconX3Url: "https://s3.amazonaws.com/smartapp-icons/Meta/light_outlet@2x.png"
29 input(name: "meter", type: "capability.powerMeter", title: "When This Power Meter...", required: true, multiple: false, description: null)
30 input(name: "threshold", type: "number", title: "Reports Above...", required: true, description: "in either watts or kw.")
33 input(name: "switches", type: "capability.switch", title: "Turn Off These Switches", required: true, multiple: true, description: null)
38 log.debug "Installed with settings: ${settings}"
43 log.debug "Updated with settings: ${settings}"
49 subscribe(meter, "power", meterHandler)
52 def meterHandler(evt) {
53 def meterValue = evt.value as double
54 def thresholdValue = threshold as int
55 if (meterValue > thresholdValue) {
56 log.debug "${meter} reported energy consumption above ${threshold}. Turning of switches."