From 0a5c8c75a302d160eba22f0113e07bcfb3482949 Mon Sep 17 00:00:00 2001 From: Marco Date: Tue, 2 May 2017 13:45:01 -0700 Subject: [PATCH] MSA-1947: . --- .../power-allowance.groovy | 114 +++++++++--------- 1 file changed, 57 insertions(+), 57 deletions(-) diff --git a/smartapps/smartthings/power-allowance.src/power-allowance.groovy b/smartapps/smartthings/power-allowance.src/power-allowance.groovy index 7ecf963..6fbd17f 100644 --- a/smartapps/smartthings/power-allowance.src/power-allowance.groovy +++ b/smartapps/smartthings/power-allowance.src/power-allowance.groovy @@ -1,57 +1,57 @@ -/** - * Copyright 2015 SmartThings - * - * 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. - * - * Power Allowance - * - * Author: SmartThings - */ -definition( - name: "Power Allowance", - namespace: "smartthings", - author: "SmartThings", - description: "Save energy or restrict total time an appliance (like a curling iron or TV) can be in use. When a switch turns on, automatically turn it back off after a set number of minutes you specify.", - category: "Green Living", - iconUrl: "https://s3.amazonaws.com/smartapp-icons/Meta/light_outlet.png", - iconX2Url: "https://s3.amazonaws.com/smartapp-icons/Meta/light_outlet@2x.png" -) - -preferences { - section("When a switch turns on...") { - input "theSwitch", "capability.switch" - } - section("Turn it off how many minutes later?") { - input "minutesLater", "number", title: "When?" - } -} - -def installed() { - log.debug "Installed with settings: ${settings}" - subscribe(theSwitch, "switch.on", switchOnHandler, [filterEvents: false]) -} - -def updated() { - log.debug "Updated with settings: ${settings}" - - unsubscribe() - subscribe(theSwitch, "switch.on", switchOnHandler, [filterEvents: false]) -} - -def switchOnHandler(evt) { - log.debug "Switch ${theSwitch} turned: ${evt.value}" - def delay = minutesLater * 60 - log.debug "Turning off in ${minutesLater} minutes (${delay}seconds)" - runIn(delay, turnOffSwitch) -} - -def turnOffSwitch() { - theSwitch.off() -} +/** + * Copyright 2015 SmartThings + * + * 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. + * + * Power Allowance + * + * Author: SmartThings + */ +definition( + name: "Power Allowance", + namespace: "smartthings", + author: "SmartThings", + description: "Save energy or restrict total time an appliance (like a curling iron or TV) can be in use. When a switch turns on, automatically turn it back off after a set number of minutes you specify.", + category: "Green Living", + iconUrl: "https://s3.amazonaws.com/smartapp-icons/Meta/light_outlet.png", + iconX2Url: "https://s3.amazonaws.com/smartapp-icons/Meta/light_outlet@2x.png" +) + +preferences { + section("When a switch turns on...") { + input "theSwitch", "capability.switch" + } + section("Turn it off how many minutes later?") { + input "minutesLater", "number", title: "When?" + } +} + +def installed() { + log.debug "Installed with settings: ${settings}" + subscribe(theSwitch, "switch.on", switchOnHandler, [filterEvents: false]) +} + +def updated() { + log.debug "Updated with settings: ${settings}" + + unsubscribe() + subscribe(theSwitch, "switch.on", switchOnHandler, [filterEvents: false]) +} + +def switchOnHandler(evt) { + log.debug "Switch ${theSwitch} turned: ${evt.value}" + def delay = minutesLater * 60 + log.debug "Turning off in ${minutesLater} minutes (${delay}seconds)" + runIn(delay, turnOffSwitch) +} + +def turnOffSwitch() { + theSwitch.off() +} \ No newline at end of file