Every address has two write policies that use the same grammar:
Both are off by default (never). This page explains the values they accept and gives ready-to-use recipes. How the history is stored is explained in Logging and history.
log of the address for Log, field json.remanent for Store value. See Addresses and Peers API: gateways.Store value is offered only by the drivers that support it. When the driver has its own default, the title of the editor shows it: Store value — driver default: ….
The editor offers the following modes:
| Mode | Log | Store value |
|---|---|---|
| never | Not logged. | Not stored. |
| always | Every value received is logged, even when it does not change. | The value is stored on every change. |
| on change (cov) | Logged when the value changes. Optional fields threshold, throttle ms, force after ms, heartbeat ms. | Stored when the value changes. Optional fields threshold, throttle ms, force after ms. |
| interval (ms) / throttle only (ms) | interval (ms): the current value is logged every N milliseconds, even when it does not change. | throttle only (ms): stored at most once every N milliseconds. |
| cron | Logged on a cron schedule. | — |
| expression | Free text, see the grammar below. | Free text, see the grammar below. |
In the millisecond fields, type a number and pick a unit in the suggestions (type 15, then choose 15 minutes = 900000).
| Value | Log | Store value |
|---|---|---|
never (also none, false, empty) |
Not logged. | Not stored. |
always (also true) |
Every value received. | Every change. |
a number of milliseconds, for example 900000 |
Interval: the current value every N ms, aligned on the clock (multiples of N since 1 January 1970 UTC: 900000 gives hh:00, hh:15, hh:30, hh:45). |
Throttle: at most one write every N ms. |
on_change |
Only when the value changes. | Only when the value changes. |
on_change 0.5 |
Only when the value changes by at least 0.5 (numeric threshold). | Same. |
a cron expression, for example 0 0 * * * |
On that schedule. | Not accepted. |
on_change, on_update and on_cov are the same thing, and the prefix on_ is optional (change, update, cov). Without a number after it, any change passes.
A cron expression has five fields: minute (0-59), hour (0-23), day of the month (1-31), month (1-12) and day of the week (0-7, Sunday = 0 or 7). Each field accepts *, lists (1,15), ranges (1-5) and steps (*/15). The schedule follows the local time of the device.
Modifiers follow a base value. Each one takes a number of milliseconds.
| Modifier | Aliases | Applies to | Effect |
|---|---|---|---|
throttle <ms> |
min |
Log, Store value | Minimum time between two writes: changes that come sooner are not written. |
force_after <ms> |
maxdiff, max_stale |
Log, Store value | A change that was held back (below the threshold, or by the throttle) is written anyway once this time has passed. Limits how out of date the recorded value can be. |
heartbeat <ms> |
max |
Log only | Writes the value again when nothing has been written for this time, even without any change. Guarantees at least one point every N ms. |
For Log only, two rules can be combined with or: the value is written when either rule matches. Example: on_change or 3600000 logs every change, and the current value every hour.
Example of the effect of on_change 0.5 throttle 60000 force_after 300000 on a temperature:
heartbeat, or or a cron expression.60000) or on_change throttle 60000, not always.COMMIT_WRITE of the device, 5000 ms by default). Values still waiting are written when the software stops.true, 1, on_update, a number) are read with the same grammar: true and 1 mean always.force_after = forceafter.tick_time exactly like this. It is a Log option for an interval or a cron schedule that dates each value at the tick, rounded to the second: 900000 tick_time.on_change is the threshold; numbers after a modifier are milliseconds.When an expression is refused, the editor shows the reason:
| Message | Meaning |
|---|---|
unknown keyword: … |
The first word is not never, always, on_change (or an alias), a number or a cron expression. |
unknown modifier: … |
A word after the base is not throttle, force_after or heartbeat (or an alias). |
… expects a number (ms) |
A modifier is not followed by a number. |
"heartbeat" is log-only |
heartbeat used in Store value. |
"or" is log-only / invalid "or" sub-rule |
or used in Store value, or one side of the or is invalid. |
"always" takes no modifier here (use <ms>) |
always throttle … in Store value: use a number instead. |
"never" takes no argument |
Extra words after never. |
negative number |
A negative number of milliseconds. |
| Need | Log | Store value |
|---|---|---|
| Energy meter, one value every 15 minutes | 900000 |
— |
| Energy meter, changes of 1 unit, and at least every 15 minutes when it moves less | on_cov 1 force_after 900000 |
— |
| Room temperature | on_cov 0.2 throttle 60000 heartbeat 3600000 |
— |
| Alarm or status bit: every transition | always |
— |
| Daily meter index at local midnight | 0 0 * * * |
— |
| Setpoint or counter kept across restarts | — | on_change throttle 60000 |
For a daily value at local midnight, use the cron expression
0 0 * * *. The interval86400000is aligned on midnight UTC, which is not local midnight.
Every logged or stored value is a write on the storage of the device. On values that change quickly (power, flow, analog inputs):
on_change with a threshold, a throttle, or an interval, to always;60000) rather than always;