tplink-energy-monitor
tplink-energy-monitor copied to clipboard
Added New Logfile Configuration Options
Hi all,
I have am enclosing changes to a snapshot taken from 487c2e2 commit (24 Sept 2020) of the main dev branch. These changes were performed on a local copy only. I did not create any branch or fork to this git-hub project (Xeroxxx/tplink-energy-monitor). Therefore, I am simply adding these changes to a zip file attached to this issue ticket, to share with others if they find it useful. Anyone can merge these changes to a project branch if they desire (hopefully). The changes made include the following new feature additions:
FEATURE ADDITIONS:
-
Optionally use the device plug "alias" (human description) as a log filename instead of Device ID. If this configuration item is missing, the default is false "plugAliasLogFileName": false,
-
Optionally use local date and timestamp in format DD/MM/YYY hh:mm (24hr). (useful if recording data for years, as computing local time from UTC can be difficult when considering daylight savings). If this configuration item is missing, the default is false "localDateTimestampFormat": false,
-
Optionally adds additional logfile generation in csv format. If this configuration item is missing, the default is false "csvLogFileFormat" : false
Note: I updated the README.md file to reflect the new feature usage for logger-config.json. Also, if a user does not add any of the new configurations to the logger-config.json, the default behavior will be as if these options are set to "false".
So, as an example, a logger-config.json can look like this:
{
// Directory path specifying where log files should be stored. It will be created if it doesn't already exist.
"logDirPath": "/opt/tplink-monitor/data",
// The number of seconds between each log entry
"logIntervalSeconds": 60,
// The maximum number of log entries to store
"maxLogEntries": 1440 // 24hrs at 1 log/min
// Optionally use the device plug "alias" (human description) as a log filename instead of Device ID. If this configuration item is missing, the default is false
"plugAliasLogFileName": true,
// Optionally use local date and timestamp in format DD/MM/YYY hh:mm (24hr)
// (useful if recording data for years, computing local time from UTC can be difficult when considering daylight savings). If this configuration item is missing, the default is false
"localDateTimestampFormat": true,
// Optionally adds additional logfile generation in csv format. If this configuration item is missing, the default is false
"csvLogFileFormat" : true
}
Download zip file here:
tplink-energy-monitor-master-487c2e2-AddedLogConfigOptions.zip
I added another logging configuration feature: Version 2
Source Code Filename: tplink-energy-monitor-master-487c2e2-AddedLogConfigOptions-V2.zip
Changes: Optionally create separate monthly data log files Ie: every 1st month begins a new cvs and json data files with prefix "MM-YYYY-" or for example, “01-2021-“
This allows the analyzing of data to be much easier, in monthly portions, rather than working with a massive ever-growing file with thousands of data points.
To enable this feature, the configuration in logger-config.json should be: "MonthlyLogFileFormat": Y
As an example, the output files for January (created on the 1st of Jan 2021) would be like: 01-2021-Device1-log.csv 01-2021-Device1-log.json ... For February (created on the 1st of Feb, 2021): 02-2021-Device1-log.csv 02-2021-Device1-log.json
tplink-energy-monitor-master-487c2e2-AddedLogConfigOptions-V2.zip
I forgot to update the README.md file in the above source code attachment. Here it is again, with the updated README.md file. (I call this version "V2b" to distinguish from the above attachment. (There is no function code change between V2 version above and V2b attached to this message)
tplink-energy-monitor-master-487c2e2-AddedLogConfigOptions-V2b.zip