# One flow to log all device status changes?

**URL:** <https://community.homey.app/t/one-flow-to-log-all-device-status-changes/53198>\
**Category:** Questions & Help\
**Tags:** devices, flow\
**Created:** [October 16, 2021, 6:36am UTC](https://community.homey.app/t/one-flow-to-log-all-device-status-changes/53198 "2021-10-16T06:36:49Z")\
**Posts on this page:** 19\
**Page:** 1

<div class="post-metadata">

**Author:** ![DGalama](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/dgalama/32/10402_2.png) [@DGalama](https://community.homey.app/u/DGalama)\
**Post date:** [October 16, 2021, 6:36am UTC](https://community.homey.app/t/one-flow-to-log-all-device-status-changes/53198/1 "2021-10-16T06:36:49Z")

</div>

How can I create a flow that adds a log entry and/or sends a notification when any of my devices is turned on or off?  
There is a flow card that you can use to report when any device has not reported to Homey, but I cannot seem to find this for status changes.  
Do I really need to create separate flows for every device I own?

---

<div class="post-metadata">

**Author:** ![Le\_Cactus](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/le_cactus/32/9727_2.png) [@Le\_Cactus](https://community.homey.app/u/Le_Cactus)\
**Post date:** [October 16, 2021, 8:45am UTC](https://community.homey.app/t/one-flow-to-log-all-device-status-changes/53198/2 "2021-10-16T08:45:05Z")

</div>

Depends on what you would like to log to. There are a few apps that could do it for you, but they log to a Influx of Microsoft SQL database.

Or maybe mttq can be of use?

---

<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:** [October 16, 2021, 10:50am UTC](https://community.homey.app/t/one-flow-to-log-all-device-status-changes/53198/3 "2021-10-16T10:50:12Z")

</div>

Try papertrails!

> [@Tradfri light triggered by Tradfri app, without flow](https://community.homey.app/t/tradfri-light-triggered-by-tradfri-app-without-flow/52666/7):
>
> That’s odd. I can only think of a loose wire connector, or maybe even a broken wire. Probably the lights turn on if you remove the power for a moment? And do you have a logcard added to every flow? If not: To be able to discover what your flows are doing and when, and how many times (per sec), you can consider installing the [Papertrails app](https://community.homey.app/t/app-pro-papertrails-log-advanced-logging-and-log-management-v0-6-3/40), and add log cards to all of your flows in just one go. It also adds ELSE logcards, if the THEN ELSE part is used in a flow. It even replaces SimpleLog…

---

<div class="post-metadata">

**Author:** ![DGalama](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/dgalama/32/10402_2.png) [@DGalama](https://community.homey.app/u/DGalama)\
**Post date:** [October 16, 2021, 11:33am UTC](https://community.homey.app/t/one-flow-to-log-all-device-status-changes/53198/4 "2021-10-16T11:33:36Z")

</div>

I use Papertrails. So what I would like to achieve is that if a light is switched on, a line is added to the Papertrails log stating “(date)(time) [device x] switched on”.

---

<div class="post-metadata">

**Author:** ![Le\_Cactus](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/le_cactus/32/9727_2.png) [@Le\_Cactus](https://community.homey.app/u/Le_Cactus)\
**Post date:** [October 16, 2021, 12:42pm UTC](https://community.homey.app/t/one-flow-to-log-all-device-status-changes/53198/5 "2021-10-16T12:42:39Z")

</div>

You can’t. You need a flow for that. A flow per device.

Like I said, there are some apps that can help you without having to create a flow for each device, but they log to dabases, not to papertrail.

---

<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:** [October 16, 2021, 3:49pm UTC](https://community.homey.app/t/one-flow-to-log-all-device-status-changes/53198/6 "2021-10-16T15:49:42Z")

</div>

> [@DGalama](#):
>
> if a light is switched on, a line is added to the Papertrails log stating “(date)(time) [device x] switched on”.

This is not a text log file, (for us normal users that is), but maybe this is somewhat usable? It’s build in since some time.

 ![Screenshot_20211016-174527_Homey](https://us1.discourse-cdn.com/flex025/uploads/athom/original/3X/0/6/066ddacfaeadefbcecef66b9a14b338fba531ef7.jpeg)

Hitting the “x hrs ago” line will reveal timestamp.

---

<div class="post-metadata">

**Author:** ![DGalama](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/dgalama/32/10402_2.png) [@DGalama](https://community.homey.app/u/DGalama)\
**Post date:** [October 17, 2021, 6:19am UTC](https://community.homey.app/t/one-flow-to-log-all-device-status-changes/53198/7 "2021-10-17T06:19:51Z")

</div>

I am aware of this functionality, but what I am looking for is to consolidate exactly this info for all devices in one logfile.

---

<div class="post-metadata">

**Author:** ![DGalama](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/dgalama/32/10402_2.png) [@DGalama](https://community.homey.app/u/DGalama)\
**Post date:** [October 17, 2021, 6:21am UTC](https://community.homey.app/t/one-flow-to-log-all-device-status-changes/53198/8 "2021-10-17T06:21:38Z")

</div>

Amazing that this is not a standard functionality.  
So which apps are you suggesting?

---

<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:** [October 17, 2021, 5:03pm UTC](https://community.homey.app/t/one-flow-to-log-all-device-status-changes/53198/9 "2021-10-17T17:03:03Z")

</div>

> [@DGalama](#):
>
> I am aware of this functionality, but what I am looking for is to consolidate exactly this info for all devices in one logfile.

I get that, the “funny” thing is, the on/off data presented is stored in some kind of log file.  
So if anyone knows how to retreive that with Homeyscript?

A workaround: if you entered different energy levels for your on/off devices,

> ![Screenshot_20211017-184707_Homey](https://us1.discourse-cdn.com/flex025/uploads/athom/original/3X/c/8/c8dc03675ebd76f10d6bd9a3b002962cf3e0098b.jpeg)

your desired data is available in Insights.

> ![Screenshot_20211017-185720_Chrome](https://us1.discourse-cdn.com/flex025/uploads/athom/original/3X/2/c/2c43c32176a4af8c5b36a4cc2444dafacbf84337.jpeg)

While using an insights export app, you can create your logfile

> ![Screenshot_20211017-172007_Chrome](https://us1.discourse-cdn.com/flex025/uploads/athom/original/3X/c/0/c0514a046929f94cbd4c7a842d3f52b01dac75fc.jpeg)

---

<div class="post-metadata">

**Author:** ![DGalama](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/dgalama/32/10402_2.png) [@DGalama](https://community.homey.app/u/DGalama)\
**Post date:** [October 22, 2021, 9:21pm UTC](https://community.homey.app/t/one-flow-to-log-all-device-status-changes/53198/11 "2021-10-22T21:21:54Z")

</div>

I decided to create two flows for every device: one to log turning and one to log turning off the device. A bit cumbersome, but by using the web version of the Homey app it took a reasonable amount of time.  
I still find it remarkable that information that is available in the system cannot not be consolidated in a file and/or exported.

---

<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:** [October 23, 2021, 6:42am UTC](https://community.homey.app/t/one-flow-to-log-all-device-status-changes/53198/12 "2021-10-23T06:42:42Z")

</div>

> [@DGalama](#):
>
> I still find it remarkable that information that is available in the system cannot not be consolidated in a file and/or exported.

Homey is a black box, which is intentional. Athom doesn’t want users to have too much control over it.

---

<div class="post-metadata">

**Author:** ![Le\_Cactus](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/le_cactus/32/9727_2.png) [@Le\_Cactus](https://community.homey.app/u/Le_Cactus)\
**Post date:** [October 23, 2021, 8:34am UTC](https://community.homey.app/t/one-flow-to-log-all-device-status-changes/53198/13 "2021-10-23T08:34:51Z")

</div>

> [@Peter\_Kawa](#):
>
> I get that, the “funny” thing is, the on/off data presented is stored in some kind of log file.  
> So if anyone knows how to retreive that with Homeyscript?

AFAIK on/off data (or any other boolean data) isn’t stored, so a Homey script won’t help you there.

---

<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:** [October 23, 2021, 4:45pm UTC](https://community.homey.app/t/one-flow-to-log-all-device-status-changes/53198/14 "2021-10-23T16:45:06Z")

</div>

> [@Le\_Cactus](#):
>
> AFAIK on/off data (or any other boolean data) isn’t stored

I don’t understand that… The info from the on/off data below has to come from a file / database of some kind. Where do you think it is from? It has to be stored somehow?  
It also survives a system reboot, so it’s not in RAM only.

> [@Peter\_Kawa](#):
>
> ![Screenshot_20211016-174527_Homey](https://us1.discourse-cdn.com/flex025/uploads/athom/original/3X/0/6/066ddacfaeadefbcecef66b9a14b338fba531ef7.jpeg)
> 
> Hitting the “x hrs ago” line will reveal timestamp.

---

<div class="post-metadata">

**Author:** ![Caseda](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/caseda/32/138695_2.png) [@Caseda](https://community.homey.app/u/Caseda)\
**Post date:** [October 23, 2021, 5:14pm UTC](https://community.homey.app/t/one-flow-to-log-all-device-status-changes/53198/15 "2021-10-23T17:14:45Z")

</div>

all boolean values are also stored in “insights” database like all other values, the insight page on [https://my.homey.app/](https://my.homey.app/) (and previously insight.homey.app) just doesn’t show them, only number insights.

---

<div class="post-metadata">

**Author:** ![Le\_Cactus](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/le_cactus/32/9727_2.png) [@Le\_Cactus](https://community.homey.app/u/Le_Cactus)\
**Post date:** [October 23, 2021, 5:29pm UTC](https://community.homey.app/t/one-flow-to-log-all-device-status-changes/53198/16 "2021-10-23T17:29:42Z")

</div>

I stand corrected then 😊 didn’t know that.

---

<div class="post-metadata">

**Author:** ![DGalama](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/dgalama/32/10402_2.png) [@DGalama](https://community.homey.app/u/DGalama)\
**Post date:** [October 23, 2021, 8:46pm UTC](https://community.homey.app/t/one-flow-to-log-all-device-status-changes/53198/17 "2021-10-23T20:46:51Z")

</div>

So, now all we need is someone to write an app to collect and store all device activities in a CSV, ready for export. 🙃

---

<div class="post-metadata">

**Author:** ![Le\_Cactus](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/le_cactus/32/9727_2.png) [@Le\_Cactus](https://community.homey.app/u/Le_Cactus)\
**Post date:** [October 24, 2021, 12:01am UTC](https://community.homey.app/t/one-flow-to-log-all-device-status-changes/53198/18 "2021-10-24T00:01:44Z")

</div>

> [@Peter\_Kawa](#):
>
> I get that, the “funny” thing is, the on/off data presented is stored in some kind of log file.  
> So if anyone knows how to retreive that with Homeyscript?

Sure, although it was a bit of trial-and-error 😉

```auto
let allDevices = await Homey.insights.getLogs()
let onoffDevices = allDevices.filter(function (capability){
    return capability.id==='onoff'
})
onoffDevices.forEach(async (device) => {
  let deviceData = await Homey.insights.getLogEntries({uri: device.uri, id: device.id})
  deviceData.values.forEach( value => {
    console.log(device.uriObj.name, value.t, value.v,'(', value.originName, ')')
  })
})

```

It will output something like this

> Switch Lampen Keuken 2021-10-17T23:29:14.677Z false ( Lampen Beneden Uit )  
> Switch Lampen Keuken 2021-10-18T05:37:23.481Z true ( deCONZ )  
> Switch Lampen Keuken 2021-10-18T06:19:52.820Z false ( deCONZ )  
> Switch Lampen Keuken 2021-10-22T17:02:51.677Z true ( Lampen Beneden Aan )  
> Switch Lampen Keuken 2021-10-22T23:46:34.780Z false ( Lampen Beneden Uit )  
> Switch Lampen Keuken 2021-10-23T16:49:06.216Z true ( Lampen Beneden Aan )  
> Lampen Beneden 2021-10-10T23:54:03.740Z false ( Lampen Beneden Uit )  
> Lampen Beneden 2021-10-10T23:54:03.740Z false ( Lampen Beneden Uit )  
> Lampen Beneden 2021-10-11T05:24:40.159Z true ( deCONZ )  
> Lampen Beneden 2021-10-11T06:36:09.768Z false ( deCONZ )  
> Lampen Beneden 2021-10-11T06:36:13.347Z true ( deCONZ )  
> Lampen Beneden 2021-10-11T08:54:50.812Z false ( \< group \> )  
> Lampen Beneden 2021-10-11T15:57:59.171Z true ( deCONZ )  
> Lampen Beneden 2021-10-11T23:13:42.747Z false ( Lampen Beneden Uit )

Grouped by device, sorted by date/time (‘zulu’ time) and it gives you the name of the app or flow that changed the state (true which is on or false which is off)

For @DGalama this still isn’t a solution, as it still isn’t in CSV format. Maybe a feature request to the developer of [Archive Insights App for Homey | Homey](https://homey.app/en-us/app/com.gruijter.insights2csv/Archive-Insights/) (@Gruijter) may help, he might be willing to include the onoff capability in the export features of _Archive Insights_

---

<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:** [October 24, 2021, 3:23pm UTC](https://community.homey.app/t/one-flow-to-log-all-device-status-changes/53198/19 "2021-10-24T15:23:26Z")

</div>

That’s great @Le_Cactus !! Thanks!

EDIT:

> [@Le\_Cactus](#):
>
> `console.log(device.uriObj.name, value.t, value.v,'(', value.originName, ')')`

This way it’s output is returned in .csv format @DGalama :  
`console.log('"' + device.uriObj.name + '"' + ',',value.t + ',',value.v + ',','"' + value.originName + '"')`

Copy the output and “paste Special” it into an spreadsheet tool.  
Mostly the default separator = `,` and string delimiter = `"`

 ![csv_paste-special](https://us1.discourse-cdn.com/flex025/uploads/athom/original/3X/e/3/e3ea508d019fab3f357e42dff3fe038c042d6d7d.png)

Next, how to retreive the local time instead of zulu time 😉 😉

---

<div class="post-metadata">

**Author:** ![DGalama](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/dgalama/32/10402_2.png) [@DGalama](https://community.homey.app/u/DGalama)\
**Post date:** [October 25, 2021, 9:14am UTC](https://community.homey.app/t/one-flow-to-log-all-device-status-changes/53198/20 "2021-10-25T09:14:04Z")

</div>

Wow, this looks great, thanks!
