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?
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?
Try papertrails!
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â.
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.
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.
Hitting the âx hrs agoâ line will reveal timestamp.
I am aware of this functionality, but what I am looking for is to consolidate exactly this info for all devices in one logfile.
Amazing that this is not a standard functionality.
So which apps are you suggesting?
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,
your desired data is available in Insights.
While using an insights export app, you can create your logfile
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.
Homey is a black box, which is intentional. Athom doesnât want users to have too much control over it.
AFAIK on/off data (or any other boolean data) isnât stored, so a Homey script wonât help you there.
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.
all boolean values are also stored in âinsightsâ database like all other values, the insight page on https://my.homey.app/ (and previously insight.homey.app) just doesnât show them, only number insights.
I stand corrected then didnât know that.
So, now all we need is someone to write an app to collect and store all device activities in a CSV, ready for export.
Sure, although it was a bit of trial-and-error
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 (@Gruijter) may help, he might be willing to include the onoff capability in the export features of Archive Insights
Thatâs great @Le_Cactus !! Thanks!
EDIT:
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 = "
Next, how to retreive the local time instead of zulu time
Wow, this looks great, thanks!