Homey Community Forum

Detect a flow has run

Hi All,

In order to push messages from Homey towards my local Monitoring Database I want to able to detect a flow has run, and then push the flow-name towards an API.

Currently I am solving this by adding a “Change Variable” Card in every single flow. And based upon the changed varible I am pushing a value towards my DB. But with many flows, this is combersome work.

Could I use HomeyScript to detect every flow that has run?

regards,

No. Even if Homeyscript was able to keep scripts running, there doesn’t seem to be an event that gets fired when a flow runs.

1 Like

The [App][Pro] PaperTrails Log - Advanced Logging and Log management (v0.6.3) can add a logging line to every flow and sent that to a syslog server. May be of use to you?

@robertklep & @HenkWillem Somehow flow runs are detected and registered (and counted):
when you hover a flowname @ my.homey.app it shows the number of runs.

Just a brainfart:
If how and where is known, one could run a flow every minute which calls a script which compares the flow-run-counters, to filter out the flows that ran that minute and log them.

2 Likes

The trigger count for each flow is contained within the results of Homey.flow.getFlows().

For example, to show all flows and their trigger count:

const flows = await Homey.flow.getFlows();

for (const [ id, flow ] of Object.entries(flows)) {
  const { name, triggerCount } = flow;

  console.log(name, ':', triggerCount);
}

So you could periodically run a Homeyscript that would collect all the trigger counts, compare them with the previous run, and have a list of flows that have run since that last run.

Nice idea, @Peter_Kawa! :+1:t2:

2 Likes