iobroker.influxdb 5.4.0 → 5.5.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +11 -5
- package/build/lib/help.js +24 -6
- package/build/lib/help.js.map +1 -1
- package/build/lib/standardHistory.js +303 -0
- package/build/lib/standardHistory.js.map +1 -0
- package/build/main.js +85 -37
- package/build/main.js.map +1 -1
- package/io-package.json +14 -14
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -303,13 +303,17 @@ Most of these values can be pre-defined in the instance settings and are then pr
|
|
|
303
303
|
## Messages for scripts and AI agents
|
|
304
304
|
`sendTo('influxdb.0', 'help', {})` answers `{help, commands}`: a description of all messages and of the measurement layout for AI agents (e.g. ioBroker.pi-agent) and script authors, and the list of all commands with `write: true` for the ones that change something.
|
|
305
305
|
|
|
306
|
+
`getHistory`, `aggregate` and `lastChange` are standard commands of the shared catalog of sendTo commands (family `history`, marked with `standard` in the answer of `help`), the same in history, sql, influxdb and recorder:
|
|
307
|
+
- `aggregate {id, start, end?, fn, value?}` answers one number for a period, `{value, ts?, unit?, count}`. `fn`: `min`, `max`, `avg`, `sum`, `count` (with `value`: how often the state became it), `delta` (how much a counter rose, resets included), `first`, `last`, `integral` (value × hours, W gives Wh), `duration` (with `value`: seconds the state had it).
|
|
308
|
+
- `lastChange {id, value?, before?}` answers when the state last changed (to `value`): `{ts, val}`.
|
|
309
|
+
|
|
306
310
|
## Access values from Javascript adapter
|
|
307
311
|
The sorted values can be accessed from Javascript adapter.
|
|
308
312
|
|
|
309
|
-
* Get 50 last stored
|
|
313
|
+
* Get the 50 last stored values of "system.adapter.admin.0.memRss" (InfluxDB keeps one measurement per state, so `id: '*'` for all IDs is not supported and answers an error)
|
|
310
314
|
```javascript
|
|
311
315
|
sendTo('influxdb.0', 'getHistory', {
|
|
312
|
-
id: '
|
|
316
|
+
id: 'system.adapter.admin.0.memRss',
|
|
313
317
|
options: {
|
|
314
318
|
end: Date.now(),
|
|
315
319
|
count: 50,
|
|
@@ -732,6 +736,11 @@ sendTo('influxdb.0', 'cleanupOrphaned', {
|
|
|
732
736
|
Placeholder for the next version (at the beginning of the line):
|
|
733
737
|
### **WORK IN PROGRESS**
|
|
734
738
|
-->
|
|
739
|
+
### 5.5.0 (2026-11-23)
|
|
740
|
+
* (GermanBluefox) Added the standard commands of the shared catalog: history.aggregate (one number for a period: min, max, avg, sum, count, delta, first, last, integral, duration) and history.lastChange; getHistory is marked as history.getHistory
|
|
741
|
+
* (GermanBluefox) Fixed: `getHistory` with `id: '*'` (or without ID) answers an error instead of an empty result. InfluxDB keeps one measurement per state and cannot read all states at once; the example in this README that used `'*'` reads one state now
|
|
742
|
+
* (GermanBluefox) Fixed: `getHistory` with an aggregate (e.g. average) and without `start` answers instead of failing with "Invalid time value" (the step was NaN). Like the sql and history adapters, it takes the newest `count` values and builds the intervals from them. An unparsable `start` or `end` is refused with "is not a valid date", a time stamp as text ("1700000000000") is accepted
|
|
743
|
+
|
|
735
744
|
### 5.4.0 (2026-11-19)
|
|
736
745
|
* (GermanBluefox) Fixed: `delete` / `deleteRange` without a valid `ts` or range no longer deletes all values of the state. A single `{id, state: {start, end}}`, a state without `ts` or with `ts: 0` deleted everything (InfluxDB 1.x since 2000, 2.x since 1970, 3.x the whole table), an unparsable `start` everything up to `end`. Such a message is refused now with an error and nothing is deleted; `{id, state: {start, end}}` and `{id, start, end}` delete the range, `ts: 0` the value at 0
|
|
737
746
|
* (GermanBluefox) Added the message "help": a description of all messages for AI agents (e.g. pi-agent), and `common.supportedMessages.help`
|
|
@@ -750,9 +759,6 @@ sendTo('influxdb.0', 'cleanupOrphaned', {
|
|
|
750
759
|
### 5.2.2 (2026-10-27)
|
|
751
760
|
* (GermanBluefox) The cleanup dialog of the statistics tab shows the oldest and the newest value of each datapoint and can preselect only datapoints whose last value is older than a given number of days, so measurements that scripts still write to stay untouched
|
|
752
761
|
|
|
753
|
-
### 5.2.0 (2026-10-24)
|
|
754
|
-
* (GermanBluefox) The cleanup dialog of the statistics tab has checkboxes, so only the selected datapoints are deleted (#565)
|
|
755
|
-
|
|
756
762
|
[Older changelogs can be found there](CHANGELOG_OLD.md)
|
|
757
763
|
|
|
758
764
|
## License
|
package/build/lib/help.js
CHANGED
|
@@ -5,10 +5,15 @@
|
|
|
5
5
|
*/
|
|
6
6
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
7
7
|
exports.HELP = exports.COMMANDS = void 0;
|
|
8
|
-
/**
|
|
8
|
+
/**
|
|
9
|
+
* Every command `processMessage` answers; `write` = it changes data, settings or the instance; `standard` = it follows
|
|
10
|
+
* the shared catalog of sendTo commands (HELP.md of ioBroker.assistant), the same in history, sql, influxdb and recorder
|
|
11
|
+
*/
|
|
9
12
|
exports.COMMANDS = [
|
|
10
13
|
{ command: 'help', write: false },
|
|
11
|
-
{ command: 'getHistory', write: false },
|
|
14
|
+
{ command: 'getHistory', write: false, standard: 'history.getHistory' },
|
|
15
|
+
{ command: 'aggregate', write: false, standard: 'history.aggregate' },
|
|
16
|
+
{ command: 'lastChange', write: false, standard: 'history.lastChange' },
|
|
12
17
|
{ command: 'getEnabledDPs', write: false },
|
|
13
18
|
{ command: 'getDatapoints', write: false },
|
|
14
19
|
{ command: 'getRawEntries', write: false },
|
|
@@ -49,15 +54,17 @@ Layout (for a query):
|
|
|
49
54
|
- Flux (2.x): from(bucket: "iobroker") |> range(start: -1h) |> filter(fn: (r) => r._measurement ==
|
|
50
55
|
"hm-rpc.0.ABC.1.TEMPERATURE" and r._field == "value"); the value is in _value.
|
|
51
56
|
|
|
52
|
-
Commands (sendTo influxdb.0):
|
|
57
|
+
Commands (sendTo influxdb.0): getHistory, aggregate and lastChange are standard commands of the shared catalog of
|
|
58
|
+
ioBroker (family history): the same names, parameters and answers in history, sql, influxdb and recorder.
|
|
53
59
|
- getHistory {id, options: {start?, end?, aggregate?, count?, step?, ...}}: the course of one state:
|
|
54
60
|
{result: [{ts, val, ack?, from?, q?, id?}], step, sessionId}, on an error {result: [], error}. options is
|
|
55
|
-
required (may be {}).
|
|
61
|
+
required (may be {}). id: one state; "*" (all states) is refused with an error.
|
|
56
62
|
aggregate: average (default), min, max, minmax (min and max of each interval), total, count, percentile
|
|
57
63
|
{percentile 0-100, default 50}, quantile {quantile 0-1, default 0.5}, integral {integralUnit in s, default 60,
|
|
58
64
|
3600 gives Wh from W; integralInterpolation none (default) | linear}: one value per interval, mostly computed
|
|
59
65
|
by InfluxDB; none or onchange: the stored values (with their ack, q and from).
|
|
60
|
-
start:
|
|
66
|
+
start: without it the newest count values; with an aggregate and without step, the adapter builds the
|
|
67
|
+
intervals from them (as sql and history do).
|
|
61
68
|
end: default now + 5000 s. count: the number of intervals (default 500); with none/onchange the number of
|
|
62
69
|
values (default limit on 1.x and 3.x, 500 on 2.x). step: the interval in ms instead of count.
|
|
63
70
|
intervalBorders: [ms, ...] ascending borders of the intervals (e.g. local days), replaces start, end and step.
|
|
@@ -66,6 +73,15 @@ Commands (sendTo influxdb.0):
|
|
|
66
73
|
round: digits after the decimal point (default the setting of the instance). removeBorderValues: true drops
|
|
67
74
|
the values before start and after end that are added for charts. sessionId: returned as it is. ignoreNull,
|
|
68
75
|
ack, from and q are not read: a null is replaced by the value before.
|
|
76
|
+
- aggregate {id, start, end?, fn, value?}: one number for a period: {value, ts?, unit?, count}. fn: min, max (ts =
|
|
77
|
+
when), avg (the mean of the stored values), sum, count (with value: how often the state became it, e.g. true),
|
|
78
|
+
delta (how much a counter rose, resets included), first, last, integral (value × hours: W gives Wh), duration
|
|
79
|
+
(with value: how many seconds the state had it). end: default now. count: the stored values in the period, at
|
|
80
|
+
most 50000 (else reason TOO_MANY_VALUES). Errors: {error, reason} (reason BAD_REQUEST for a wrong parameter).
|
|
81
|
+
Computed from the values of getHistory (aggregate none).
|
|
82
|
+
- lastChange {id, value?, before?}: when the state last changed (to value): {ts, val}; before: only the values
|
|
83
|
+
before this time. A value logged again does not count as a change. Reason NOT_FOUND if it never had the value;
|
|
84
|
+
only the newest 10000 stored values are searched: limited true = it had it already then.
|
|
69
85
|
- getEnabledDPs {}: the states this instance logs: {[id]: their settings (enabled, changesOnly, debounceTime,
|
|
70
86
|
blockTime, changesMinDelta, changesRelogInterval, ignoreZero, ignoreBelowNumber, ignoreAboveNumber, round,
|
|
71
87
|
storageType, aliasId, customTags, ...)}.
|
|
@@ -118,7 +134,9 @@ How to talk to the user:
|
|
|
118
134
|
with their unit.
|
|
119
135
|
- A state has a history only if it is or was logged (getEnabledDPs, getDatapoints). For a longer period request
|
|
120
136
|
one value per interval (e.g. aggregate average with start and count 24 to 200) instead of every stored value.
|
|
121
|
-
|
|
137
|
+
For one number of a period (the highest value, how often, how long, how much) use the command aggregate, for
|
|
138
|
+
"when was it last ..." lastChange. Prefer these and getHistory; write a query only for what they cannot answer,
|
|
139
|
+
and read dbversion and dbname first.
|
|
122
140
|
- Send only reading statements with query (InfluxQL SELECT or SHOW, Flux without to() or another output). Any
|
|
123
141
|
other statement only on the user's explicit request.
|
|
124
142
|
- query (other than reading), delete, deleteRange, deleteAll, update, storeState, cleanupOrphaned, destroy,
|
package/build/lib/help.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"help.js","sourceRoot":"","sources":["../../src/lib/help.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAEH
|
|
1
|
+
{"version":3,"file":"help.js","sourceRoot":"","sources":["../../src/lib/help.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAEH;;;GAGG;AACU,QAAA,QAAQ,GAA6D;IAC9E,EAAE,OAAO,EAAE,MAAM,EAAE,KAAK,EAAE,KAAK,EAAE;IACjC,EAAE,OAAO,EAAE,YAAY,EAAE,KAAK,EAAE,KAAK,EAAE,QAAQ,EAAE,oBAAoB,EAAE;IACvE,EAAE,OAAO,EAAE,WAAW,EAAE,KAAK,EAAE,KAAK,EAAE,QAAQ,EAAE,mBAAmB,EAAE;IACrE,EAAE,OAAO,EAAE,YAAY,EAAE,KA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EAAE,SAAS,EAAE,KAAK,EAAE,IAAI,EAAE;IACnC,EAAE,OAAO,EAAE,cAAc,EAAE,KAAK,EAAE,IAAI,EAAE;CAC3C,CAAC;AAEW,QAAA,IAAI,GAAG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;4DA2GwC,CAAC"}
|
|
@@ -0,0 +1,303 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* The commands `aggregate` and `lastChange` of the shared catalog of sendTo commands (family "history", see HELP.md
|
|
4
|
+
* of ioBroker.assistant): one number for a period, and the time of the last change of a state. Both are computed
|
|
5
|
+
* from the stored values as the adapter reads them anyway (for `getHistory` or `getRawEntries`), so they need no
|
|
6
|
+
* database query of their own.
|
|
7
|
+
*
|
|
8
|
+
* The same file is used by ioBroker.history, ioBroker.sql, ioBroker.influxdb and ioBroker.recorder: keep it identical.
|
|
9
|
+
*/
|
|
10
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
11
|
+
exports.MAX_SCAN = exports.MAX_VALUES = exports.AGGREGATE_FUNCTIONS = void 0;
|
|
12
|
+
exports.aggregate = aggregate;
|
|
13
|
+
exports.lastChange = lastChange;
|
|
14
|
+
exports.readThroughGetHistory = readThroughGetHistory;
|
|
15
|
+
/** The values of `fn` of `aggregate` */
|
|
16
|
+
exports.AGGREGATE_FUNCTIONS = [
|
|
17
|
+
'min',
|
|
18
|
+
'max',
|
|
19
|
+
'avg',
|
|
20
|
+
'sum',
|
|
21
|
+
'count',
|
|
22
|
+
'delta',
|
|
23
|
+
'first',
|
|
24
|
+
'last',
|
|
25
|
+
'integral',
|
|
26
|
+
'duration',
|
|
27
|
+
];
|
|
28
|
+
/** `aggregate` reads at most so many values: a longer period gives the error TOO_MANY_VALUES */
|
|
29
|
+
exports.MAX_VALUES = 50_000;
|
|
30
|
+
/** `lastChange` reads the values backwards in pages of this size ... */
|
|
31
|
+
const PAGE = 1_000;
|
|
32
|
+
/** ... and stops after so many values */
|
|
33
|
+
exports.MAX_SCAN = 10_000;
|
|
34
|
+
const HOUR = 3_600_000;
|
|
35
|
+
function fail(error, reason) {
|
|
36
|
+
return { error, reason };
|
|
37
|
+
}
|
|
38
|
+
/** ms since 1970 from a number, a numeric text or a date text (a text without a zone is local time) */
|
|
39
|
+
function toTimestamp(value) {
|
|
40
|
+
if (typeof value === 'number') {
|
|
41
|
+
return Number.isFinite(value) ? value : undefined;
|
|
42
|
+
}
|
|
43
|
+
if (typeof value !== 'string' || !value.trim()) {
|
|
44
|
+
return undefined;
|
|
45
|
+
}
|
|
46
|
+
const text = value.trim();
|
|
47
|
+
if (/^\d+$/.test(text)) {
|
|
48
|
+
return parseInt(text, 10);
|
|
49
|
+
}
|
|
50
|
+
// Date reads a date without a time as UTC, the catalog means the local midnight
|
|
51
|
+
const ts = new Date(/^\d{4}-\d{2}-\d{2}$/.test(text) ? `${text}T00:00` : text).getTime();
|
|
52
|
+
return Number.isFinite(ts) ? ts : undefined;
|
|
53
|
+
}
|
|
54
|
+
function isGiven(value) {
|
|
55
|
+
return value !== undefined && value !== null && value !== '';
|
|
56
|
+
}
|
|
57
|
+
/** A value as number (true = 1, false = 0, a numeric text), null if it is none */
|
|
58
|
+
function toNumber(val) {
|
|
59
|
+
if (typeof val === 'boolean') {
|
|
60
|
+
return val ? 1 : 0;
|
|
61
|
+
}
|
|
62
|
+
const n = typeof val === 'number' ? val : typeof val === 'string' && val.trim() ? Number(val) : NaN;
|
|
63
|
+
return Number.isFinite(n) ? n : null;
|
|
64
|
+
}
|
|
65
|
+
/** A value to compare: true, 1 and "true" are the same, as are 5 and "5"; texts without case */
|
|
66
|
+
function comparable(val) {
|
|
67
|
+
if (typeof val === 'boolean') {
|
|
68
|
+
return val ? 1 : 0;
|
|
69
|
+
}
|
|
70
|
+
if (typeof val === 'string') {
|
|
71
|
+
const text = val.trim().toLowerCase();
|
|
72
|
+
if (text === 'true' || text === 'false') {
|
|
73
|
+
return text === 'true' ? 1 : 0;
|
|
74
|
+
}
|
|
75
|
+
return text && Number.isFinite(Number(text)) ? Number(text) : text;
|
|
76
|
+
}
|
|
77
|
+
return val;
|
|
78
|
+
}
|
|
79
|
+
function same(a, b) {
|
|
80
|
+
return comparable(a) === comparable(b);
|
|
81
|
+
}
|
|
82
|
+
function round(value) {
|
|
83
|
+
return Math.round(value * 1000) / 1000;
|
|
84
|
+
}
|
|
85
|
+
/** The values in [start, end] without the gaps (null), sorted by ts */
|
|
86
|
+
function inRange(values, start, end) {
|
|
87
|
+
return values
|
|
88
|
+
.filter(v => v && v.ts >= start && v.ts <= end && v.val !== null && v.val !== undefined)
|
|
89
|
+
.sort((a, b) => a.ts - b.ts);
|
|
90
|
+
}
|
|
91
|
+
function errorText(e) {
|
|
92
|
+
return e instanceof Error ? e.message : String(e);
|
|
93
|
+
}
|
|
94
|
+
/** The value of one function; `before` = the last value before start, `end` = the end, but not after now */
|
|
95
|
+
function compute(fn, values, before, wanted, start, end) {
|
|
96
|
+
const numbers = values
|
|
97
|
+
.map(v => ({ ts: v.ts, n: toNumber(v.val) }))
|
|
98
|
+
.filter((v) => v.n !== null);
|
|
99
|
+
const sum = numbers.reduce((total, v) => total + v.n, 0);
|
|
100
|
+
switch (fn) {
|
|
101
|
+
case 'first':
|
|
102
|
+
case 'last': {
|
|
103
|
+
const v = fn === 'first' ? values[0] : values[values.length - 1];
|
|
104
|
+
return v ? { value: v.val, ts: v.ts } : { value: null };
|
|
105
|
+
}
|
|
106
|
+
case 'min':
|
|
107
|
+
case 'max': {
|
|
108
|
+
let best;
|
|
109
|
+
for (const v of numbers) {
|
|
110
|
+
if (!best || (fn === 'min' ? v.n < best.n : v.n > best.n)) {
|
|
111
|
+
best = v;
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
return best ? { value: best.n, ts: best.ts } : { value: null };
|
|
115
|
+
}
|
|
116
|
+
case 'avg':
|
|
117
|
+
return { value: numbers.length ? round(sum / numbers.length) : null };
|
|
118
|
+
case 'sum':
|
|
119
|
+
return { value: round(sum) };
|
|
120
|
+
case 'count': {
|
|
121
|
+
if (!isGiven(wanted)) {
|
|
122
|
+
return { value: values.length };
|
|
123
|
+
}
|
|
124
|
+
// how often the state became the value: the values before it do not count again
|
|
125
|
+
let count = 0;
|
|
126
|
+
let previous = before?.val;
|
|
127
|
+
for (const v of values) {
|
|
128
|
+
if (same(v.val, wanted) && (previous === undefined || !same(previous, wanted))) {
|
|
129
|
+
count++;
|
|
130
|
+
}
|
|
131
|
+
previous = v.val;
|
|
132
|
+
}
|
|
133
|
+
return { value: count };
|
|
134
|
+
}
|
|
135
|
+
case 'delta': {
|
|
136
|
+
// how much a counter rose: a value below the one before is a reset, it rose from 0 to this value
|
|
137
|
+
const series = (before ? [before, ...values] : values)
|
|
138
|
+
.map(v => toNumber(v.val))
|
|
139
|
+
.filter((n) => n !== null);
|
|
140
|
+
let rise = 0;
|
|
141
|
+
for (let i = 1; i < series.length; i++) {
|
|
142
|
+
rise += series[i] >= series[i - 1] ? series[i] - series[i - 1] : series[i];
|
|
143
|
+
}
|
|
144
|
+
return { value: series.length ? round(rise) : null };
|
|
145
|
+
}
|
|
146
|
+
default: {
|
|
147
|
+
// integral and duration: every value holds until the next one, the last one until the end
|
|
148
|
+
const line = before ? [{ ts: start, val: before.val }, ...values] : values;
|
|
149
|
+
let total = 0;
|
|
150
|
+
for (let i = 0; i < line.length; i++) {
|
|
151
|
+
const from = Math.max(line[i].ts, start);
|
|
152
|
+
const to = Math.min(i + 1 < line.length ? line[i + 1].ts : end, end);
|
|
153
|
+
if (to > from) {
|
|
154
|
+
if (fn === 'duration') {
|
|
155
|
+
total += same(line[i].val, wanted) ? to - from : 0;
|
|
156
|
+
}
|
|
157
|
+
else {
|
|
158
|
+
total += (toNumber(line[i].val) ?? 0) * (to - from);
|
|
159
|
+
}
|
|
160
|
+
}
|
|
161
|
+
}
|
|
162
|
+
if (!line.length) {
|
|
163
|
+
return { value: null };
|
|
164
|
+
}
|
|
165
|
+
return { value: fn === 'duration' ? Math.round(total / 1000) : round(total / HOUR) };
|
|
166
|
+
}
|
|
167
|
+
}
|
|
168
|
+
}
|
|
169
|
+
/**
|
|
170
|
+
* `aggregate {id, start, end?, fn, value?}`: one number for a period, `{value, ts?, unit?, count}`.
|
|
171
|
+
* fn: min, max (ts = when), avg, sum, count (with value: how often the state became it), delta (how much a counter
|
|
172
|
+
* rose, resets included), first, last (ts = when), integral (value × hours, e.g. W → Wh), duration (with value:
|
|
173
|
+
* seconds the state had it). count = the number of stored values in the period.
|
|
174
|
+
*
|
|
175
|
+
* @param message the message of sendTo
|
|
176
|
+
* @param source the stored values
|
|
177
|
+
* @param now the current time
|
|
178
|
+
*/
|
|
179
|
+
async function aggregate(message, source, now = Date.now()) {
|
|
180
|
+
const m = (message && typeof message === 'object' ? message : {});
|
|
181
|
+
const id = m.id;
|
|
182
|
+
const fn = m.fn;
|
|
183
|
+
if (typeof id !== 'string' || !id) {
|
|
184
|
+
return fail('id is missing', 'BAD_REQUEST');
|
|
185
|
+
}
|
|
186
|
+
if (typeof fn !== 'string' || !exports.AGGREGATE_FUNCTIONS.includes(fn)) {
|
|
187
|
+
return fail(`fn must be one of ${exports.AGGREGATE_FUNCTIONS.join(', ')}`, 'BAD_REQUEST');
|
|
188
|
+
}
|
|
189
|
+
const start = toTimestamp(m.start);
|
|
190
|
+
const end = isGiven(m.end) ? toTimestamp(m.end) : now;
|
|
191
|
+
if (start === undefined || end === undefined || start > end) {
|
|
192
|
+
return fail('start and end must be times (ms or a date text) and start not after end', 'BAD_REQUEST');
|
|
193
|
+
}
|
|
194
|
+
if (fn === 'duration' && !isGiven(m.value)) {
|
|
195
|
+
return fail('fn duration needs the value', 'BAD_REQUEST');
|
|
196
|
+
}
|
|
197
|
+
try {
|
|
198
|
+
const read = await source.read(id, { start, end, count: exports.MAX_VALUES + 1 });
|
|
199
|
+
if (read.length > exports.MAX_VALUES) {
|
|
200
|
+
return fail(`More than ${exports.MAX_VALUES} stored values in this period: ask for a shorter one`, 'TOO_MANY_VALUES');
|
|
201
|
+
}
|
|
202
|
+
const values = inRange(read, start, end);
|
|
203
|
+
// what the state was at start, for the changes, the counter and the time line
|
|
204
|
+
let before;
|
|
205
|
+
if ((fn === 'count' && isGiven(m.value)) || fn === 'delta' || fn === 'integral' || fn === 'duration') {
|
|
206
|
+
before = inRange(await source.read(id, { end: start - 1, count: 10 }), -Infinity, start - 1).pop();
|
|
207
|
+
}
|
|
208
|
+
const result = compute(fn, values, before, m.value, start, Math.min(end, now));
|
|
209
|
+
const answer = { value: result.value, count: values.length };
|
|
210
|
+
if (result.ts !== undefined) {
|
|
211
|
+
answer.ts = result.ts;
|
|
212
|
+
}
|
|
213
|
+
const unit = fn === 'duration' ? 's' : fn === 'count' ? undefined : await source.unit?.(id);
|
|
214
|
+
if (unit) {
|
|
215
|
+
answer.unit = fn === 'integral' ? `${unit}h` : unit;
|
|
216
|
+
}
|
|
217
|
+
return answer;
|
|
218
|
+
}
|
|
219
|
+
catch (e) {
|
|
220
|
+
return { error: errorText(e) };
|
|
221
|
+
}
|
|
222
|
+
}
|
|
223
|
+
/**
|
|
224
|
+
* `lastChange {id, value?, before?}`: when the state last changed (to value), `{ts, val}`: the first of the newest
|
|
225
|
+
* stored values that are the same as the newest one (or as value). before: only the values before this time.
|
|
226
|
+
* At most MAX_SCAN values are read: if the state had the value longer, ts is the oldest one read and limited true.
|
|
227
|
+
*
|
|
228
|
+
* @param message the message of sendTo
|
|
229
|
+
* @param source the stored values
|
|
230
|
+
* @param now the current time
|
|
231
|
+
*/
|
|
232
|
+
async function lastChange(message, source, now = Date.now()) {
|
|
233
|
+
const m = (message && typeof message === 'object' ? message : {});
|
|
234
|
+
const id = m.id;
|
|
235
|
+
if (typeof id !== 'string' || !id) {
|
|
236
|
+
return fail('id is missing', 'BAD_REQUEST');
|
|
237
|
+
}
|
|
238
|
+
let end = isGiven(m.before) ? toTimestamp(m.before) : now;
|
|
239
|
+
if (end === undefined) {
|
|
240
|
+
return fail('before must be a time (ms or a date text)', 'BAD_REQUEST');
|
|
241
|
+
}
|
|
242
|
+
let wanted = m.value;
|
|
243
|
+
// the oldest value read of the newest run of values that are the same as the wanted one
|
|
244
|
+
let run;
|
|
245
|
+
try {
|
|
246
|
+
for (let scanned = 0; scanned < exports.MAX_SCAN;) {
|
|
247
|
+
const page = await source.read(id, { end, count: PAGE });
|
|
248
|
+
const values = inRange(page, -Infinity, end);
|
|
249
|
+
for (let i = values.length - 1; i >= 0; i--) {
|
|
250
|
+
if (!isGiven(wanted)) {
|
|
251
|
+
wanted = values[i].val;
|
|
252
|
+
}
|
|
253
|
+
if (same(values[i].val, wanted)) {
|
|
254
|
+
run = values[i];
|
|
255
|
+
}
|
|
256
|
+
else if (run) {
|
|
257
|
+
return { ts: run.ts, val: run.val };
|
|
258
|
+
}
|
|
259
|
+
}
|
|
260
|
+
if (page.length < PAGE) {
|
|
261
|
+
// no older values: the state has had it since the first stored value
|
|
262
|
+
return run ? { ts: run.ts, val: run.val } : fail(`${id} has no such stored value`, 'NOT_FOUND');
|
|
263
|
+
}
|
|
264
|
+
scanned += page.length;
|
|
265
|
+
end = Math.min(...page.map(v => v.ts)) - 1;
|
|
266
|
+
}
|
|
267
|
+
}
|
|
268
|
+
catch (e) {
|
|
269
|
+
return { error: errorText(e) };
|
|
270
|
+
}
|
|
271
|
+
return run
|
|
272
|
+
? { ts: run.ts, val: run.val, limited: true }
|
|
273
|
+
: fail(`${id} has no such value in its newest ${exports.MAX_SCAN} stored values`, 'NOT_FOUND');
|
|
274
|
+
}
|
|
275
|
+
/**
|
|
276
|
+
* The `read` of a `ValueSource` through the adapter's own `getHistory` (aggregate none, without border values).
|
|
277
|
+
*
|
|
278
|
+
* @param ask sends `getHistory` with this message to the own instance and resolves with the answer
|
|
279
|
+
*/
|
|
280
|
+
function readThroughGetHistory(ask) {
|
|
281
|
+
return async (id, query) => {
|
|
282
|
+
const answer = (await ask({
|
|
283
|
+
id,
|
|
284
|
+
options: {
|
|
285
|
+
start: query.start,
|
|
286
|
+
end: query.end,
|
|
287
|
+
count: query.count,
|
|
288
|
+
limit: query.count,
|
|
289
|
+
aggregate: 'none',
|
|
290
|
+
returnNewestEntries: query.start === undefined,
|
|
291
|
+
removeBorderValues: true,
|
|
292
|
+
},
|
|
293
|
+
}));
|
|
294
|
+
if (answer instanceof Error) {
|
|
295
|
+
throw answer;
|
|
296
|
+
}
|
|
297
|
+
if (answer?.error) {
|
|
298
|
+
throw new Error(typeof answer.error === 'string' ? answer.error : JSON.stringify(answer.error));
|
|
299
|
+
}
|
|
300
|
+
return Array.isArray(answer?.result) ? answer.result : [];
|
|
301
|
+
};
|
|
302
|
+
}
|
|
303
|
+
//# sourceMappingURL=standardHistory.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"standardHistory.js","sourceRoot":"","sources":["../../src/lib/standardHistory.ts"],"names":[],"mappings":";AAAA;;;;;;;GAOG;;;AA4MH,8BAkDC;AAWD,gCA4CC;AAOD,sDAwBC;AA9TD,wCAAwC;AAC3B,QAAA,mBAAmB,GAAG;IAC/B,KAAK;IACL,KAAK;IACL,KAAK;IACL,KAAK;IACL,OAAO;IACP,OAAO;IACP,OAAO;IACP,MAAM;IACN,UAAU;IACV,UAAU;CACb,CAAC;AAEF,gGAAgG;AACnF,QAAA,UAAU,GAAG,MAAM,CAAC;AACjC,wEAAwE;AACxE,MAAM,IAAI,GAAG,KAAK,CAAC;AACnB,yCAAyC;AAC5B,QAAA,QAAQ,GAAG,MAAM,CAAC;AAC/B,MAAM,IAAI,GAAG,SAAS,CAAC;AAEvB,SAAS,IAAI,CAAC,KAAa,EAAE,MAAc;IACvC,OAAO,EAAE,KAAK,EAAE,MAAM,EAAE,CAAC;AAC7B,CAAC;AAED,uGAAuG;AACvG,SAAS,WAAW,CAAC,KAAc;IAC/B,IAAI,OAAO,KAAK,KAAK,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