Is there any way to trace what node/routine is updating a global variable?

As the title says - i have a routine/function/change node buried deep somewhere that is changing a global variable - is there any smart way to find what this is ?

Craig

OK so first thing i tried was to Export all flows to json (formatted)

I then opened that in my editor and did a search for the variable name i was interested in and that gives me a list of them all - and then what type of node it was and also the Node ID - trying to work out how to find a node id and the flow it is on in the editor

Craig

Use the search bar and search for the node id. That will show you the flow it is on.
If you then hover over the node icon and click on the magnifying glass on the left, it will take you to the correct location on the flow.

image

Good one thanks - is there anyway to do it all in one step - or is my first step of doing the export the right way to go ?

Craig

Sure just use a code snippet like this example

1 Like

Just search ctrl+f for the name then use f to step through each found node

Or use the the :mag: toolbar at the bottom of the flow canvas and the << & >> button that appear after executing a search.

Better still, don't update globals from multiple locations (bad programming practice 101). Instead, use link nodes or subflows to update globals in 1 place.

@craigcurtin Also, if you set the global value add some meta data, e.g. time updated and where/what updated the value, you would find it easier to see what, where and when the global was updated in the future.

[edit] sorry reply was not meant for you @smcgann99 pressed wrong reply button

Arguably even more betterer don't use global/flow context unless it is not practical to achieve the result by passing values via messages.

Agreed 100%

I feel folk reach for globals (and are informed to use globals) far more than they should.

There are times where context makes sense, but in many cases, context can (and should) be avoided

Hmm,

Globals seem like a very sensible solution to a lot of situations though - as an example i download our power prices every 5 minutes (as we are on a wholesale variable rate) - this is a large array that holds a lot of inforomation.

I then use this across a number of other areas where i have to make decisions based on the current power price (should i charge the EV) should i run the Heatpump in the next 1/2 hour etc etc

Each of these functions are broken into seperate flows to keep them neat and to reflect what they are doing - in my case the Global context appears to be ideal for this - plus it allows me to drill down from any flow and see what values may be being used by other flows

But i do like the idea of updating the Global variables to note what updated them and when - i will go back and redo a lot of my stuff to reflect this.

Craig

1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.