/**
* Auto_Off Parent App
*
* Copyright 2020 C Steele, Mattias Fornander
*
* 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.
*
*/
public static String version() { return "v1.0.2" }
definition(
name: "Auto_Off",
namespace: "csteele",
author: "Mattias Fornander, CSteele",
description: "The Child app will automatically turn off/on devices after set amount of time on/off",
category: "Automation",
importUrl: "https://raw.githubusercontent.com/HubitatCommunity/Auto_Off/main/Auto_Off.groovy",
iconUrl: "",
iconX2Url: "",
iconX3Url: ""
)
preferences {
page name: "mainPage", title: "", install: true, uninstall: true // ,submitOnChange: true
}
def installed() {
if (descTextEnable) log.info "Installed with settings: ${settings}"
initialize()
}
def updated() {
if (descTextEnable) log.info "Updated with settings: ${settings}"
unschedule()
if (debugOutput) runIn(1800,logsOff)
initialize()
}
def initialize() {
if (descTextEnable) log.info "There are ${childApps.size()} child smartapps"
childApps.each {child ->
child.setDebug(debugOutput, descTextEnable)
log.info "Child app: ${child.label}"
}
}
def mainPage() {
dynamicPage(name: "mainPage") {
section {
paragraph title: "Title",
"This parent app is a container for all:
Auto_Off child apps"
}
section (){app(name: "Auto_Off", appName: "Auto_Off device", namespace: "csteele", title: "Create a New Auto Off Child - Delay", multiple: true)}
// section (){app(name: "Auto_Off", appName: "Auto_Off dim", namespace: "csteele", title: "Create a New Auto Off Child - Dimmer", multiple: true)}
section (){app(name: "Auto_Off", appName: "Auto_Off poll", namespace: "csteele", title: "Create a New Auto Off Child - Poll", multiple: true)}
section (title: "Name/Rename") {label title: "Enter a name for this parent app (optional)", required: false}
section ("Other preferences") {
input "debugOutput", "bool", title: "Enable debug logging?", defaultValue: false
input "descTextEnable","bool", title: "Enable descriptionText logging?", defaultValue: true
}
display()
}
}
def logsOff() {
log.warn "debug logging disabled..."
app?.updateSetting("debugOutput",[value:"false",type:"bool"])
}
def display() {
updateCheck()
section{
paragraph "\n