/* * Device UI * * * Licensed Virtual 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, WIyTHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License * for the specific language governing permissions and limitations under the License. * * Date Who Description * ------------- ------------------- --------------------------------------------------------- * */ static String version() { return '0.1.2' } import java.text.SimpleDateFormat import groovy.json.JsonSlurper import groovy.json.JsonOutput import groovy.transform.Field //include thebearmay.uiInputElements definition ( name: "Device UI", namespace: "thebearmay", author: "Jean P. May, Jr.", description: "Alternate Device UI", category: "Utility", importUrl: "https://raw.githubusercontent.com/thebearmay/hubitat/main/apps/deviceUI.groovy", installOnOpen: true, oauth: false, iconUrl: "", iconX2Url: "" ) preferences { page name: "deviceList" page name: "uiRender" } mappings { /* path("/refresh") { action: [POST: "refresh", GET: "refresh"] } */ } def installed() { // log.trace "installed()" state?.isInstalled = true initialize() } def updated(){ // log.trace "updated()" if(!state?.isInstalled) { state?.isInstalled = true } if(debugEnabled) runIn(1800,logsOff) } def initialize(){ } void logsOff(){ app.updateSetting("debugEnabled",[value:"false",type:"bool"]) } def deviceList(){ dynamicPage (name: "deviceList", title: "
| ${selDev.displayName}(${selDev.id}) | ${ndBtn} | ${resetLO} |
Current States
' String region3 = '' String region4 = '' String region5 = '' String region6 = '' deviceMap.commands.sort{it.name}.each { region1 += buildCommandBlock(it) } deviceMap.device.currentStates.sort().each{ it.value.stringValue=it.value.stringValue.replace('\"','\\\"') region2 += "${it.value.attributeName}: ${it.value.stringValue}State Variables
' deviceMap.deviceState.sort().each{ it.value=it.value.toString().replace('\"','\\\"') region2 += "${it.key}: ${it.value}
" } region3 = buildPreference(deviceMap.settings) region3 += "| ${savePref} | ${revPref} |
| ${saveDevInf} | ${revDevInf} |
$title
" String params = '' if(parms.parameters){ if(debugEnabled) log.debug "Found ${parms.parameters.size()} parameters" int inx = 0 parms.parameters.each { pType = it.type.toLowerCase().trim() if("$pType" == "string") pType = 'text' String nameBlock = '' if(it.name) nameBlock += "${it.name}| "+getInputElemStr( [name:"devInfName", type:"text", title:"Device Name", width:"20em", background:"#ADD8E6", radius:"15px", submitOnChange:true, defaultValue:"${dVal}" ]) dVal = settings["devInfLabel"]?:dMap.label?:"" if(dVal != dMap.label && dMap.label != null) { state.lastDirty = 'label' state.devInfoDirty = true } diBlock += " | "+getInputElemStr( [name:"devInfLabel", type:"text", title:"Device Label", width:"20em", background:"#ADD8E6", radius:"15px", submitOnChange:true, defaultValue:"${dVal}" ]) dVal = settings["devInfDNI"]?:dMap.deviceNetworkId if(dVal != dMap.deviceNetworkId) { state.lastDirty = 'DNI' state.devInfoDirty = true } diBlock += " | "+getInputElemStr( [name:"devInfDNI", type:"text", title:"Device Network ID", width:"20em", background:"#ADD8E6", radius:"15px", submitOnChange:true, defaultValue:"${dVal}" ]) dVal = settings["devInfDevTypeId"]?:dMap.deviceTypeId if("$dVal" != "${dMap.deviceTypeId}") { state.lastDirty = 'deviceTypeId' state.devInfoDirty = true } //log.debug "${getInputElemStr( [name:"devInfDevTypeId", type:"enum", title:"Device Type", width:"20em", background:"#ADD8E6", radius:"15px", options:dList, submitOnChange:true, defaultValue:"${dVal}" ]).replace('<','<')}" diBlock += " |
| "+getInputElemStr( [name:"devInfDevTypeId", type:"enum", title:"Device Type", width:"20em", background:"#ADD8E6", radius:"15px", options:dList, submitOnChange:true, defaultValue:"${dVal}" ])//+"" //dVal = "${settings["devInfRoom"]}"?:"${dMap.roomId}"?:"" if(settings["devInfRoom"]) dVal = settings["devInfRoom"] else if (dMap.roomId) dVal = dMap.roomId else dVal = '' //log.debug "${settings["devInfRoom"]} ${dMap.roomId} $dVal" if("$dVal" != "${dMap.roomId}" && dMap.roomId != null) { state.lastDirty = 'roomId' state.devInfoDirty = true } diBlock += " | "+getInputElemStr( [name:"devInfRoom", type:"enum", title:"Room", width:"20em", background:"#ADD8E6", radius:"15px", options:rList, submitOnChange:true, defaultValue:"${dVal}" ])//+"" dVal = settings["devInfDash"]?:dashSelList?:"" if(dVal != dashSelList && dashSelList != []) { state.lastDirty = "dashSelList $dval $dashSelList" state.devInfoDirty = true } diBlock += " | "+getInputElemStr( [name:"devInfDash", type:"enum", title:"Dashboards", width:"20em", background:"#ADD8E6", radius:"15px", options:dashList, submitOnChange:true, defaultValue:dVal, multiple:true ])//+"" dVal = settings["devInfMaxEvent"]?:dMap.maxEvents?:11 if(dVal != dMap.maxEvents && dMap.maxEvents != null) { state.lastDirty = 'maxEvents' state.devInfoDirty = true } diBlock += " |
| "+getInputElemStr( [name:"devInfMaxEvent", type:"number", title:"Max Events * per event type (1-2000)", width:"20em", background:"#ADD8E6", radius:"15px", submitOnChange:true, defaultValue:dVal ]) dVal = settings["devInfMaxStates"]?:dMap.maxStates?:30 if(dVal != dMap.maxStates && dMap.maxStates != null) { state.lastDirty = 'maxStates' state.devInfoDirty = true } diBlock += " | "+getInputElemStr( [name:"devInfMaxStates", type:"number", title:"State History Size * per attribute (1-2000)", width:"20em", background:"#ADD8E6", radius:"15px", submitOnChange:true, defaultValue:dVal ]) dVal = settings["devInfSpammy"]?:dMap.spammyThreshold?:300 if(dVal != dMap.spammyThreshold && dMap.spammyThreshold != null) { state.lastDirty = 'spammyThreshold' state.devInfoDirty = true } diBlock += " | "+getInputElemStr( [name:"devInfSpammy", type:"number", title:"Too many events alert threshold * per hour (100-2000)", width:"20em", background:"#ADD8E6", radius:"15px", submitOnChange:true, defaultValue:dVal ]) //dVal = "${settings['devInfMeshEnabled']}"?:"${dMap.meshEnabled}"?:false if(settings['devInfMeshEnabled']) dVal = settings['devInfMeshEnabled'] else if(dMap.meshEnabled) dVal = dMap.meshEnabled else dVal = false if("${dVal}" != "${dMap.meshEnabled}" && (dVal != false && dMap.meshEnabled == null)) { state.lastDirty = 'meshEnabled' state.devInfoDirty = true //log.debug "${settings["devInfMeshEnabled"]} ${dMap.meshEnabled} $dVal" } diBlock += " |
| "+getInputElemStr( [name:"devInfMeshEnabled", type:"bool", title:"Hub Mesh Enabled", width:"20em", background:"#ADD8E6", radius:"15px", submitOnChange:true, defaultValue:dVal ]) dVal = "${settings["devInfHomeKitEnabled"]}"?:"${dMap.homeKitEnabled}"?:false if("${dVal}" != "${dMap.homeKitEnabled}" && (dVal == false && dMap.homeKitEnabled != null) ) { state.lastDirty = 'homeKitEnabled' state.devInfoDirty = true //log.debug "${settings["devInfHomeKitEnabled"]} ${dMap.homeKitEnabled} $dVal" } diBlock += " | "+getInputElemStr( [name:"devInfHomeKitEnabled", type:"bool", title:"HomeKit Enabled", width:"20em", background:"#ADD8E6", radius:"15px", submitOnChange:true, defaultValue:dVal ]) dVal = settings["devInfNotes"]?:dMap.notes?:'' if(dVal != dMap.notes && dMap.notes != null){ state.lastDirty = 'notes' state.devInfoDirty = true } diBlock += " |
| $usedBy | $dateBlock |
| Date | Name | Value | Unit | Description | Descriptive Text | Source |
|---|---|---|---|---|---|---|
| ${sdfOut.format(eDate)} | ${it.name} | ${it.value} | ${it.unit?:''} | ${it.description?.replace('<','<')?:''} | ${it.descriptionText?.replace('<','<')?:''} | ${it.source} |
| Name | Schedule | Next | Previous | Status | |
|---|---|---|---|---|---|
| ${it.handler} | ${it.schedule} | ${sdfOut.format(sdfIn.parse(it.nextRunTime))} | ${(it.prevRunTime) ? sdfOut.format(sdfIn.parse(it.prevRunTime)):""} | ${it.status} | $delBtn |
| ${it} | " } str += "
|---|