/* * * * 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 * ------------- ------------------- --------------------------------------------------------- * 05Jan2025 thebearmay capture privateF and actRuleMain */ import groovy.transform.Field import groovy.json.JsonSlurper static String version() { return '0.0.11' } definition ( name: "Rule References Rule Table", namespace: "thebearmay", author: "Jean P. May, Jr.", description: "Simple Table Display for Rules referencing other Rules", category: "Utility", importUrl: "https://raw.githubusercontent.com/thebearmay/hubitat/main/apps/ruleRruleList.groovy", installOnOpen: true, oauth: false, iconUrl: "", iconX2Url: "" ) preferences { page name: "mainPage" } 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("debugEnabled",[value:"false",type:"bool"]) } def mainPage(){ dynamicPage (name: "mainPage", title: "", install: true, uninstall: true) { section("
| Rule Affects | |
|---|---|
| Rule Name(id) | Rules Affected(id) | Related Rules | " childApps.each { ca -> jData=readJsonPage("http://127.0.0.1:8080/installedapp/statusJson/${ca.key}") aSHold=[] oTable += "
| ${ca.value}(${ca.key}) | "
jData.appSettings.each { aS ->
if(aS.name.toString().contains('ruleAct') || aS.name.toString().contains('pauseRule.') || aS.name.toString().contains('valFunction.') || aS.name.toString().contains('privateT') || aS.name.toString().contains('privateF') || aS.name.toString().contains('stopAct')){
vSplit = aS.value.toString().replace('\"','').replace('[','').replace(']','').split(',')
//log.debug "${aS.value} ${vSplit}"
vSplit.each{
if(ca.key != it)
aSHold.add("\"$it\"")
}
}
}
if(debugEnabled)
log.debug "$aSHold"
i=0
aSHold.sort().unique().each {
sInx = it.toString().indexOf('\"')+1
eInx = it.toString().indexOf('\"',sInx)
aKey=it.toString().substring(sInx,eInx)
if(aKey != 'null' && aKey != ca.key ){
if(i>0) oTable += ", " i++ aName=getName(aKey,childApps) oTable+= "${aName}(${aKey})" rule2Runner.add([key:"$aKey", value:"${ca.key}", name:"$aName"]) } } oTable += ' |
| In Use | |
|---|---|
| Rule Name(id) | In Use By(id) |
| ${r.name}(${r.key}) | " holdR=[] holdR.add(r.value) lastKey = r.key } else if(r.key != 'null'){ holdR.add(r.value) } } i=0 holdR.sort().each{ if(i>0) oTable+= ', ' oTable+="${getName(it,childApps)}(${it})" i++ } oTable+=' |