definition( name: "Hub Details", namespace: "hubDetails", author: "Josh Lobe", description: "Hub details and statistics.", category: "Convenience", iconUrl: "", iconX2Url: "" ) import java.text.DecimalFormat import java.text.SimpleDateFormat hubUrl = "http://${location.hub.localIP}" preferences { page(name: "mainPage", title: "Hub Details", install: true, uninstall: true) { section { Integer DD = location.hub.uptime / (24 * 3600) Integer HH = (location.hub.uptime % (24 * 3600)) / 3600 Integer MM = (location.hub.uptime % 3600) / 60 Integer SS = location.hub.uptime % 60 // Scripts html = "" html += "
" html += "
" // Hub Details html += "" html += "" html += "" html += "" html += "" html += "" html += "" html += "" html += "" html += "" html += "" html += "
Hub Details
Name${location.hub.name}
Model${getHubVersion()}
Local IP${location.hub.localIP}
Firmware${location.hub.firmwareVersionString}
Zigbee ID${location.hub.zigbeeId}
Zigbee EUI${location.hub.zigbeeEui}
Zigbee Channel${location.hub.properties.data.zigbeeChannel}
Zigbee Pan ID${location.hub.data.zigbeePanID}
Uptime${ DD + ' days, ' + HH + ' Hours, ' + MM + ' Minutes, and ' + SS + ' Seconds' }
" httpGet([ uri: "${hubUrl}:8080/hub2/hubData", contentType: "application/json" ]) { resp -> if (resp.success) { // Hub Data html += "" html += "" html += "" html += "" html += "" html += "
Hub Data
Hub ID${resp.data.hubId}
Access Token${resp.data.baseModel.dashboard.accessToken}
Hub Version${resp.data.hubVersion}
" // Hub Alerts html += "" html += "" html += "" html += "" html += "" html += "" html += "" html += "" html += "" html += "" html += "" html += "" html += "
Hub Alerts
Load High${resp.data.alerts.hubHighLoad}
Load Elevated${resp.data.alerts.hubLoadElevated}
Load Severe${resp.data.alerts.hubLoadSevere}
Low Memory${resp.data.alerts.hubLowMemory}
Large-ish Database${resp.data.alerts.hubLargeishDatabase}
Large Database${resp.data.alerts.hubLargeDatabase}
Huge Database${resp.data.alerts.hubHugeDatabase}
Zigbee Offline${resp.data.alerts.zigbeeOffline}
ZWave Offline${resp.data.alerts.zwaveOffline}
Spammy Devices${resp.data.alerts.spammyDevices}
" } } html += "
" html += "
" // Location Details html += "" html += "" html += "" html += "" html += "" html += "" html += "" html += "" html += "" html += "" html += "" html += "" html += "" html += "
Location Details
Name${location.name}
ID${location.id}
Firmware${location.hub.firmwareVersionString}
Zip Code${location.zipCode}
Latitude${location.latitude}
Longitude${location.longitude}
Sunrise${location.sunrise}
Sunset${location.sunset}
HSM Status${location.hsmStatus}
HSM Mode${location.properties.currentMode}
Temp Scale${location.temperatureScale}
" // Hub Endpoints html += "" html += "" httpGet([ uri: "${hubUrl}:8080/hub/advanced/freeOSMemory" ]) { resp -> if (resp.success) { DecimalFormat df = new DecimalFormat( "#,###" ) historyLink = "(history)" html += "" } } httpGet([ uri: "${hubUrl}:8080/hub/advanced/internalTempCelsius" ]) { resp -> if (resp.success) { html += "" } } httpGet([ uri: "${hubUrl}:8080/hub/advanced/databaseSize" ]) { resp -> if (resp.success) { html += "" } } httpGet([ uri: "${hubUrl}:8080/hub/advanced/maxDeviceStateAgeDays" ]) { resp -> if (resp.success) { html += "" } } httpGet([ uri: "${hubUrl}:8080/hub/advanced/maxEventAgeDays" ]) { resp -> if (resp.success) { html += "" } } html += "
Hub Endpoints
Hub Memory${df.format( resp.data.toString() as Integer )} KB ${historyLink}
Hub CPU Temp${celsiusToFahrenheit( new Double( resp.data.toString() ) )} °F
Database Size${resp.data} MB
Max State Time${resp.data} Days
Max Event Time${resp.data} Days
" httpGet([ uri: "${hubUrl}:8080/hub/zwaveVersion" ]) { resp -> if (resp.success) { zString = resp.data.toString() Integer start = zString.indexOf( '(' ) Integer end = zString.length() String wrkStr = zString.substring( start, end ).replace( "(", "[" ).replace( ")", "]" ) HashMap zMap = (HashMap)evaluate( wrkStr ) // ZWave Data html += "" html += "" html += "" html += "" html += "" html += "" html += "" html += "" html += "
ZWave Data
Library Type${zMap.zWaveLibraryType}
Protocol Version${zMap.zWaveProtocolVersion}
Protocol Sub Version${zMap.zWaveProtocolSubVersion}
Firmware Version${zMap.firmware0Version}
Firmware Sub Version${zMap.firmware0SubVersion}
Hardware Version${zMap.hardwareVersion}
" } } html += "
" html += "
" httpGet([ uri: "${hubUrl}:8080/hub/advanced/freeOSMemoryHistory", contentType: "text/html" ]) { resp -> if (resp.success) { html += "
" // Memory Graph html += "
" html += "
" html += "
" // CPU Graph html += "
" html += "
" html += "
" html += "
" def count = 0 def times = '' def mems = '' def cpus = '' loadWork = resp.data.toString() loadWork.eachLine{ if( it.contains( "Date" ) ) return count++ if( count % 20 != 0 ) return line = it.split( "," ) Date date = Date.parse( 'MM-dd H:mm:ss', line[0] ) String newDate = date.format( 'MM-dd, h:mm a' ) times += '"' + newDate + '",' mems += line[1] + ',' cpus += line[2] + ',' } times = times.replaceAll(',$', ''); mems = mems.replaceAll(',$', ''); cpus = cpus.replaceAll(',$', ''); html += "" } } // Styles html += "" // Print the page paragraph html } } } def installed() { log.trace "Installed Hub Details Application" updated() } def updated() { log.trace "Updated Hub Details Application" } def uninstalled() { log.trace "Uninstalled Hub Details Application" }