iobroker.sql 2.0.2 → 2.1.2

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 CHANGED
@@ -1,829 +1,850 @@
1
- ![Logo](admin/sql.png)
2
- # ioBroker.sql
3
-
4
- ![Number of Installations](http://iobroker.live/badges/sql-installed.svg) ![Number of Installations](http://iobroker.live/badges/sql-stable.svg) [![NPM version](http://img.shields.io/npm/v/iobroker.sql.svg)](https://www.npmjs.com/package/iobroker.sql)
5
- [![Downloads](https://img.shields.io/npm/dm/iobroker.sql.svg)](https://www.npmjs.com/package/iobroker.sql)
6
- [![Tests](https://travis-ci.org/ioBroker/ioBroker.sql.svg?branch=master)](https://travis-ci.org/ioBroker/ioBroker.sql)
7
-
8
- [![NPM](https://nodei.co/npm/iobroker.sql.png?downloads=true)](https://nodei.co/npm/iobroker.sql/)
9
-
10
- This adapter saves state history into SQL DB.
11
-
12
- Supports PostgreSQL, mysql, Microsoft SQL Server and sqlite.
13
- You can leave port 0 if default port is desired.
14
-
15
- **This adapter uses Sentry libraries to automatically report exceptions and code errors to the developers.** For more details and for information how to disable the error reporting see [Sentry-Plugin Documentation](https://github.com/ioBroker/plugin-sentry#plugin-sentry)! Sentry reporting is used starting with js-controller 3.0.
16
-
17
- ## Settings
18
-
19
- ## Connection Settings
20
- - **DB Type**: Type of the SQL DB: MySQL, PostgreSQL, MS-SQL or SQLite3
21
- - **Host**: IP address or host name with SQL Server
22
- - **Port**: Port of SQL Server (leave blank if not sure)
23
- - **Database name**: Database name. Default iobroker
24
- - **User**: Username for SQL. Must exist in the DB.
25
- - **Password**: Password for SQL.
26
- - **Password confirm**: Just repeat password here.
27
- - **Encrypt**: Some DBs support encryption.
28
- - **Round real to**: Number of digits after the comma.
29
- - **Allow parallel requests**: Allow simultaneous SQL requests to DB.
30
- - **Do not create database**: Activate this option if database already created (e.g. by administrator) and the ioBroker-user does not have enough rights to create a DB.
31
-
32
- ## Default Settings
33
- - **Debounce Time** - Protection against unstable values to make sure that only stable values are logged when the value did not change in the defined amount of Milliseconds. ATTENTION: If values change more often then this setting effectively no value will be logged (because any value is unstable)
34
- - **Blocktime** - Defines for how long after storing the last value no further value is stored. When the given time in Milliseconds is over then the next value that fulfills all other checks is logged.
35
- - **Record changes only** - This function make sure that only changed values are logged if they fulfill other checks (see below). Same values will not be logged.
36
- - **still record the same values (seconds)** - When using "Record changes only" you can set a time interval in seconds here after which also unchanged values will be re-logged into the DB. You can detect the values re-logged by the adapter with the "from" field.
37
- - **Minimum difference from last value** - When using "Record changes only" you can define the required minimum difference between the new value and the last value. If this is not reached the value is not recorded.
38
- - **ignore 0 or null values (==0)** - You can define if 0 or null values should be ignored.
39
- - **ignore values below zero (<0)** - You can define if values below zero should be ignored.
40
- - **Disable charting optimized logging of skipped values** - By default the adapter tries to record the values for optimized charting. This can mean that additional values (that e.g. not fulfilled all checks above) are logged automatically. If this is not wanted, you can disable this feature.
41
- - **Alias-ID** - You can define an alias for the ID. This is useful if you have changed a device and want to have continuous data logging. Please consider switching to real alias States in teh future!
42
- - **Storage retention** - How many values in the past will be stored on disk. Data are deleted when the time is reached as soon as new data should be stored for a datapoint.
43
- - **Maximal number of stored in RAM values** - Define how many number of values will be hold in RAM before persisting them on disk. You can control how much I/O is done.
44
- - **Enable enhanced debug logs for the datapoint** - If you want to see more detailed logs for this datapoint, you can enable this option. You still need to enable "debug" loglevel for these additional values to be visible! This helps in debugging issues or understanding why the adapter is logging a value (or not).
45
-
46
- Most of these values can be pre-defined in the instance settings and are then pre-filled or used for the datapoint.
47
-
48
- ## Database installation tips
49
-
50
- ### MS-SQL:
51
- Use ```localhost\instance``` for the host and check TCP/IP connections enabled.
52
- https://msdn.microsoft.com/en-us/library/bb909712(v=vs.90).aspx
53
-
54
- ### SQLite:
55
- is "file"-DB and cannot manage too many events. If you have a big amount of data use the real DB, like PostgreSQL and co.
56
-
57
- SQLite DB must not be installed extra. It is just a file on disk, but to install it you require build tools on your system. For linux, just write:
58
-
59
- ```
60
- sudo apt-get install build-essential
61
- ```
62
-
63
- For windows:
64
-
65
- ```
66
- c:\>npm install --global --production windows-build-tools
67
- ```
68
-
69
- and then reinstall the adapter, e.g:
70
-
71
- ```
72
- cd /opt/iobroker
73
- iobroker stop sql
74
- npm install iobroker.sql --production
75
- iobroker start sql
76
- ```
77
-
78
- ### MySQL:
79
- You can install mysql on linux systems as following:
80
-
81
- ```
82
- apt-get install mysql-server mysql-client
83
-
84
- mysql -u root -p
85
-
86
- CREATE USER 'iobroker'@'%' IDENTIFIED BY 'iobroker';
87
- GRANT ALL PRIVILEGES ON * . * TO 'iobroker'@'%';
88
- FLUSH PRIVILEGES;
89
- ```
90
-
91
- If required edit */etc/mysql/my.cnf* to set bind to IP-Address for remote connect.
92
-
93
- **Warning**: iobroker user is "admin". If required give limited rights to iobroker user.
94
-
95
- On the "windows" it can be easily installed via installer: https://dev.mysql.com/downloads/installer/.
96
-
97
- Pay attention for authentication method. The new encryption algorithm in MySQL 8.0 is not yet supported by `node.js` and you must select legacy authentication method.
98
-
99
- ![Windows](img/WindowsMySQLinstaller.png)
100
-
101
- ## Structure of the DBs
102
- Default Database name is "iobroker", but it can be changed in the configuration.
103
- ### Sources
104
- This table is a list of adapter's instances, that wrote the entries. (state.from)
105
-
106
- | DB | Name in query |
107
- |------------|----------------------|
108
- | MS-SQL | iobroker.dbo.sources |
109
- | MySQL | iobroker.sources |
110
- | PostgreSQL | sources |
111
- | SQLite | sources |
112
-
113
- Structure:
114
-
115
- | Field | Type | Description |
116
- |-------|--------------------------------------------|-------------------------------------------|
117
- | id | INTEGER NOT NULL PRIMARY KEY IDENTITY(1,1) | unique ID |
118
- | name | varchar(255) / TEXT | instance of adapter, that wrote the entry |
119
-
120
- *Note:* MS-SQL uses varchar(255), and others use TEXT
121
-
122
- ### Data points
123
- This table is a list of data points. (IDs)
124
-
125
- | DB | Name in query |
126
- |------------|-------------------------|
127
- | MS-SQL | iobroker.dbo.datapoints |
128
- | MySQL | iobroker.datapoints |
129
- | PostgreSQL | datapoints |
130
- | SQLite | datapoints |
131
-
132
- Structure:
133
-
134
- | Field | Type | Description |
135
- |-------|--------------------------------------------|-------------------------------------------------|
136
- | id | INTEGER NOT NULL PRIMARY KEY IDENTITY(1,1) | unique ID |
137
- | name | varchar(255) / TEXT | ID of variable, e.g. hm-rpc.0.JEQ283747.1.STATE |
138
- | type | INTEGER | 0 - number, 1 - string, 2 - boolean |
139
-
140
- *Note:* MS-SQL uses varchar(255), and others use TEXT
141
-
142
- ### Numbers
143
- Values for states with type "number". **ts** means "time series".
144
-
145
- | DB | Name in query |
146
- |------------|-------------------------|
147
- | MS-SQL | iobroker.dbo.ts_number |
148
- | MySQL | iobroker.ts_number |
149
- | PostgreSQL | ts_number |
150
- | SQLite | ts_number |
151
-
152
- Structure:
153
-
154
- | Field | Type | Description |
155
- |--------|--------------------------------------------|-------------------------------------------------|
156
- | id | INTEGER | ID of state from "Data points" table |
157
- | ts | BIGINT / INTEGER | Time in ms till epoch. Can be converted to time with "new Date(ts)" |
158
- | val | REAL | Value |
159
- | ack | BIT/BOOLEAN | Is acknowledged: 0 - not ack, 1 - ack |
160
- | _from | INTEGER | ID of source from "Sources" table |
161
- | q | INTEGER | Quality as number. You can find description [here](https://github.com/ioBroker/ioBroker/blob/master/doc/SCHEMA.md#states) |
162
-
163
- *Note:* MS-SQL uses BIT, and others use BOOLEAN. SQLite uses for ts INTEGER and all others BIGINT.
164
-
165
- The user can define additional to type `number` the functionality of "counters". For this purpose following table is created:
166
- | DB | Name in the query |
167
- |------------|-------------------------|
168
- | MS-SQL | iobroker.dbo.ts_counter |
169
- | MySQL | iobroker.ts_counter |
170
- | PostgreSQL | ts_counter |
171
- | SQLite | ts_counter |
172
-
173
- Structure:
174
-
175
- | Field | Type | Description |
176
- |--------|--------------------------------------------|-------------------------------------------------|
177
- | id | INTEGER | ID of state from "Data points" table |
178
- | ts | BIGINT / INTEGER | Time in ms till epoch. Can be converted to time with "new Date(ts)" |
179
- | val | REAL | Value |
180
-
181
- This table stores the values when the counter was exchanged and the value does not increase, but failed to zero or lower value.
182
-
183
- ### Strings
184
- Values for states with type "string".
185
-
186
- | DB | Name in query |
187
- |------------|-------------------------|
188
- | MS-SQL | iobroker.dbo.ts_string |
189
- | MySQL | iobroker.ts_string |
190
- | PostgreSQL | ts_string |
191
- | SQLite | ts_string |
192
-
193
- Structure:
194
-
195
- | Field | Type | Description |
196
- |--------|--------------------------------------------|-------------------------------------------------|
197
- | id | INTEGER | ID of state from "Data points" table |
198
- | ts | BIGINT | Time in ms till epoch. Can be converted to time with "new Date(ts)" |
199
- | val | TEXT | Value |
200
- | ack | BIT/BOOLEAN | Is acknowledged: 0 - not ack, 1 - ack |
201
- | _from | INTEGER | ID of source from "Sources" table |
202
- | q | INTEGER | Quality as number. You can find description [here](https://github.com/ioBroker/ioBroker/blob/master/doc/SCHEMA.md#states) |
203
-
204
- *Note:* MS-SQL uses BIT, and others use BOOLEAN. SQLite uses for ts INTEGER and all others BIGINT.
205
-
206
- ### Booleans
207
- Values for states with type "boolean".
208
-
209
- | DB | Name in query |
210
- |------------|-------------------------|
211
- | MS-SQL | iobroker.dbo.ts_bool |
212
- | MySQL | iobroker.ts_bool |
213
- | PostgreSQL | ts_bool |
214
- | SQLite | ts_bool |
215
-
216
- Structure:
217
-
218
- | Field | Type | Description |
219
- |--------|--------------------------------------------|-------------------------------------------------|
220
- | id | INTEGER | ID of state from "Data points" table |
221
- | ts | BIGINT | Time in ms till epoch. Can be converted to time with "new Date(ts)" |
222
- | val | BIT/BOOLEAN | Value |
223
- | ack | BIT/BOOLEAN | Is acknowledged: 0 - not ack, 1 - ack |
224
- | _from | INTEGER | ID of source from "Sources" table |
225
- | q | INTEGER | Quality as number. You can find description [here](https://github.com/ioBroker/ioBroker/blob/master/doc/SCHEMA.md#states) |
226
-
227
- *Note:* MS-SQL uses BIT, and others use BOOLEAN. SQLite uses for ts INTEGER and all others BIGINT.
228
-
229
- ## Access values from Javascript adapter
230
- The sorted values can be accessed from Javascript adapter.
231
-
232
- * Get 50 last stored events for all IDs
233
- ```
234
- sendTo('sql.0', 'getHistory', {
235
- id: '*',
236
- options: {
237
- end: Date.now(),
238
- count: 50,
239
- aggregate: 'onchange',
240
- addId: true
241
- }
242
- }, function (result) {
243
- for (var i = 0; i < result.result.length; i++) {
244
- console.log(result.result[i].id + ' ' + new Date(result.result[i].ts).toISOString());
245
- }
246
- });
247
- ```
248
-
249
- * Get stored values for "system.adapter.admin.0.memRss" in last hour
250
- ```
251
- var end = Date.now();
252
- sendTo('sql.0', 'getHistory', {
253
- id: 'system.adapter.admin.0.memRss',
254
- options: {
255
- start: end - 3600000,
256
- end: end,
257
- aggregate: 'onchange',
258
- addId: true
259
- }
260
- }, function (result) {
261
- for (var i = 0; i < result.result.length; i++) {
262
- console.log(result.result[i].id + ' ' + new Date(result.result[i].ts).toISOString());
263
- }
264
- });
265
- ```
266
-
267
- Possible options:
268
- - **start** - (optional) time in ms - *Date.now()*'
269
- - **end** - (optional) time in ms - *Date.now()*', by default is (now + 5000 seconds)
270
- - **step** - (optional) used in aggregate (max, min, average, total, ...) step in ms of intervals
271
- - **count** - number of values if aggregate is 'onchange' or number of intervals if other aggregate method. Count will be ignored if step is set, else default is 500 if not set
272
- - **from** - if *from* field should be included in answer
273
- - **ack** - if *ack* field should be included in answer
274
- - **q** - if *q* field should be included in answer
275
- - **addId** - if *id* field should be included in answer
276
- - **limit** - do not return more entries than limit
277
- - **round** - round result to number of digits after decimal point
278
- - **ignoreNull** - if null values should be included (false), replaced by last not null value (true) or replaced with 0 (0)
279
- - **removeBorderValues** - By default additional border values are returned to optimize charting. Set this option to true if this is not wanted (e.g. for script data processing)
280
- - **returnNewestEntries** - The returned data are always sorted by timestamp ascending. When using aggregate "none" and also providing "count" or "limit" this means that normally the oldest entries are returned (unless no start data is provided). Set this option to true to get the newest entries instead.
281
- - **aggregate** - aggregate method:
282
- - *minmax* - used special algorithm. Splice the whole time range in small intervals and find for every interval max, min, start and end values.
283
- - *max* - Splice the whole time range in small intervals and find for every interval max value and use it for this interval (nulls will be ignored).
284
- - *min* - Same as max, but take minimal value.
285
- - *average* - Same as max, but take average value.
286
- - *total* - Same as max, but calculate total value.
287
- - *count* - Same as max, but calculate number of values (nulls will be calculated).
288
- - *percentile* - Calculate n-th percentile (n is given in options.percentile or defaults to 50 if not provided).
289
- - *quantile* - Calculate n quantile (n is given in options.quantile or defaults to 0.5 if not provided).
290
- - *integral* - Calculate integral (additional parameters see below).
291
- - *none* - No aggregation at all. Only raw values in given period.
292
- - **percentile** - (optional) when using aggregate method "percentile" defines the percentile level (0..100)(defaults to 50)
293
- - **quantile** - (optional) when using aggregate method "quantile" defines the quantile level (0..1)(defaults to 0.5)
294
- - **integralUnit** - (optional) when using aggregate method "integral" defines the unit in seconds (defaults to 60s). e.g. to get integral in hours for Wh or such, set to 3600.
295
- - **integralInterpolation** - (optional) when using aggregate method "integral" defines the interpolation method (defaults to "none").
296
- - *linear* - linear interpolation
297
- - *none* - no/stepwise interpolation
298
-
299
- The first and last points will be calculated for aggregations, except aggregation "none".
300
- If you manually request some aggregation you should ignore first and last values, because they are calculated from values outside of period.
301
-
302
-
303
- ## Get counter
304
- User can ask the value of some counter (type=number, counter=true) for specific period.
305
-
306
- ```
307
- var now = Date.now();
308
- // get consumption value for last 30 days
309
- sendTo('sql.0', 'getCounter', {
310
- id: 'system.adapter.admin.0.memRss',
311
- options: {
312
- start: now - 3600000 * 24 * 30,
313
- end: now,
314
- }
315
- }, result => {
316
- console.log(`In last 30 days the consumption was ${result.result} kWh`);
317
- });
318
- ```
319
- If the counter device will be replaced it will be calculated too.
320
-
321
- ## Custom queries
322
- The user can execute custom queries on tables from javascript adapter:
323
-
324
- ```
325
- sendTo('sql.0', 'query', 'SELECT * FROM datapoints', function (result) {
326
- if (result.error) {
327
- console.error(result.error);
328
- } else {
329
- // show result
330
- console.log('Rows: ' + JSON.stringify(result.result));
331
- }
332
- });
333
- ```
334
-
335
- Or get entries for the last hour for ID=system.adapter.admin.0.memRss
336
- ```
337
- sendTo('sql.0', 'query', 'SELECT id FROM datapoints WHERE name="system.adapter.admin.0.memRss"', function (result) {
338
- if (result.error) {
339
- console.error(result.error);
340
- } else {
341
- // show result
342
- console.log('Rows: ' + JSON.stringify(result.result));
343
- var now = new Date();
344
- now.setHours(-1);
345
- sendTo('sql.0', 'query', 'SELECT * FROM ts_number WHERE ts >= ' + now.getTime() + ' AND id=' + result.result[0].id, function (result) {
346
- console.log('Rows: ' + JSON.stringify(result.result));
347
- });
348
- }
349
- });
350
- ```
351
-
352
- *Note:*
353
-
354
- Depending on the database, the database name or database name + schema must be inserted before the table name - see boxes above under 'Structure of the DBs'.
355
-
356
- Example if your database is called 'iobroker':
357
-
358
- | DB | Name in query |
359
- |------------|------------------------------------------|
360
- | MS-SQL | SELECT * FROM iobroker.dbo.datapoints ...|
361
- | MySQL | SELECT * FROM iobroker.datapoints ... |
362
-
363
- ## storeState
364
- If you want to write other data into the InfluxDB/SQL you can use the build in system function **storeState**.
365
- This function can also be used to convert data from other History adapters like History or SQL.
366
-
367
- The given IDs are not checked against the ioBroker database and do not need to be set up there, but can only be accessed directly.
368
-
369
- The Message can have one of the following three formats:
370
- * one ID and one state object
371
-
372
- ```
373
- sendTo('history.0', 'storeState', [
374
- id: 'mbus.0.counter.xxx',
375
- state: {ts: 1589458809352, val: 123, ack: false, from: 'system.adapter.whatever.0', ...}
376
- ], result => console.log('added'));
377
- ```
378
-
379
- * one ID and array of state objects
380
-
381
- ```
382
- sendTo('history.0', 'storeState', {
383
- id: 'mbus.0.counter.xxx',
384
- state: [
385
- {ts: 1589458809352, val: 123, ack: false, from: 'system.adapter.whatever.0', ...},
386
- {ts: 1589458809353, val: 123, ack: false, from: 'system.adapter.whatever.0', ...}
387
- ]
388
- }, result => console.log('added'));
389
- ```
390
-
391
- * array of multiple IDs with one state object each
392
-
393
- ```
394
- sendTo('history.0', 'storeState', [
395
- {id: 'mbus.0.counter.xxx', state: {ts: 1589458809352, val: 123, ack: false, from: 'system.adapter.whatever.0', ...}},
396
- {id: 'mbus.0.counter.yyy', state: {ts: 1589458809353, val: 123, ack: false, from: 'system.adapter.whatever.0', ...}}
397
- ], result => console.log('added'));
398
- ```
399
-
400
- Additionally, you can add attribute `rules: true` in message to activate all rules, like `counter`, `changesOnly`, `de-bounce` and so on.
401
-
402
- ## delete state
403
- If you want to delete entry from the Database you can use the build in system function **delete**:
404
-
405
- ```
406
- sendTo('sql.0', 'delete', [
407
- {id: 'mbus.0.counter.xxx', state: {ts: 1589458809352},
408
- {id: 'mbus.0.counter.yyy', state: {ts: 1589458809353}
409
- ], result => console.log('deleted'));
410
- ```
411
-
412
- To delete ALL history data for some data point execute:
413
-
414
- ```
415
- sendTo('sql.0', 'deleteAll', [
416
- {id: 'mbus.0.counter.xxx'}
417
- {id: 'mbus.0.counter.yyy'}
418
- ], result => console.log('deleted'));
419
- ```
420
-
421
- To delete history data for some data point and for some range, execute:
422
-
423
- ```
424
- sendTo('sql.0', 'deleteRange', [
425
- {id: 'mbus.0.counter.xxx', start: '2019-01-01T00:00:00.000Z', end: '2019-12-31T23:59:59.999'},
426
- {id: 'mbus.0.counter.yyy', start: 1589458809352, end: 1589458809353}
427
- ], result => console.log('deleted'));
428
- ```
429
-
430
- Time could be ms since epoch or ans string, that could be converted by javascript Date object.
431
-
432
- Values will be deleted including defined limits. `ts >= start AND ts <= end`
433
-
434
- ## change state
435
- If you want to change entry's value, quality or acknowledge flag in the database you can use the build in system function **update**:
436
-
437
- ```
438
- sendTo('sql.0', 'update', [
439
- {id: 'mbus.0.counter.xxx', state: {ts: 1589458809352, val: 15, ack: true, q: 0},
440
- {id: 'mbus.0.counter.yyy', state: {ts: 1589458809353, val: 16, ack: true, q: 0}
441
- ], result => console.log('deleted'));
442
- ```
443
-
444
- `ts` is mandatory. At least one other flags must be included in state object.
445
-
446
- Be careful with `counters`. The `counters` in DB will not be reset, and you must handle it yourself.
447
-
448
- ## History Logging Management via Javascript
449
- The adapter supports enabling and disabling of history logging via JavaScript and also retrieving the list of enabled data points with their settings.
450
-
451
- ### enable
452
- The message requires to have the "id" of the data point. Additionally, optional "options" to define the data point specific settings:
453
-
454
- ```
455
- sendTo('sql.0', 'enableHistory', {
456
- id: 'system.adapter.sql.0.memRss',
457
- options: {
458
- changesOnly: true,
459
- debounce: 0,
460
- retention: 31536000,
461
- maxLength: 3,
462
- changesMinDelta: 0.5,
463
- aliasId: ''
464
- }
465
- }, function (result) {
466
- if (result.error) {
467
- console.log(result.error);
468
- }
469
- if (result.success) {
470
- //successful enabled
471
- }
472
- });
473
- ```
474
-
475
- ### disable
476
- The message requires to have the "id" of the data point.
477
-
478
- ```
479
- sendTo('sql.0', 'disableHistory', {
480
- id: 'system.adapter.sql.0.memRss',
481
- }, function (result) {
482
- if (result.error) {
483
- console.log(result.error);
484
- }
485
- if (result.success) {
486
- // successful enabled
487
- }
488
- });
489
- ```
490
-
491
- ### get List
492
- The message has no parameters.
493
-
494
- ```
495
- sendTo('sql.0', 'getEnabledDPs', {}, function (result) {
496
- //result is object like:
497
- {
498
- "system.adapter.sql.0.memRss": {
499
- "changesOnly":true,
500
- "debounce":0,
501
- "retention":31536000,
502
- "maxLength":3,
503
- "changesMinDelta":0.5,
504
- "enabled":true,
505
- "changesRelogInterval":0,
506
- "aliasId": ""
507
- }
508
- ...
509
- }
510
- });
511
- ```
512
-
513
- <!--
514
- Placeholder for the next version (at the beginning of the line):
515
- ### __WORK IN PROGRESS__
516
- -->
517
-
518
- ## Changelog
519
- ### 2.0.2 (2022-05-11)
520
- * (Apollon77) BREAKING: Configuration is only working in the new Admin 5 UI!
521
- * (Apollon77) Did bigger adjustments to the recording logic and added a lot of new Features. Please refer to Changelog and Forum post for details.
522
-
523
- ### 2.0.0 (2022-05-11)
524
- * (Apollon77) Breaking: Configuration is only working in the new Admin 5 UI!
525
- * (Apollon77) Breaking! Did bigger adjustments to the recording logic. Debounce is refined and blockTime is added to differentiate between the two checks
526
- * (Apollon77) Breaking! GetHistory requests now need to deliver the ts in milliseconds! Make sure to use up to date scripts and Charting UIs
527
- * (Apollon77) Add RAM buffering and mass inserts for logging
528
- * (Apollon77) New setting added to disable the "logging of additional values for charting optimization" - then only the expected data are logged
529
- * (Apollon77) Add flag returnNewestEntries for GetHistory to determine which records to return when more entries as "count" are existing for aggregate "none"
530
- * (Apollon77) Add support for addId getHistory flag for GetHistory
531
- * (Apollon77) Add new Debug flag to enable/disable debug logging on datapoint level (default is false) to optimize performance
532
- * (Apollon77) Add aggregate method "percentile" to calculate the percentile (0..100) of the values (requires options.percentile with the percentile level, defaults to 50 if not provided). Basically same as Quantile just different levels are used
533
- * (Apollon77) Add aggregate method "quantile" to calculate the quantile (0..1) of the values (requires options.quantile with the quantile level, defaults to 0.5 if not provided). Basically same as Percentile just different levels are used
534
- * (Apollon77) Add (experimental) method "integral" to calculate the integral of the values. Requires options.integralUnit with the time duration of the integral in seconds, defaults to 60s if not provided. Optionally a linear interpolation can be done by setting options.integralInterpolation to "linear"
535
- * (Apollon77) When request contains flag removeBorderValues: true, the result then cut the additional pre and post border values out of the results
536
- * (Apollon77) Enhance the former "Ignore below 0" feature and now allow specifying to ignore below or above specified values. The old setting is converted to the new one
537
- * (Apollon77) Upgrade MSSQL and MySQL drivers incl. Support for MySQL 8
538
- * (Apollon77) Make sure that min change delta allows numbers entered with comma (german notation) in all cases
539
- * (Apollon77) Add support to specify how to round numbers on query per datapoint
540
- * (Apollon77) Do not log passwords for Postgres connections
541
- * (Apollon77) Optimize SSL support for database connections including option to allow self signed certificates
542
- * (Apollon77) Allow to specify custom retention duration in days
543
- * (winnyschuster) Fix Insert statement for MSSQL ts_counter
544
- * (winnyschuster) type of ts in user queries corrected
545
-
546
- ### 1.16.2 (2022-02-16)
547
- * (bluefox) Marked interpolated data with `i=true`
548
-
549
- ### 1.16.1 (2021-12-19)
550
- * (Excodibur) Hide settings not relevant when "log changes only" is not used
551
- * (Apollon77) Allow all number values for debounce again
552
-
553
- ### 1.16.0 (2021-12-14)
554
- * (bluefox) Support only `js-controller` >= 3.3.x
555
- * (bluefox) Used system/custom view for collecting the objects
556
- * (bluefox) Implemented option to ignore zero- or/and below zero- values
557
-
558
- ### 1.15.7 (2021-04-28)
559
- * (bluefox) fixed the support of Admin5
560
-
561
- ### 1.15.6 (2021-04-19)
562
- * (bluefox) added support of Admin5
563
-
564
- ### 1.15.5 (2021-01-22)
565
- * (Apollon77) make sure message query is a string (Sentry)
566
-
567
- ### 1.15.4 (2021-01-17)
568
- * (Apollon77) Optimize stop handling
569
-
570
- ### 1.15.3 (2020-08-29)
571
- * (bluefox) Added the option "Do not create database". E.g. if DB was created and it does not required to do that, because the user does not have enough rights.
572
-
573
- ### 1.15.2 (2020-07-26)
574
- * (Apollon77) prevent wrong errors that realId is missing
575
-
576
- ### 1.15.1 (2020-07-20)
577
- * (Apollon77) implement a workaround for postgres problem
578
-
579
- ### 1.15.0 (2020-07-19)
580
- *BREAKING* This version only accepts Node.js 10.x+ (because sqlite3 was upgraded)
581
- * (Apollon77) Prevent crash case (Sentry IOBROKER-SQL-16, IOBROKER-SQL-15, IOBROKER-SQL-1K)
582
-
583
- ### 1.14.2 (2020-06-23)
584
- * (bluefox) Fixed error for data storage
585
-
586
- ### 1.14.1 (2020-06-17)
587
- * (bluefox) Corrected error for objects with mixed type
588
-
589
- ### 1.14.0 (2020-05-20)
590
- * (bluefox) added the range deletion and the delete all operations
591
-
592
- ### 1.13.1 (2020-05-20)
593
- * (bluefox) added changed and delete operations
594
-
595
- ### 1.12.6 (2020-05-08)
596
- * (bluefox) set default history if not yet set
597
-
598
- ### 1.12.5 (2020-05-05)
599
- * (Apollon77) Crash prevented for invalid objects (Sentry IOBROKER-SQL-X)
600
-
601
- ### 1.12.4 (2020-05-04)
602
- * (Apollon77) Potential crash fixed when disabling data points too fast (Sentry IOBROKER-SQL-W)
603
- * (Apollon77) Always set "encrypt" flag, even if false because else might en in default true (see https://github.com/tediousjs/tedious/issues/931)
604
-
605
- ### 1.12.3 (2020-04-30)
606
- * (Apollon77) Try to create indexes on MSSQL to speed up things. Infos are shown if not possible to be able for the user to do it themself. Timeout is 15s
607
-
608
- ### 1.12.2 (2020-04-30)
609
- * (Apollon77) MSSQL works again
610
-
611
- ### 1.12.1 (2020-04-26)
612
- * (Apollon77) Fix potential crash (Sentry)
613
-
614
- ### 1.12.0 (2020-04-23)
615
- * (Apollon77) Implement max Connections setting and respect it, now allows to control how many concurrent connections to database are used (default 100) and others wait up to 10s for a free connection before failing)
616
- * (Apollon77) Change dependencies to admin to a global dependency
617
- * (Apollon77) Update connection status also in between
618
- * (Apollon77) fix some potential crash cases (Sentry reported)
619
- * (Omega236) Add id to error message for queries
620
- * (Apollon77) update pg to stay compatible with nodejs 14
621
- * (Apollon77) Start clearly ending timeouts on unload ... still some cases left!
622
-
623
- ### 1.11.1 (2020-04-19)
624
- * __Requires js-controller >= 2.0.0__
625
- * (Apollon77) removed usage of adapter.objects
626
- * (Apollon77) check if objects have changed and ignore unchanged
627
- * (Apollon77) Add Sentry for Error Reporting with js-controller 3.0
628
- * (Apollon77) Make sure value undefined is ignored
629
-
630
- ### 1.10.1 (2020-04-12)
631
- * (bluefox) Converted to ES6
632
- * (bluefox) The counter functionality was implemented.
633
-
634
- ### 1.9.5 (2019-05-15)
635
- * (Apollon77) Add support for nodejs 12
636
-
637
- ### 1.9.4 (2019-02-24)
638
- * (Apollon77) Fix several smaller issues and topics
639
- * (Apollon77) Optimize Texts (for Admin v3 UI)
640
-
641
- ### 1.9.0 (2018-06-19)
642
- * (Apollon77) Add option to log datapoints as other ID (alias) to easier migrate devices and such
643
-
644
- ### 1.8.0 (2018-04-29)
645
- * (Apollon77) Update sqlite3, nodejs 10 compatible
646
- * (BuZZy1337) Admin fix
647
-
648
- ### 1.7.4 (2018-04-15)
649
- * (Apollon77) Fix getHistory
650
-
651
- ### 1.7.3 (2018-03-28)
652
- * (Apollon77) Respect 'keep forever' setting for retention from data point configuration
653
-
654
- ### 1.7.2 (2018-03-24)
655
- * (Apollon77) Disable to write NULLs for SQLite
656
-
657
- ### 1.7.1 (2018-02-10)
658
- * (Apollon77) Make option to write NULL values on start/stop boundaries configurable
659
-
660
- ### 1.6.9 (2018-02-07)
661
- * (bondrogeen) Admin3 Fixes
662
- * (Apollon77) optimize relog feature and other things
663
-
664
- ### 1.6.7 (2018-01-31)
665
- * (Bluefox) Admin3 Fixes
666
- * (Apollon77) Relog and null log fixes
667
-
668
- ### 1.6.2 (2018-01-30)
669
- * (Apollon77) Admin3 Fixes
670
-
671
- ### 1.6.0 (2018-01-14)
672
- * (bluefox) Ready for Admin3
673
-
674
- ### 1.5.8 (2017-10-05)
675
- * (Apollon77) fix relog value feature
676
-
677
- ### 1.5.7 (2017-08-10)
678
- * (bluefox) add "save last value" option
679
-
680
- ### 1.5.6 (2017-08-02)
681
- * (Apollon77) fix behaviour of log interval to always log the current value
682
-
683
- ### 1.5.4 (2017-06-12)
684
- * (Apollon77) fix dependency to other library
685
-
686
- ### 1.5.3 (2017-04-07)
687
- * (Apollon77) fix in datatype conversions
688
-
689
- ### 1.5.0 (2017-03-02)
690
- * (Apollon77) Add option to define storage datatype per datapoint inclusing converting the value if needed
691
-
692
- ### 1.4.6 (2017-02-25)
693
- * (Apollon77) Fix typo with PostgrSQL
694
-
695
- ### 1.4.5 (2017-02-18)
696
- * (Apollon77) Small fix again for older configurations
697
- * (Apollon77) fix for DBConverter Analyze function
698
-
699
- ### 1.4.3 (2017-02-11)
700
- * (Apollon77) Small fix for older configurations
701
-
702
- ### 1.4.2 (2017-01-16)
703
- * (bluefox) Fix handling of float values in Adapter config and Datapoint config.
704
-
705
- ### 1.4.1
706
- * (Apollon77) Rollback to sql-client 0.7 to get rid of the mmagic dependecy that brings problems on older systems
707
-
708
- ### 1.4.0 (2016-12-02)
709
- * (Apollon77) Add messages enableHistory/disableHistory
710
- * (Apollon77) add support to log changes only if value differs a minimum value for numbers
711
-
712
- ### 1.3.4 (2016-11)
713
- * (Apollon77) Allow database names with '-' for MySQL
714
-
715
- ### 1.3.3 (2016-11)
716
- * (Apollon77) Update dependecies
717
-
718
- ### 1.3.2 (2016-11-21)
719
- * (bluefox) Fix insert of string with '
720
-
721
- ### 1.3.0 (2016-10-29)
722
- * (Apollon77) add option to re-log unchanged values to make it easier for visualization
723
-
724
- ### 1.2.1 (2016-08-30)
725
- * (bluefox) Fix selector for SQL objects
726
-
727
- ### 1.2.0 (2016-08-30)
728
- * (bluefox) сompatible only with new admin
729
-
730
- ### 1.0.10 (2016-08-27)
731
- * (bluefox) change name of object from "history" to "custom"
732
-
733
- ### 1.0.10 (2016-07-31)
734
- * (bluefox) fix multi requests if sqlite
735
-
736
- ### 1.0.9 (2016-06-14)
737
- * (bluefox) allow settings for parallel requests
738
-
739
- ### 1.0.7 (2016-05-31)
740
- * (bluefox) draw line to the end if ignore null
741
-
742
- ### 1.0.6 (2016-05-30)
743
- * (bluefox) allow setup DB name for mysql and mssql
744
-
745
- ### 1.0.5 (2016-05-29)
746
- * (bluefox) switch max and min with each other
747
-
748
- ### 1.0.4 (2016-05-29)
749
- * (bluefox) check retention of data if set "never"
750
-
751
- ### 1.0.3 (2016-05-28)
752
- * (bluefox) try to calculate old timestamps
753
-
754
- ### 1.0.2 (2016-05-24)
755
- * (bluefox) fix error with io-package
756
-
757
- ### 1.0.1 (2016-05-24)
758
- * (bluefox) fix error with SQLite
759
-
760
- ### 1.0.0 (2016-05-20)
761
- * (bluefox) change default aggregation name
762
-
763
- ### 0.3.3 (2016-05-18)
764
- * (bluefox) fix postgres
765
-
766
- ### 0.3.2 (2016-05-13)
767
- * (bluefox) queue select if IDs and FROMs queries for sqlite
768
-
769
- ### 0.3.1 (2016-05-12)
770
- * (bluefox) queue delete queries too for sqlite
771
-
772
- ### 0.3.0 (2016-05-08)
773
- * (bluefox) support of custom queries
774
- * (bluefox) only one request simultaneously for sqlite
775
- * (bluefox) add tests (primitive and only sql)
776
-
777
- ### 0.2.0 (2016-04-30)
778
- * (bluefox) support of milliseconds
779
- * (bluefox) fix sqlite
780
-
781
- ### 0.1.4 (2016-04-25)
782
- * (bluefox) fix deletion of old entries
783
-
784
- ### 0.1.3 (2016-03-08)
785
- * (bluefox) do not print errors twice
786
-
787
- ### 0.1.2 (2015-12-22)
788
- * (bluefox) fix MS-SQL port settings
789
-
790
- ### 0.1.1 (2015-12-19)
791
- * (bluefox) fix error with double entries
792
-
793
- ### 0.1.0 (2015-12-14)
794
- * (bluefox) support of strings
795
-
796
- ### 0.0.3 (2015-12-06)
797
- * (smiling_Jack) Add demo Data ( todo: faster insert to db )
798
- * (smiling_Jack) change aggregation (now same as history Adapter)
799
- * (bluefox) bug fixing
800
-
801
- ### 0.0.2 (2015-12-06)
802
- * (bluefox) allow only 1 client for SQLite
803
-
804
- ### 0.0.1 (2015-11-19)
805
- * (bluefox) initial commit
806
-
807
- ## License
808
-
809
- The MIT License (MIT)
810
-
811
- Copyright (c) 2015-2022 bluefox <dogafox@gmail.com>, Apollon77
812
-
813
- Permission is hereby granted, free of charge, to any person obtaining a copy
814
- of this software and associated documentation files (the "Software"), to deal
815
- in the Software without restriction, including without limitation the rights
816
- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
817
- copies of the Software, and to permit persons to whom the Software is
818
- furnished to do so, subject to the following conditions:
819
-
820
- The above copyright notice and this permission notice shall be included in
821
- all copies or substantial portions of the Software.
822
-
823
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
824
- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
825
- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
826
- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
827
- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
828
- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
829
- THE SOFTWARE.
1
+ ![Logo](admin/sql.png)
2
+ # ioBroker.sql
3
+
4
+ ![Number of Installations](http://iobroker.live/badges/sql-installed.svg) ![Number of Installations](http://iobroker.live/badges/sql-stable.svg) [![NPM version](http://img.shields.io/npm/v/iobroker.sql.svg)](https://www.npmjs.com/package/iobroker.sql)
5
+ [![Downloads](https://img.shields.io/npm/dm/iobroker.sql.svg)](https://www.npmjs.com/package/iobroker.sql)
6
+ [![Tests](https://travis-ci.org/ioBroker/ioBroker.sql.svg?branch=master)](https://travis-ci.org/ioBroker/ioBroker.sql)
7
+
8
+ [![NPM](https://nodei.co/npm/iobroker.sql.png?downloads=true)](https://nodei.co/npm/iobroker.sql/)
9
+
10
+ This adapter saves state history into SQL DB.
11
+
12
+ Supports PostgreSQL, mysql, Microsoft SQL Server and sqlite.
13
+ You can leave port 0 if default port is desired.
14
+
15
+ **This adapter uses Sentry libraries to automatically report exceptions and code errors to the developers.** For more details and for information how to disable the error reporting see [Sentry-Plugin Documentation](https://github.com/ioBroker/plugin-sentry#plugin-sentry)! Sentry reporting is used starting with js-controller 3.0.
16
+
17
+ ## Settings
18
+
19
+ ## Connection Settings
20
+ - **DB Type**: Type of the SQL DB: MySQL, PostgreSQL, MS-SQL or SQLite3
21
+ - **Host**: IP address or host name with SQL Server
22
+ - **Port**: Port of SQL Server (leave blank if not sure)
23
+ - **Database name**: Database name. Default iobroker
24
+ - **User**: Username for SQL. Must exist in the DB.
25
+ - **Password**: Password for SQL.
26
+ - **Password confirm**: Just repeat password here.
27
+ - **Encrypt**: Some DBs support encryption.
28
+ - **Round real to**: Number of digits after the comma.
29
+ - **Allow parallel requests**: Allow simultaneous SQL requests to DB.
30
+ - **Do not create database**: Activate this option if database already created (e.g. by administrator) and the ioBroker-user does not have enough rights to create a DB.
31
+
32
+ ## Default Settings
33
+ - **Debounce Time** - Protection against unstable values to make sure that only stable values are logged when the value did not change in the defined amount of Milliseconds. ATTENTION: If values change more often then this setting effectively no value will be logged (because any value is unstable)
34
+ - **Blocktime** - Defines for how long after storing the last value no further value is stored. When the given time in Milliseconds is over then the next value that fulfills all other checks is logged.
35
+ - **Record changes only** - This function make sure that only changed values are logged if they fulfill other checks (see below). Same values will not be logged.
36
+ - **still record the same values (seconds)** - When using "Record changes only" you can set a time interval in seconds here after which also unchanged values will be re-logged into the DB. You can detect the values re-logged by the adapter with the "from" field.
37
+ - **Minimum difference from last value** - When using "Record changes only" you can define the required minimum difference between the new value and the last value. If this is not reached the value is not recorded.
38
+ - **ignore 0 or null values (==0)** - You can define if 0 or null values should be ignored.
39
+ - **ignore values below zero (<0)** - You can define if values below zero should be ignored.
40
+ - **Disable charting optimized logging of skipped values** - By default the adapter tries to record the values for optimized charting. This can mean that additional values (that e.g. not fulfilled all checks above) are logged automatically. If this is not wanted, you can disable this feature.
41
+ - **Alias-ID** - You can define an alias for the ID. This is useful if you have changed a device and want to have continuous data logging. Please consider switching to real alias States in teh future!
42
+ - **Storage retention** - How many values in the past will be stored on disk. Data are deleted when the time is reached as soon as new data should be stored for a datapoint.
43
+ - **Maximal number of stored in RAM values** - Define how many number of values will be hold in RAM before persisting them on disk. You can control how much I/O is done.
44
+ - **Enable enhanced debug logs for the datapoint** - If you want to see more detailed logs for this datapoint, you can enable this option. You still need to enable "debug" loglevel for these additional values to be visible! This helps in debugging issues or understanding why the adapter is logging a value (or not).
45
+
46
+ Most of these values can be pre-defined in the instance settings and are then pre-filled or used for the datapoint.
47
+
48
+ ## Database installation tips
49
+
50
+ ### MS-SQL:
51
+ Use ```localhost\instance``` for the host and check TCP/IP connections enabled.
52
+ https://msdn.microsoft.com/en-us/library/bb909712(v=vs.90).aspx
53
+
54
+ ### SQLite:
55
+ is "file"-DB and cannot manage too many events. If you have a big amount of data use the real DB, like PostgreSQL and co.
56
+
57
+ SQLite DB must not be installed extra. It is just a file on disk, but to install it you require build tools on your system. For linux, just write:
58
+
59
+ ```
60
+ sudo apt-get install build-essential
61
+ ```
62
+
63
+ For windows:
64
+
65
+ ```
66
+ c:\>npm install --global --production windows-build-tools
67
+ ```
68
+
69
+ and then reinstall the adapter, e.g:
70
+
71
+ ```
72
+ cd /opt/iobroker
73
+ iobroker stop sql
74
+ npm install iobroker.sql --production
75
+ iobroker start sql
76
+ ```
77
+
78
+ ### MySQL:
79
+ You can install mysql on linux systems as following:
80
+
81
+ ```
82
+ apt-get install mysql-server mysql-client
83
+
84
+ mysql -u root -p
85
+
86
+ CREATE USER 'iobroker'@'%' IDENTIFIED BY 'iobroker';
87
+ GRANT ALL PRIVILEGES ON * . * TO 'iobroker'@'%';
88
+ FLUSH PRIVILEGES;
89
+ ```
90
+
91
+ If required edit */etc/mysql/my.cnf* to set bind to IP-Address for remote connect.
92
+
93
+ **Warning**: iobroker user is "admin". If required give limited rights to iobroker user.
94
+
95
+ On the "windows" it can be easily installed via installer: https://dev.mysql.com/downloads/installer/.
96
+
97
+ Pay attention for authentication method. The new encryption algorithm in MySQL 8.0 is not yet supported by `node.js` and you must select legacy authentication method.
98
+
99
+ ![Windows](img/WindowsMySQLinstaller.png)
100
+
101
+ ## Structure of the DBs
102
+ Default Database name is "iobroker", but it can be changed in the configuration.
103
+ ### Sources
104
+ This table is a list of adapter's instances, that wrote the entries. (state.from)
105
+
106
+ | DB | Name in query |
107
+ |------------|----------------------|
108
+ | MS-SQL | iobroker.dbo.sources |
109
+ | MySQL | iobroker.sources |
110
+ | PostgreSQL | sources |
111
+ | SQLite | sources |
112
+
113
+ Structure:
114
+
115
+ | Field | Type | Description |
116
+ |-------|--------------------------------------------|-------------------------------------------|
117
+ | id | INTEGER NOT NULL PRIMARY KEY IDENTITY(1,1) | unique ID |
118
+ | name | varchar(255) / TEXT | instance of adapter, that wrote the entry |
119
+
120
+ *Note:* MS-SQL uses varchar(255), and others use TEXT
121
+
122
+ ### Data points
123
+ This table is a list of data points. (IDs)
124
+
125
+ | DB | Name in query |
126
+ |------------|-------------------------|
127
+ | MS-SQL | iobroker.dbo.datapoints |
128
+ | MySQL | iobroker.datapoints |
129
+ | PostgreSQL | datapoints |
130
+ | SQLite | datapoints |
131
+
132
+ Structure:
133
+
134
+ | Field | Type | Description |
135
+ |-------|--------------------------------------------|-------------------------------------------------|
136
+ | id | INTEGER NOT NULL PRIMARY KEY IDENTITY(1,1) | unique ID |
137
+ | name | varchar(255) / TEXT | ID of variable, e.g. hm-rpc.0.JEQ283747.1.STATE |
138
+ | type | INTEGER | 0 - number, 1 - string, 2 - boolean |
139
+
140
+ *Note:* MS-SQL uses varchar(255), and others use TEXT
141
+
142
+ ### Numbers
143
+ Values for states with type "number". **ts** means "time series".
144
+
145
+ | DB | Name in query |
146
+ |------------|-------------------------|
147
+ | MS-SQL | iobroker.dbo.ts_number |
148
+ | MySQL | iobroker.ts_number |
149
+ | PostgreSQL | ts_number |
150
+ | SQLite | ts_number |
151
+
152
+ Structure:
153
+
154
+ | Field | Type | Description |
155
+ |--------|--------------------------------------------|-------------------------------------------------|
156
+ | id | INTEGER | ID of state from "Data points" table |
157
+ | ts | BIGINT / INTEGER | Time in ms till epoch. Can be converted to time with "new Date(ts)" |
158
+ | val | REAL | Value |
159
+ | ack | BIT/BOOLEAN | Is acknowledged: 0 - not ack, 1 - ack |
160
+ | _from | INTEGER | ID of source from "Sources" table |
161
+ | q | INTEGER | Quality as number. You can find description [here](https://github.com/ioBroker/ioBroker/blob/master/doc/SCHEMA.md#states) |
162
+
163
+ *Note:* MS-SQL uses BIT, and others use BOOLEAN. SQLite uses for ts INTEGER and all others BIGINT.
164
+
165
+ The user can define additional to type `number` the functionality of "counters". For this purpose following table is created:
166
+ | DB | Name in the query |
167
+ |------------|-------------------------|
168
+ | MS-SQL | iobroker.dbo.ts_counter |
169
+ | MySQL | iobroker.ts_counter |
170
+ | PostgreSQL | ts_counter |
171
+ | SQLite | ts_counter |
172
+
173
+ Structure:
174
+
175
+ | Field | Type | Description |
176
+ |--------|--------------------------------------------|-------------------------------------------------|
177
+ | id | INTEGER | ID of state from "Data points" table |
178
+ | ts | BIGINT / INTEGER | Time in ms till epoch. Can be converted to time with "new Date(ts)" |
179
+ | val | REAL | Value |
180
+
181
+ This table stores the values when the counter was exchanged and the value does not increase, but failed to zero or lower value.
182
+
183
+ ### Strings
184
+ Values for states with type "string".
185
+
186
+ | DB | Name in query |
187
+ |------------|-------------------------|
188
+ | MS-SQL | iobroker.dbo.ts_string |
189
+ | MySQL | iobroker.ts_string |
190
+ | PostgreSQL | ts_string |
191
+ | SQLite | ts_string |
192
+
193
+ Structure:
194
+
195
+ | Field | Type | Description |
196
+ |--------|--------------------------------------------|-------------------------------------------------|
197
+ | id | INTEGER | ID of state from "Data points" table |
198
+ | ts | BIGINT | Time in ms till epoch. Can be converted to time with "new Date(ts)" |
199
+ | val | TEXT | Value |
200
+ | ack | BIT/BOOLEAN | Is acknowledged: 0 - not ack, 1 - ack |
201
+ | _from | INTEGER | ID of source from "Sources" table |
202
+ | q | INTEGER | Quality as number. You can find description [here](https://github.com/ioBroker/ioBroker/blob/master/doc/SCHEMA.md#states) |
203
+
204
+ *Note:* MS-SQL uses BIT, and others use BOOLEAN. SQLite uses for ts INTEGER and all others BIGINT.
205
+
206
+ ### Booleans
207
+ Values for states with type "boolean".
208
+
209
+ | DB | Name in query |
210
+ |------------|-------------------------|
211
+ | MS-SQL | iobroker.dbo.ts_bool |
212
+ | MySQL | iobroker.ts_bool |
213
+ | PostgreSQL | ts_bool |
214
+ | SQLite | ts_bool |
215
+
216
+ Structure:
217
+
218
+ | Field | Type | Description |
219
+ |--------|--------------------------------------------|-------------------------------------------------|
220
+ | id | INTEGER | ID of state from "Data points" table |
221
+ | ts | BIGINT | Time in ms till epoch. Can be converted to time with "new Date(ts)" |
222
+ | val | BIT/BOOLEAN | Value |
223
+ | ack | BIT/BOOLEAN | Is acknowledged: 0 - not ack, 1 - ack |
224
+ | _from | INTEGER | ID of source from "Sources" table |
225
+ | q | INTEGER | Quality as number. You can find description [here](https://github.com/ioBroker/ioBroker/blob/master/doc/SCHEMA.md#states) |
226
+
227
+ *Note:* MS-SQL uses BIT, and others use BOOLEAN. SQLite uses for ts INTEGER and all others BIGINT.
228
+
229
+ ## Access values from Javascript adapter
230
+ The sorted values can be accessed from Javascript adapter.
231
+
232
+ * Get 50 last stored events for all IDs
233
+ ```
234
+ sendTo('sql.0', 'getHistory', {
235
+ id: '*',
236
+ options: {
237
+ end: Date.now(),
238
+ count: 50,
239
+ aggregate: 'onchange',
240
+ addId: true
241
+ }
242
+ }, function (result) {
243
+ for (var i = 0; i < result.result.length; i++) {
244
+ console.log(result.result[i].id + ' ' + new Date(result.result[i].ts).toISOString());
245
+ }
246
+ });
247
+ ```
248
+
249
+ * Get stored values for "system.adapter.admin.0.memRss" in last hour
250
+ ```
251
+ var end = Date.now();
252
+ sendTo('sql.0', 'getHistory', {
253
+ id: 'system.adapter.admin.0.memRss',
254
+ options: {
255
+ start: end - 3600000,
256
+ end: end,
257
+ aggregate: 'onchange',
258
+ addId: true
259
+ }
260
+ }, function (result) {
261
+ for (var i = 0; i < result.result.length; i++) {
262
+ console.log(result.result[i].id + ' ' + new Date(result.result[i].ts).toISOString());
263
+ }
264
+ });
265
+ ```
266
+
267
+ Possible options:
268
+ - **start** - (optional) time in ms - *Date.now()*'
269
+ - **end** - (optional) time in ms - *Date.now()*', by default is (now + 5000 seconds)
270
+ - **step** - (optional) used in aggregate (max, min, average, total, ...) step in ms of intervals
271
+ - **count** - number of values if aggregate is 'onchange' or number of intervals if other aggregate method. Count will be ignored if step is set, else default is 500 if not set
272
+ - **from** - if *from* field should be included in answer
273
+ - **ack** - if *ack* field should be included in answer
274
+ - **q** - if *q* field should be included in answer
275
+ - **addId** - if *id* field should be included in answer
276
+ - **limit** - do not return more entries than limit
277
+ - **round** - round result to number of digits after decimal point
278
+ - **ignoreNull** - if null values should be included (false), replaced by last not null value (true) or replaced with 0 (0)
279
+ - **removeBorderValues** - By default additional border values are returned to optimize charting. Set this option to true if this is not wanted (e.g. for script data processing)
280
+ - **returnNewestEntries** - The returned data are always sorted by timestamp ascending. When using aggregate "none" and also providing "count" or "limit" this means that normally the oldest entries are returned (unless no start data is provided). Set this option to true to get the newest entries instead.
281
+ - **aggregate** - aggregate method (Default: 'average'):
282
+ - *minmax* - used special algorithm. Splice the whole time range in small intervals and find for every interval max, min, start and end values.
283
+ - *max* - Splice the whole time range in small intervals and find for every interval max value and use it for this interval (nulls will be ignored).
284
+ - *min* - Same as max, but take minimal value.
285
+ - *average* - Same as max, but take average value.
286
+ - *total* - Same as max, but calculate total value.
287
+ - *count* - Same as max, but calculate number of values (nulls will be calculated).
288
+ - *percentile* - Calculate n-th percentile (n is given in options.percentile or defaults to 50 if not provided).
289
+ - *quantile* - Calculate n quantile (n is given in options.quantile or defaults to 0.5 if not provided).
290
+ - *integral* - Calculate integral (additional parameters see below).
291
+ - *none* - No aggregation at all. Only raw values in given period.
292
+ - **percentile** - (optional) when using aggregate method "percentile" defines the percentile level (0..100)(defaults to 50)
293
+ - **quantile** - (optional) when using aggregate method "quantile" defines the quantile level (0..1)(defaults to 0.5)
294
+ - **integralUnit** - (optional) when using aggregate method "integral" defines the unit in seconds (defaults to 60s). e.g. to get integral in hours for Wh or such, set to 3600.
295
+ - **integralInterpolation** - (optional) when using aggregate method "integral" defines the interpolation method (defaults to "none").
296
+ - *linear* - linear interpolation
297
+ - *none* - no/stepwise interpolation
298
+
299
+ The first and last points will be calculated for aggregations, except aggregation "none".
300
+ If you manually request some aggregation you should ignore first and last values, because they are calculated from values outside of period.
301
+
302
+
303
+ ## Get counter
304
+ User can ask the value of some counter (type=number, counter=true) for specific period.
305
+
306
+ ```
307
+ var now = Date.now();
308
+ // get consumption value for last 30 days
309
+ sendTo('sql.0', 'getCounter', {
310
+ id: 'system.adapter.admin.0.memRss',
311
+ options: {
312
+ start: now - 3600000 * 24 * 30,
313
+ end: now,
314
+ }
315
+ }, result => {
316
+ console.log(`In last 30 days the consumption was ${result.result} kWh`);
317
+ });
318
+ ```
319
+ If the counter device will be replaced it will be calculated too.
320
+
321
+ ## Custom queries
322
+ The user can execute custom queries on tables from javascript adapter:
323
+
324
+ ```
325
+ sendTo('sql.0', 'query', 'SELECT * FROM datapoints', function (result) {
326
+ if (result.error) {
327
+ console.error(result.error);
328
+ } else {
329
+ // show result
330
+ console.log('Rows: ' + JSON.stringify(result.result));
331
+ }
332
+ });
333
+ ```
334
+
335
+ Or get entries for the last hour for ID=system.adapter.admin.0.memRss
336
+ ```
337
+ sendTo('sql.0', 'query', 'SELECT id FROM datapoints WHERE name="system.adapter.admin.0.memRss"', function (result) {
338
+ if (result.error) {
339
+ console.error(result.error);
340
+ } else {
341
+ // show result
342
+ console.log('Rows: ' + JSON.stringify(result.result));
343
+ var now = new Date();
344
+ now.setHours(-1);
345
+ sendTo('sql.0', 'query', 'SELECT * FROM ts_number WHERE ts >= ' + now.getTime() + ' AND id=' + result.result[0].id, function (result) {
346
+ console.log('Rows: ' + JSON.stringify(result.result));
347
+ });
348
+ }
349
+ });
350
+ ```
351
+
352
+ *Note:*
353
+
354
+ Depending on the database, the database name or database name + schema must be inserted before the table name - see boxes above under 'Structure of the DBs'.
355
+
356
+ Example if your database is called 'iobroker':
357
+
358
+ | DB | Name in query |
359
+ |------------|------------------------------------------|
360
+ | MS-SQL | SELECT * FROM iobroker.dbo.datapoints ...|
361
+ | MySQL | SELECT * FROM iobroker.datapoints ... |
362
+
363
+ ## storeState
364
+ If you want to write other data into the InfluxDB/SQL you can use the build in system function **storeState**.
365
+ This function can also be used to convert data from other History adapters like History or SQL.
366
+
367
+ A successful response do not mean that the data are really written out to the disk. It just means that they were processed.
368
+
369
+ The given ids are not checked against the ioBroker database and do not need to be set up or enabled there. If own IDs are used without settings then the "rules" parameter is not supported and will result in an error. The default "Maximal number of stored in RAM values" is used for such IDs.
370
+
371
+ The Message can have one of the following three formats:
372
+ * one ID and one state object
373
+
374
+ ```
375
+ sendTo('history.0', 'storeState', [
376
+ id: 'mbus.0.counter.xxx',
377
+ state: {ts: 1589458809352, val: 123, ack: false, from: 'system.adapter.whatever.0', ...}
378
+ ], result => console.log('added'));
379
+ ```
380
+
381
+ * one ID and array of state objects
382
+
383
+ ```
384
+ sendTo('history.0', 'storeState', {
385
+ id: 'mbus.0.counter.xxx',
386
+ state: [
387
+ {ts: 1589458809352, val: 123, ack: false, from: 'system.adapter.whatever.0', ...},
388
+ {ts: 1589458809353, val: 123, ack: false, from: 'system.adapter.whatever.0', ...}
389
+ ]
390
+ }, result => console.log('added'));
391
+ ```
392
+
393
+ * array of multiple IDs with one state object each
394
+
395
+ ```
396
+ sendTo('history.0', 'storeState', [
397
+ {id: 'mbus.0.counter.xxx', state: {ts: 1589458809352, val: 123, ack: false, from: 'system.adapter.whatever.0', ...}},
398
+ {id: 'mbus.0.counter.yyy', state: {ts: 1589458809353, val: 123, ack: false, from: 'system.adapter.whatever.0', ...}}
399
+ ], result => console.log('added'));
400
+ ```
401
+
402
+ Additionally, you can add attribute `rules: true` in message to activate all rules, like `counter`, `changesOnly`, `de-bounce` and so on.
403
+
404
+ In case of errors an array with all single error messages is returned and also a successCount to see how many entries were stored successfully.
405
+
406
+ ## delete state
407
+ If you want to delete entry from the Database you can use the build in system function **delete**:
408
+
409
+ ```
410
+ sendTo('sql.0', 'delete', [
411
+ {id: 'mbus.0.counter.xxx', state: {ts: 1589458809352},
412
+ {id: 'mbus.0.counter.yyy', state: {ts: 1589458809353}
413
+ ], result => console.log('deleted'));
414
+ ```
415
+
416
+ To delete ALL history data for some data point execute:
417
+
418
+ ```
419
+ sendTo('sql.0', 'deleteAll', [
420
+ {id: 'mbus.0.counter.xxx'}
421
+ {id: 'mbus.0.counter.yyy'}
422
+ ], result => console.log('deleted'));
423
+ ```
424
+
425
+ To delete history data for some data point and for some range, execute:
426
+
427
+ ```
428
+ sendTo('sql.0', 'deleteRange', [
429
+ {id: 'mbus.0.counter.xxx', start: '2019-01-01T00:00:00.000Z', end: '2019-12-31T23:59:59.999'},
430
+ {id: 'mbus.0.counter.yyy', start: 1589458809352, end: 1589458809353}
431
+ ], result => console.log('deleted'));
432
+ ```
433
+
434
+ Time could be ms since epoch or ans string, that could be converted by javascript Date object.
435
+
436
+ Values will be deleted including defined limits. `ts >= start AND ts <= end`
437
+
438
+ ## change state
439
+ If you want to change entry's value, quality or acknowledge flag in the database you can use the build in system function **update**:
440
+
441
+ ```
442
+ sendTo('sql.0', 'update', [
443
+ {id: 'mbus.0.counter.xxx', state: {ts: 1589458809352, val: 15, ack: true, q: 0},
444
+ {id: 'mbus.0.counter.yyy', state: {ts: 1589458809353, val: 16, ack: true, q: 0}
445
+ ], result => console.log('deleted'));
446
+ ```
447
+
448
+ `ts` is mandatory. At least one other flags must be included in state object.
449
+
450
+ Be careful with `counters`. The `counters` in DB will not be reset, and you must handle it yourself.
451
+
452
+ ## History Logging Management via Javascript
453
+ The adapter supports enabling and disabling of history logging via JavaScript and also retrieving the list of enabled data points with their settings.
454
+
455
+ ### enable
456
+ The message requires to have the "id" of the data point. Additionally, optional "options" to define the data point specific settings:
457
+
458
+ ```
459
+ sendTo('sql.0', 'enableHistory', {
460
+ id: 'system.adapter.sql.0.memRss',
461
+ options: {
462
+ changesOnly: true,
463
+ debounce: 0,
464
+ retention: 31536000,
465
+ maxLength: 3,
466
+ changesMinDelta: 0.5,
467
+ aliasId: ''
468
+ }
469
+ }, function (result) {
470
+ if (result.error) {
471
+ console.log(result.error);
472
+ }
473
+ if (result.success) {
474
+ //successful enabled
475
+ }
476
+ });
477
+ ```
478
+
479
+ ### disable
480
+ The message requires to have the "id" of the data point.
481
+
482
+ ```
483
+ sendTo('sql.0', 'disableHistory', {
484
+ id: 'system.adapter.sql.0.memRss',
485
+ }, function (result) {
486
+ if (result.error) {
487
+ console.log(result.error);
488
+ }
489
+ if (result.success) {
490
+ // successful enabled
491
+ }
492
+ });
493
+ ```
494
+
495
+ ### get List
496
+ The message has no parameters.
497
+
498
+ ```
499
+ sendTo('sql.0', 'getEnabledDPs', {}, function (result) {
500
+ //result is object like:
501
+ {
502
+ "system.adapter.sql.0.memRss": {
503
+ "changesOnly":true,
504
+ "debounce":0,
505
+ "retention":31536000,
506
+ "maxLength":3,
507
+ "changesMinDelta":0.5,
508
+ "enabled":true,
509
+ "changesRelogInterval":0,
510
+ "aliasId": ""
511
+ }
512
+ ...
513
+ }
514
+ });
515
+ ```
516
+
517
+ <!--
518
+ Placeholder for the next version (at the beginning of the line):
519
+ ### __WORK IN PROGRESS__
520
+ -->
521
+
522
+ ## Changelog
523
+ ### 2.1.2 (2022-06-08)
524
+ * (Apollon77) Huge performance optimizations for GetHistory calls
525
+
526
+ ### 2.1.1 (2022-05-30)
527
+ * (Apollon77) Fix crash cases reported by Sentry
528
+
529
+ ### 2.1.0 (2022-05-27)
530
+ * (Apollon77) Fix crash cases reported by Sentry
531
+ * (Apollon77) Fix several places where pooled connections might have not been returned to pool correctly and add logging for it
532
+ * (Apollon77) Work around an issue in used Pooling library that potentially gave out too many connections
533
+ * (Apollon77) Optimize retention check to better spread the first checks over time
534
+ * (Apollon77) Default to not use datapoint buffering as in 1.x when set to 0
535
+ * (Apollon77) Make sure disabling "Log changes only" also really do not log the changes anymore
536
+ * (Apollon77) Allow storeState and GetHistory also to be called for "unknown ids"
537
+ * (Apollon77) Adjust the fallback logic for type detection to use the type of the state value to log as last fallback
538
+ * (Apollon77) Fix storing booleans on MSSQL
539
+
540
+ ### 2.0.2 (2022-05-11)
541
+ * (Apollon77) BREAKING: Configuration is only working in the new Admin 5 UI!
542
+ * (Apollon77) Did bigger adjustments to the recording logic and added a lot of new Features. Please refer to Changelog and Forum post for details.
543
+
544
+ ### 2.0.0 (2022-05-11)
545
+ * (Apollon77) Breaking: Configuration is only working in the new Admin 5 UI!
546
+ * (Apollon77) Breaking! Did bigger adjustments to the recording logic. Debounce is refined and blockTime is added to differentiate between the two checks
547
+ * (Apollon77) Breaking! GetHistory requests now need to deliver the ts in milliseconds! Make sure to use up to date scripts and Charting UIs
548
+ * (Apollon77) Add RAM buffering and mass inserts for logging
549
+ * (Apollon77) New setting added to disable the "logging of additional values for charting optimization" - then only the expected data are logged
550
+ * (Apollon77) Add flag returnNewestEntries for GetHistory to determine which records to return when more entries as "count" are existing for aggregate "none"
551
+ * (Apollon77) Add support for addId getHistory flag for GetHistory
552
+ * (Apollon77) Add new Debug flag to enable/disable debug logging on datapoint level (default is false) to optimize performance
553
+ * (Apollon77) Add aggregate method "percentile" to calculate the percentile (0..100) of the values (requires options.percentile with the percentile level, defaults to 50 if not provided). Basically same as Quantile just different levels are used
554
+ * (Apollon77) Add aggregate method "quantile" to calculate the quantile (0..1) of the values (requires options.quantile with the quantile level, defaults to 0.5 if not provided). Basically same as Percentile just different levels are used
555
+ * (Apollon77) Add (experimental) method "integral" to calculate the integral of the values. Requires options.integralUnit with the time duration of the integral in seconds, defaults to 60s if not provided. Optionally a linear interpolation can be done by setting options.integralInterpolation to "linear"
556
+ * (Apollon77) When request contains flag removeBorderValues: true, the result then cut the additional pre and post border values out of the results
557
+ * (Apollon77) Enhance the former "Ignore below 0" feature and now allow specifying to ignore below or above specified values. The old setting is converted to the new one
558
+ * (Apollon77) Upgrade MSSQL and MySQL drivers incl. Support for MySQL 8
559
+ * (Apollon77) Make sure that min change delta allows numbers entered with comma (german notation) in all cases
560
+ * (Apollon77) Add support to specify how to round numbers on query per datapoint
561
+ * (Apollon77) Do not log passwords for Postgres connections
562
+ * (Apollon77) Optimize SSL support for database connections including option to allow self signed certificates
563
+ * (Apollon77) Allow to specify custom retention duration in days
564
+ * (winnyschuster) Fix Insert statement for MSSQL ts_counter
565
+ * (winnyschuster) type of ts in user queries corrected
566
+
567
+ ### 1.16.2 (2022-02-16)
568
+ * (bluefox) Marked interpolated data with `i=true`
569
+
570
+ ### 1.16.1 (2021-12-19)
571
+ * (Excodibur) Hide settings not relevant when "log changes only" is not used
572
+ * (Apollon77) Allow all number values for debounce again
573
+
574
+ ### 1.16.0 (2021-12-14)
575
+ * (bluefox) Support only `js-controller` >= 3.3.x
576
+ * (bluefox) Used system/custom view for collecting the objects
577
+ * (bluefox) Implemented option to ignore zero- or/and below zero- values
578
+
579
+ ### 1.15.7 (2021-04-28)
580
+ * (bluefox) fixed the support of Admin5
581
+
582
+ ### 1.15.6 (2021-04-19)
583
+ * (bluefox) added support of Admin5
584
+
585
+ ### 1.15.5 (2021-01-22)
586
+ * (Apollon77) make sure message query is a string (Sentry)
587
+
588
+ ### 1.15.4 (2021-01-17)
589
+ * (Apollon77) Optimize stop handling
590
+
591
+ ### 1.15.3 (2020-08-29)
592
+ * (bluefox) Added the option "Do not create database". E.g. if DB was created and it does not required to do that, because the user does not have enough rights.
593
+
594
+ ### 1.15.2 (2020-07-26)
595
+ * (Apollon77) prevent wrong errors that realId is missing
596
+
597
+ ### 1.15.1 (2020-07-20)
598
+ * (Apollon77) implement a workaround for postgres problem
599
+
600
+ ### 1.15.0 (2020-07-19)
601
+ *BREAKING* This version only accepts Node.js 10.x+ (because sqlite3 was upgraded)
602
+ * (Apollon77) Prevent crash case (Sentry IOBROKER-SQL-16, IOBROKER-SQL-15, IOBROKER-SQL-1K)
603
+
604
+ ### 1.14.2 (2020-06-23)
605
+ * (bluefox) Fixed error for data storage
606
+
607
+ ### 1.14.1 (2020-06-17)
608
+ * (bluefox) Corrected error for objects with mixed type
609
+
610
+ ### 1.14.0 (2020-05-20)
611
+ * (bluefox) added the range deletion and the delete all operations
612
+
613
+ ### 1.13.1 (2020-05-20)
614
+ * (bluefox) added changed and delete operations
615
+
616
+ ### 1.12.6 (2020-05-08)
617
+ * (bluefox) set default history if not yet set
618
+
619
+ ### 1.12.5 (2020-05-05)
620
+ * (Apollon77) Crash prevented for invalid objects (Sentry IOBROKER-SQL-X)
621
+
622
+ ### 1.12.4 (2020-05-04)
623
+ * (Apollon77) Potential crash fixed when disabling data points too fast (Sentry IOBROKER-SQL-W)
624
+ * (Apollon77) Always set "encrypt" flag, even if false because else might en in default true (see https://github.com/tediousjs/tedious/issues/931)
625
+
626
+ ### 1.12.3 (2020-04-30)
627
+ * (Apollon77) Try to create indexes on MSSQL to speed up things. Infos are shown if not possible to be able for the user to do it themself. Timeout is 15s
628
+
629
+ ### 1.12.2 (2020-04-30)
630
+ * (Apollon77) MSSQL works again
631
+
632
+ ### 1.12.1 (2020-04-26)
633
+ * (Apollon77) Fix potential crash (Sentry)
634
+
635
+ ### 1.12.0 (2020-04-23)
636
+ * (Apollon77) Implement max Connections setting and respect it, now allows to control how many concurrent connections to database are used (default 100) and others wait up to 10s for a free connection before failing)
637
+ * (Apollon77) Change dependencies to admin to a global dependency
638
+ * (Apollon77) Update connection status also in between
639
+ * (Apollon77) fix some potential crash cases (Sentry reported)
640
+ * (Omega236) Add id to error message for queries
641
+ * (Apollon77) update pg to stay compatible with nodejs 14
642
+ * (Apollon77) Start clearly ending timeouts on unload ... still some cases left!
643
+
644
+ ### 1.11.1 (2020-04-19)
645
+ * __Requires js-controller >= 2.0.0__
646
+ * (Apollon77) removed usage of adapter.objects
647
+ * (Apollon77) check if objects have changed and ignore unchanged
648
+ * (Apollon77) Add Sentry for Error Reporting with js-controller 3.0
649
+ * (Apollon77) Make sure value undefined is ignored
650
+
651
+ ### 1.10.1 (2020-04-12)
652
+ * (bluefox) Converted to ES6
653
+ * (bluefox) The counter functionality was implemented.
654
+
655
+ ### 1.9.5 (2019-05-15)
656
+ * (Apollon77) Add support for nodejs 12
657
+
658
+ ### 1.9.4 (2019-02-24)
659
+ * (Apollon77) Fix several smaller issues and topics
660
+ * (Apollon77) Optimize Texts (for Admin v3 UI)
661
+
662
+ ### 1.9.0 (2018-06-19)
663
+ * (Apollon77) Add option to log datapoints as other ID (alias) to easier migrate devices and such
664
+
665
+ ### 1.8.0 (2018-04-29)
666
+ * (Apollon77) Update sqlite3, nodejs 10 compatible
667
+ * (BuZZy1337) Admin fix
668
+
669
+ ### 1.7.4 (2018-04-15)
670
+ * (Apollon77) Fix getHistory
671
+
672
+ ### 1.7.3 (2018-03-28)
673
+ * (Apollon77) Respect 'keep forever' setting for retention from data point configuration
674
+
675
+ ### 1.7.2 (2018-03-24)
676
+ * (Apollon77) Disable to write NULLs for SQLite
677
+
678
+ ### 1.7.1 (2018-02-10)
679
+ * (Apollon77) Make option to write NULL values on start/stop boundaries configurable
680
+
681
+ ### 1.6.9 (2018-02-07)
682
+ * (bondrogeen) Admin3 Fixes
683
+ * (Apollon77) optimize relog feature and other things
684
+
685
+ ### 1.6.7 (2018-01-31)
686
+ * (Bluefox) Admin3 Fixes
687
+ * (Apollon77) Relog and null log fixes
688
+
689
+ ### 1.6.2 (2018-01-30)
690
+ * (Apollon77) Admin3 Fixes
691
+
692
+ ### 1.6.0 (2018-01-14)
693
+ * (bluefox) Ready for Admin3
694
+
695
+ ### 1.5.8 (2017-10-05)
696
+ * (Apollon77) fix relog value feature
697
+
698
+ ### 1.5.7 (2017-08-10)
699
+ * (bluefox) add "save last value" option
700
+
701
+ ### 1.5.6 (2017-08-02)
702
+ * (Apollon77) fix behaviour of log interval to always log the current value
703
+
704
+ ### 1.5.4 (2017-06-12)
705
+ * (Apollon77) fix dependency to other library
706
+
707
+ ### 1.5.3 (2017-04-07)
708
+ * (Apollon77) fix in datatype conversions
709
+
710
+ ### 1.5.0 (2017-03-02)
711
+ * (Apollon77) Add option to define storage datatype per datapoint inclusing converting the value if needed
712
+
713
+ ### 1.4.6 (2017-02-25)
714
+ * (Apollon77) Fix typo with PostgrSQL
715
+
716
+ ### 1.4.5 (2017-02-18)
717
+ * (Apollon77) Small fix again for older configurations
718
+ * (Apollon77) fix for DBConverter Analyze function
719
+
720
+ ### 1.4.3 (2017-02-11)
721
+ * (Apollon77) Small fix for older configurations
722
+
723
+ ### 1.4.2 (2017-01-16)
724
+ * (bluefox) Fix handling of float values in Adapter config and Datapoint config.
725
+
726
+ ### 1.4.1
727
+ * (Apollon77) Rollback to sql-client 0.7 to get rid of the mmagic dependecy that brings problems on older systems
728
+
729
+ ### 1.4.0 (2016-12-02)
730
+ * (Apollon77) Add messages enableHistory/disableHistory
731
+ * (Apollon77) add support to log changes only if value differs a minimum value for numbers
732
+
733
+ ### 1.3.4 (2016-11)
734
+ * (Apollon77) Allow database names with '-' for MySQL
735
+
736
+ ### 1.3.3 (2016-11)
737
+ * (Apollon77) Update dependecies
738
+
739
+ ### 1.3.2 (2016-11-21)
740
+ * (bluefox) Fix insert of string with '
741
+
742
+ ### 1.3.0 (2016-10-29)
743
+ * (Apollon77) add option to re-log unchanged values to make it easier for visualization
744
+
745
+ ### 1.2.1 (2016-08-30)
746
+ * (bluefox) Fix selector for SQL objects
747
+
748
+ ### 1.2.0 (2016-08-30)
749
+ * (bluefox) сompatible only with new admin
750
+
751
+ ### 1.0.10 (2016-08-27)
752
+ * (bluefox) change name of object from "history" to "custom"
753
+
754
+ ### 1.0.10 (2016-07-31)
755
+ * (bluefox) fix multi requests if sqlite
756
+
757
+ ### 1.0.9 (2016-06-14)
758
+ * (bluefox) allow settings for parallel requests
759
+
760
+ ### 1.0.7 (2016-05-31)
761
+ * (bluefox) draw line to the end if ignore null
762
+
763
+ ### 1.0.6 (2016-05-30)
764
+ * (bluefox) allow setup DB name for mysql and mssql
765
+
766
+ ### 1.0.5 (2016-05-29)
767
+ * (bluefox) switch max and min with each other
768
+
769
+ ### 1.0.4 (2016-05-29)
770
+ * (bluefox) check retention of data if set "never"
771
+
772
+ ### 1.0.3 (2016-05-28)
773
+ * (bluefox) try to calculate old timestamps
774
+
775
+ ### 1.0.2 (2016-05-24)
776
+ * (bluefox) fix error with io-package
777
+
778
+ ### 1.0.1 (2016-05-24)
779
+ * (bluefox) fix error with SQLite
780
+
781
+ ### 1.0.0 (2016-05-20)
782
+ * (bluefox) change default aggregation name
783
+
784
+ ### 0.3.3 (2016-05-18)
785
+ * (bluefox) fix postgres
786
+
787
+ ### 0.3.2 (2016-05-13)
788
+ * (bluefox) queue select if IDs and FROMs queries for sqlite
789
+
790
+ ### 0.3.1 (2016-05-12)
791
+ * (bluefox) queue delete queries too for sqlite
792
+
793
+ ### 0.3.0 (2016-05-08)
794
+ * (bluefox) support of custom queries
795
+ * (bluefox) only one request simultaneously for sqlite
796
+ * (bluefox) add tests (primitive and only sql)
797
+
798
+ ### 0.2.0 (2016-04-30)
799
+ * (bluefox) support of milliseconds
800
+ * (bluefox) fix sqlite
801
+
802
+ ### 0.1.4 (2016-04-25)
803
+ * (bluefox) fix deletion of old entries
804
+
805
+ ### 0.1.3 (2016-03-08)
806
+ * (bluefox) do not print errors twice
807
+
808
+ ### 0.1.2 (2015-12-22)
809
+ * (bluefox) fix MS-SQL port settings
810
+
811
+ ### 0.1.1 (2015-12-19)
812
+ * (bluefox) fix error with double entries
813
+
814
+ ### 0.1.0 (2015-12-14)
815
+ * (bluefox) support of strings
816
+
817
+ ### 0.0.3 (2015-12-06)
818
+ * (smiling_Jack) Add demo Data ( todo: faster insert to db )
819
+ * (smiling_Jack) change aggregation (now same as history Adapter)
820
+ * (bluefox) bug fixing
821
+
822
+ ### 0.0.2 (2015-12-06)
823
+ * (bluefox) allow only 1 client for SQLite
824
+
825
+ ### 0.0.1 (2015-11-19)
826
+ * (bluefox) initial commit
827
+
828
+ ## License
829
+
830
+ The MIT License (MIT)
831
+
832
+ Copyright (c) 2015-2022 bluefox <dogafox@gmail.com>, Apollon77
833
+
834
+ Permission is hereby granted, free of charge, to any person obtaining a copy
835
+ of this software and associated documentation files (the "Software"), to deal
836
+ in the Software without restriction, including without limitation the rights
837
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
838
+ copies of the Software, and to permit persons to whom the Software is
839
+ furnished to do so, subject to the following conditions:
840
+
841
+ The above copyright notice and this permission notice shall be included in
842
+ all copies or substantial portions of the Software.
843
+
844
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
845
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
846
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
847
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
848
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
849
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
850
+ THE SOFTWARE.