/* * Device Details Display * * 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, 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. * * Change History: * * Date Who What * ---- --- ---- * 2021-03-11 thebearmay Original version 0.1.0 * 2021-03-15 thebearmay Release Candidate version 1.0.0 * 2021-04-14 thebearmay pull in last attribute state change * 2021-04-25 thebearmay error when attribute has never been set * 2021-05-04 thebearmay hub 2.2.7x changes * 2021-07-28 thebearmay add .properties expansion * 2021-11-19 thebearmay add report option ->v2.0.0 * 2021-11-22 thebearmay clean up last activity date on report and add commands * 2022-02-07 thebearmay add Capabilities to the report * 2022-06-20 thebearmay embedded section error */ import java.text.SimpleDateFormat static String version() { return '2.0.4' } definition ( name: "Device Details Display", namespace: "thebearmay", author: "Jean P. May, Jr.", description: "Display the capabilities, attributes, commands and device data for devices selected.", category: "Utility", importUrl: "https://raw.githubusercontent.com/thebearmay/hubitat/main/apps/deviceCharacteristics.groovy", oauth: false, iconUrl: "", iconX2Url: "" ) preferences { page name: "mainPage" page name: "deviceCharacteristics" page name: "deviceReport" } def installed() { // log.trace "installed()" state?.isInstalled = true initialize() } def updated(){ // log.trace "updated()" if(!state?.isInstalled) { state?.isInstalled = true } if(debugEnable) runIn(1800,logsOff) } def initialize(){ } void logsOff(){ app.updateSetting("debugEnable",[value:"false",type:"bool"]) } def mainPage(){ dynamicPage (name: "mainPage", title: "", install: true, uninstall: true) { if (app.getInstallationState() == 'COMPLETE') { section("Main") { input "qryDevice", "capability.*", title: "Devices of Interest:", multiple: true, required: true, submitOnChange: true if (qryDevice != null) { href "deviceCharacteristics", title: "Device Characteristics", required: false href "deviceReport", title: "Device Report", required: false } } } else { section("") { paragraph title: "Click Done", "Please click Done to install app before continuing" } } } } def deviceCharacteristics(){ dynamicPage (name: "deviceCharacteristics", title: "", install: false, uninstall: false) { // section("Device Characteristics"){ def strWork = "" for(i=0;i 1){ if(location.hub.firmwareVersionString <= "2.2.7.0") { unt = stateParts[3]?.trim() ts = stateParts[0] dsc= stateParts[1] }else { unt = stateParts[4]?.replace("unit=","") unt = unt.trim() ts = stateParts[1]?.replace("date=","") dsc = stateParts } tempDisp = "\n\t\tActivity Timestamp: ${ts}\n\t\tEvent Desc: ${dsc}\n\t\tUnit:$unt" // [2] - value, [4] - data type } else tempDisp = "N/A" qryDeviceState += "$it (${it.dataType}): $tempValue \n\tLast State Change $tempDisp" nl = true } def devAttr = qryDevice[i].supportedAttributes def devCap = qryDevice[i].capabilities def devCmd = qryDevice[i].supportedCommands def devData = qryDevice[i].getData() def devId = qryDevice[i].getId() def devType = qryDevice[i].getTypeName() pStr1 = "

$qryName

ID: $devId \n\n"// Room: $devRoom \n\n" pStr1 += "Type: $devType\n\n" pStr1 += "Capabilities: $devCap\n\n" pStr1 += "Attributes:$devAttr" pStr2 = "Device Data: $devData" section ("") { paragraph pStr1 } section ("Attribute Details", hideable: true, hidden: true) { paragraph "Current Values:\n$qryDeviceState" } section { for (n=0;n(" + devCmd.parameters[n] + ")" } paragraph "Commands:$devCmd" } section ("Command Details", hideable: true, hidden: true) { paragraph " $strWork " } section (""){ paragraph pStr2 } section ("Properties Details", hideable: true, hidden: true) { propStr ="" qryDevice[i].properties.each { propStr+="$it
" } paragraph propStr } } //} } } def deviceReport(){ dynamicPage (name: "deviceReport", title: "", install: false, uninstall: false) { section("Device Characteristics Report"){ rpt=buildReport() String rptHTML = """ """ paragraph "$rptHTML" paragraph "
$rpt
" } } } def buildReport() { hh = hubitat.helper.HexUtils String html = "" html += "" qdSorted = qryDevice.displayName.sort() for(i=0; i" } } html += "" html += "" SimpleDateFormat sdfIn = new SimpleDateFormat("yyyy-MM-dd HH:mm:ssZZZZZ") SimpleDateFormat sdfOut = new SimpleDateFormat("ddMMMyyyy HH:mm:ss") Date wkDate = sdfIn.parse((String)it.lastActivity) fDate = sdfOut.format(wkDate) html += "" html +="" } } } html +="
NameTypeStatusDisabledControllerCapabilitiesAttributesCommandsDataDNILast Activity
$dString${it.deviceNetworkId}${fDate}
" return html } def appButtonHandler(btn) { switch(btn) { default: log.error "Undefined button $btn pushed" break } } def intialize() { }