[APP][Pro] Flow Checker

Haha! Beautiful! I see numbers.

Thank you very much my good man!

1 Like

Will make a fix for new users :smiley:

Great job, Martijn!

I’ve looked through the app now, and it works beautifully.

I have an idea for some future releases.
A category in FLOWS tab that shows dependant flows (i.e. the flows to which the other flows reference).
That way, if you are about to implement some crazy s*** something new, you could check beforehand if this is going to mess up some other automations where that particular flow is used. Does that make sense?
I am in the process of bulding my automation after a homey meltdown without a backup, so I don’t have that many flows now. The way I tracked it before was manually in a document (works well if you are religiously filling it) or making a beta flow and seeing what stops to function in a period of a month or so. This would eliminate that.

I don’t know how difficult it actually is to show that, but it looks like you check that in the app already. It’s but an idea to consider. Again - it’s a great app as it is! Thank you.

@dzt
Ah yes makes sense.
I already have something on my todo list for this.

Will check :slight_smile:

And thanks!!

2 Likes

No change unfortunately.

Thanks Martijn. I just wonder what could be possibly wrong, take a look on screenshots…
obrazek

And one of the flow :

I don’t see any variable broken…tried re-saving, no difference.

Common is “()” in the name of variable (defined by the app itself).

New app update (test: 1.16.2.):

1. FIX: settings page issue for new users.
2. FIX: findLogic

@Sharkys made a fix. Can you check if this resolves it?

2 Likes

excellent, thank you ! Old broken flows disappeared, 4 new broken appeared as expected, well done :slight_smile:

2 Likes

Nice! :smiley:

2 Likes

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… :grimacing: )

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);
3 Likes

Hey @Peter_Kawa
I like the idea :stuck_out_tongue:
It should be possible. Just thinking what the best place should be for this.

2 Likes

New app update (live: 1.16.2.):

1. FIX: settings page issue for new users.
2. FIX: findLogic

Hi @martijnpoppen,

after the last app update v1.16.2 all the variables used as “value storage” are recognized as UNUSED_LOGIC again. The same issue like mentioned in post #295.

image

Info:
– Variable Hue_Lesen_Dimm = 1
– Variable Hue_Lesen_Temp = 0.55

This issue was solved with app v1.16.0.

If it’s not fixable or to complicated to fix, I will use “normal” values in the flows instead of logic variables.

Will have a check @fantross

Probalby I can fix it but then I’ll @Sharkys too to test. As this seems to conflict with each other :stuck_out_tongue:

2 Likes

I wasn’t reporting issues with unused variables, it was other way around - until latest Flow check version, it reported something broken, which was not and something not broken, which actually was :wink:

Yes exaclty. But that’s on the same line :stuck_out_tongue:
So it’s conflicting in some way

will check!

1 Like

New app update (test: 1.16.3.):

1. FIX: nested logic

@fantross can you check?

@Sharkys everything still working? :speak_no_evil:

1 Like

seems to be ok after upgrade and forcing the check :slight_smile:

1 Like

For me seems also be ok, the variables are not listed anymore :+1:t3:
Thx again @martijnpoppen

1 Like

New app update (live: 1.16.3.):

1. FIX: nested logic

2 Likes

Hi Martijn,

Because I’m having some problems with my Homey in terms of memory, I’m working with Athom to find out where the problem is.
They indicate that my memory is usually at 200% and that it is most likely due to some apps and flows that run too often etc.
I just wouldn’t know what flows that could be.
Is there an option in flow checker to see how often a certain flow is run and if it consumes too much memory?
All my apps stay well below 30mb of memory so I don’t know where to look for the problem.

Thank you.