Hi Martijn,
No clue if it’s realistic, but is it possible to show an overview of Logics Vars (and BetterLogic maybe) and the flows they reside in?
(I have a script for that (below this message) ).
Or better, a search field “Find the flow(s) used with this variable”.
Enter a (partial) variable name, and it returns the flowname(s).
I don’t know what the impact will be on the memory usage of the app.
(How did I ever do without Flow Checker… )
Cheers!
// FindLogicsVarsInFlows.js
//
// Script to find Homey Logics Variables in Flows, and orphaned Variables (by RonnyW)
// Adjusted somewhat, when called from a flow, it returns the output in a Variable (PD)
const flows = await Homey.flow.getFlows();
const logicVars = await Homey.logic.getVariables();
let flowMatches;
let varUsed;
let position = [];
let results2Var; // To be able to build a string to output the results to
// a variable [FoundLogicsVarsInFlows], for usage in flows
results2Var = ("*** Logics Variables found in Flows ***\n\n script: FindLogicsVarsInFlows.js\n\n");
for (var iLogicVar in logicVars){
results2Var = results2Var + "\n**VARIABLE:** ["+logicVars[iLogicVar].name + "]\n";
let logicVar = logicVars[iLogicVar].name;
let logicVarId = logicVars[iLogicVar].id;
varUsed = false;
for (var iFlow in flows){
flowMatches = false;
position = [];
// Search for variable name in Triggers
if (flows[iFlow].trigger.uri == "homey:manager:logic"){
for (var iArgs in flows[iFlow].trigger.args){
if ( flows[iFlow].trigger.args[iArgs].name == logicVar
|| flows[iFlow].trigger.args[iArgs].id == logicVarId){
position.push("Trigger card (IF)");
flowMatches = true;
}
}
}
// Search for variable name in Condition cards
for(var iCond in flows[iFlow].conditions){
if ( flows[iFlow].conditions[iCond] &&
flows[iFlow].conditions[iCond].uri == "homey:manager:logic"){
//log(flows[iFlow].conditions[iCond].args);
for (var iArgs in flows[iFlow].conditions[iCond].args){
if ( flows[iFlow].conditions[iCond].args[iArgs].name == logicVar
|| flows[iFlow].conditions[iCond].args[iArgs].id == logicVarId ){
position.push("Condition (AND) - direct reference");
flowMatches = true;
}
}
}
for (var iArgs in flows[iFlow].conditions[iCond].args){
if ( flows[iFlow].conditions[iCond].args[iArgs] &&
JSON.stringify( flows[iFlow].conditions[iCond].args[iArgs] ).indexOf( logicVarId ) > 0 &&
JSON.stringify( flows[iFlow].conditions[iCond].args[iArgs] ).indexOf( "homey:manager:logic" ) > 0 ){
position.push("Condition (AND) - indirect reference (Tag)");
flowMatches = true;
}
}
}
// Search for variable name in Action cards
for(var iAct in flows[iFlow].actions){
if ( flows[iFlow].actions[iAct] &&
flows[iFlow].actions[iAct].uri == "homey:manager:logic"){
for (var iArgs in flows[iFlow].actions[iAct].args){
if ( flows[iFlow].actions[iAct].args[iArgs].name == logicVar
|| flows[iFlow].actions[iAct].args[iArgs].id == logicVarId ){
position.push("Action (THEN) - direct reference");
flowMatches = true;
}
}
}
for (var iArgs in flows[iFlow].actions[iAct].args){
if ( flows[iFlow].actions[iAct].args[iArgs] &&
JSON.stringify( flows[iFlow].actions[iAct].args[iArgs] ).indexOf( logicVarId ) > 0 &&
JSON.stringify( flows[iFlow].actions[iAct].args[iArgs] ).indexOf( "homey:manager:logic" ) > 0 ){
position.push("Action (THEN) - indirect reference (Tag)");
flowMatches = true;
}
}
}
// Results of Flows found:
if (flowMatches == true){
varUsed = true;
results2Var = results2Var + " - ";
results2Var = results2Var + "**Flowname:** (" + flows[iFlow].name + ") \n";
results2Var = results2Var +" -Position: \n";
for (iPos in position){
results2Var = results2Var + " -" +position[iPos] + " / \n";
}
}
}
if (!varUsed){
results2Var = results2Var +"*** NOT FOUND IN FLOWS *** \n\n";
}
}
// Output to a StringVariable [FoundLogicsVarsInFlows]
await tag( "FoundLogicsVarsInFlows", results2Var );
//
// Output (just test to view the result data in 'results2Var')
//console.log(results2Var)
return(true);