The Correction tab of a MySQL logger rewrites the logged history: change or delete values, apply a formula to a period, recompute the aggregates, or import values from a CSV file. Typical uses: fix a meter index after a meter replacement, remove aberrant values, reload a history exported from another system.
A correction writes directly into the database and cannot be undone by the device. Download the backup offered before each correction (see 6).
mysql driver), and only users who can open the Loggers menu (administrators) can use it. See Logging and history.Open the logger panel (click its name in Loggers), then the Correction tab. The form has five fields:
| Field | Default | Description |
|---|---|---|
| Address | — | One or several logged addresses. |
| Table | logs |
logs for the raw values, or an aggregate table: logs_quarterly (15 min), logs_3hourly, logs_daily, logs_weekly, logs_monthly. |
| Type | manual |
manual, function, recompute or import (sections 2 to 5). |
| Start, End | today 00:00, tomorrow 00:00 | Period of the correction. The end is excluded. |
Every type ends with a confirmation window that sums up the action, the period (in the time of the device), the number of addresses, and the backup option. The aggregates of the period are recomputed after each correction.
A JavaScript function is called for every row of the selected addresses in the period:
function(row){ // row = {ts, address, value, value_string}
// your code
}
row to change the row.return 'd' deletes the row.value_avg, value_min, value_max, value_first, value_last and value_count instead of value.Click Preview to see what the function would do, without writing anything. Then click Run function. A syntax error is reported before the task starts; an error during the task stops it with the status error.
Examples:
// Scale factor: the meter was configured in Wh instead of kWh
row.value = row.value / 1000
// Remove aberrant values
if(row.value < 0 || row.value > 100000) return 'd'
Leaving Address empty runs the function on all addresses of the logger, and no backup can be made.
Recompute rebuilds the aggregates (15 minutes, 3 hours, day, week, month) of the period from the raw values. No raw value is changed. Use it when charts on long periods do not match the raw values, for example after an import made outside the Correction tab. Leave Address empty to recompute all addresses, then click Recompute.
Import writes the rows of a CSV file into the database. The file needs a header line with these columns:
| Column | Content |
|---|---|
ts |
Time stamp in milliseconds since 1 January 1970 UTC, digits only (for example 1764543600000). |
address |
<gateway_id>|<name>, for example 12|%M100: the id of the gateway, a vertical bar, the name of the address. |
value and/or value_string |
The numeric value and/or the text value. |
Example:
ts,address,value
1764543600000,12|%M100,1520.5
1764544500000,12|%M100,1521.2
"" and line breaks are then allowed inside.date, for example) are ignored.ts and address as an existing row replace it.| make the whole file refused.Choose the file, check the preview, then click Upload & Import (N rows).
Before a manual, function or import correction, the confirmation window offers Download a backup of the current rows first (CSV: import it later to undo), ticked by default. The device then downloads the current rows of the period, in the import format, before writing. To undo the correction, import this file with the Import type: modified and deleted rows are restored.
While a task runs, a bar at the top of the tab shows its progress in percent, with the buttons pause, resume and the trash can (delete the task).
Loggers created with older software versions store local time. When the period crosses a summer/winter time change, the window warns that the rows of the repeated autumn hour overwrite each other: only one value per time stamp can be kept for that hour.
| Message | Cause |
|---|---|
select at least one address to load its data |
Get data without address (manual type). |
the end date must be after the start date |
End before or equal to Start. |
already has one task running |
Another task of this logger is running or paused: wait, resume or delete it. |
CSV must have "ts" and "address" columns / CSV must have "value" or "value_string" column |
Header line missing or misspelled. |
Backup failed (…): nothing was changed |
The backup could not be made (too many rows, for example). |