# Detect a flow has run

**URL:** <https://community.homey.app/t/detect-a-flow-has-run/55337>\
**Category:** Developers\
**Tags:** homeyscript\
**Created:** [November 24, 2021, 10:26am UTC](https://community.homey.app/t/detect-a-flow-has-run/55337 "2021-11-24T10:26:09Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![HenkWillem](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/henkwillem/32/47676_2.png) [@HenkWillem](https://community.homey.app/u/HenkWillem)\
**Post date:** [November 24, 2021, 10:26am UTC](https://community.homey.app/t/detect-a-flow-has-run/55337/1 "2021-11-24T10:26:09Z")

</div>

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,

---

<div class="post-metadata">

**Author:** ![robertklep](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/robertklep/32/160628_2.png) [@robertklep](https://community.homey.app/u/robertklep)\
**Post date:** [November 24, 2021, 10:40am UTC](https://community.homey.app/t/detect-a-flow-has-run/55337/2 "2021-11-24T10:40:06Z")

</div>

> [@HenkWillem](#):
>
> Could I use HomeyScript to detect every flow that has run?

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.

---

<div class="post-metadata">

**Author:** ![Edwin\_D](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/edwin_d/32/136417_2.png) [@Edwin\_D](https://community.homey.app/u/Edwin_D)\
**Post date:** [November 24, 2021, 12:10pm UTC](https://community.homey.app/t/detect-a-flow-has-run/55337/3 "2021-11-24T12:10:47Z")

</div>

The [[App][Pro] PaperTrails Log - Advanced Logging and Log management (v0.6.3)](https://community.homey.app/t/app-pro-papertrails-log-advanced-logging-and-log-management-v0-6-3/40) can add a logging line to every flow and sent that to a syslog server. May be of use to you?

---

<div class="post-metadata">

**Author:** ![Peter\_Kawa](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/peter_kawa/32/173848_2.png) [@Peter\_Kawa](https://community.homey.app/u/Peter_Kawa)\
**Post date:** [November 24, 2021, 12:39pm UTC](https://community.homey.app/t/detect-a-flow-has-run/55337/4 "2021-11-24T12:39:09Z")

</div>

@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.

---

<div class="post-metadata">

**Author:** ![robertklep](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/robertklep/32/160628_2.png) [@robertklep](https://community.homey.app/u/robertklep)\
**Post date:** [November 24, 2021, 1:22pm UTC](https://community.homey.app/t/detect-a-flow-has-run/55337/5 "2021-11-24T13:22:33Z")

</div>

The trigger count for each flow is contained within the results of [`Homey.flow.getFlows()`](https://athombv.github.io/node-homey-api/HomeyAPIV2.ManagerFlow.html#getFlows).

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

```auto
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! 👍🏻
