Last active
July 1, 2016 20:56
-
-
Save jimmyjames/8e94e9959e3253d2738a34b436b035f0 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* mode input tests | |
* | |
* Copyright 2016 james anderson | |
* | |
* 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. | |
* | |
*/ | |
definition( | |
name: "mode input tests", | |
namespace: "jimmyjames", | |
author: "james anderson", | |
description: "asdfasdf", | |
category: "", | |
iconUrl: "https://s3.amazonaws.com/smartapp-icons/Convenience/Cat-Convenience.png", | |
iconX2Url: "https://s3.amazonaws.com/smartapp-icons/Convenience/Cat-Convenience@2x.png", | |
iconX3Url: "https://s3.amazonaws.com/smartapp-icons/Convenience/Cat-Convenience@2x.png") | |
preferences { | |
// Begin using mode method. This automically only executes the smartapp when in the selected modes | |
// for single page preferences, this is automically added to the preferences | |
/*page(name: "pageOne", nextPage: "pageTwo", uninstall: true) { | |
section() { | |
input "theswitch", "capability.switch" | |
} | |
} | |
page(name: "pageTwo", install: true, uninstall: true) { | |
section() { | |
input "text", "text", required: false | |
mode title: "set for specific mode" | |
} | |
}*/ | |
// end mode() | |
// Begin using "modes" input type. This is just data; the SmartApp must control the logic itself | |
// Comment out pages above and uncomment this to try (be sure to uninstall the SmartApp first!) | |
/*page(name: "pageOne", nextPage: "pageTwo", uninstall: true) { | |
section() { | |
input "theswitch", "capability.switch" | |
} | |
} | |
page(name: "pageTwo", install: true, uninstall: true) { | |
section() { | |
input "modes", "mode", title: "select modes", multiple: true | |
} | |
}*/ | |
// End using "modes" input type. | |
// begin using dynamic pages, similar to app that's having trouble | |
page(name: "mainPage") | |
page(name: "optionsPage") | |
page(name: "aboutPage") | |
// end dynamic pages | |
} | |
def mainPage() { | |
dynamicPage(name: "mainPage", title: "Select your devices and settings", install: true, uninstall: true) { | |
section("choose a switch") { | |
input "theswitch", "capability.switch" | |
} | |
section("Optional Settings (Fan Speed, Timers, Motion, etc)") { | |
href (name: "optionsPage", | |
title: "Configure Optional settings", | |
description: none, | |
image: "https://raw.githubusercontent.com/dcoffing/SmartThingsPublic/master/smartapps/dcoffing/evap-cooler-thermostat.src/settings250x250.png", | |
required: false, | |
page: "optionsPage" | |
) | |
} | |
section("Version Info, User's Guide") { | |
// VERSION | |
href (name: "aboutPage", | |
title: "Evap Cooler Thermostat \n"+"Version: 1.0.160628 \n"+"Copyright © 2016 Dale Coffing", | |
description: "Tap to get user's guide.", | |
image: "https://raw.githubusercontent.com/dcoffing/SmartThingsPublic/master/smartapps/dcoffing/evap-cooler-thermostat.src/ect250x250.png", | |
required: false, | |
page: "aboutPage" | |
) | |
} | |
} | |
} | |
def optionsPage() { | |
dynamicPage(name: "optionsPage", title: "Configure Optional Settings", install: false, uninstall: false) { | |
section ("Change SmartApp name, Mode selector") { | |
label title: "Assign a name", required: false | |
mode title: "Set for specific mode(s)", required: false | |
} | |
} | |
} | |
def aboutPage() { | |
dynamicPage(name: "aboutPage", title: none, install: true, uninstall: true) { | |
section("User's Guide; Evap Cooler Thermostat") { | |
paragraph "This SmartApp does some cool stuff" | |
} | |
} | |
} | |
def installed() { | |
log.debug "Installed with settings: ${settings}" | |
initialize() | |
} | |
def updated() { | |
log.debug "Updated with settings: ${settings}" | |
unsubscribe() | |
initialize() | |
} | |
def initialize() { | |
subscribe(theswitch, "switch", handler) | |
} | |
// if using mode(), this will only fire when the current mode is one of the selected modes | |
// if using input() of type mode, the SmartApp needs to check the modes itself | |
def handler(evt) { | |
log.debug "in switch handler" | |
if (modes) { | |
log.debug "modes input selected: $modes" | |
if (modes.contains(location.currentMode)) { | |
log.debug "current mode is one of the selected modes" | |
} else { | |
log.debug "current mode is not one of the selected modes" | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment