iobroker.influxdb-prologger 1.0.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/LICENSE +21 -0
- package/README.md +205 -0
- package/admin/assets/index-BlcpU2eF.js +788 -0
- package/admin/index_m.html +17 -0
- package/admin/influxdb-prologger.png +0 -0
- package/build/lib/group-resolver.js +56 -0
- package/build/lib/group-resolver.js.map +7 -0
- package/build/lib/influx-client.js +164 -0
- package/build/lib/influx-client.js.map +7 -0
- package/build/lib/line-protocol.js +44 -0
- package/build/lib/line-protocol.js.map +7 -0
- package/build/main.js +268 -0
- package/build/main.js.map +7 -0
- package/io-package.json +130 -0
- package/package.json +95 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Simon Prosen <simon@prosen.dev>
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,205 @@
|
|
|
1
|
+

|
|
2
|
+
# ioBroker.influxdb-prologger
|
|
3
|
+
|
|
4
|
+
[](https://www.npmjs.com/package/iobroker.influxdb-prologger)
|
|
5
|
+
[](https://www.npmjs.com/package/iobroker.influxdb-prologger)
|
|
6
|
+

|
|
7
|
+

|
|
8
|
+
|
|
9
|
+
[](https://nodei.co/npm/iobroker.influxdb-prologger/)
|
|
10
|
+
|
|
11
|
+
**Tests:** 
|
|
12
|
+
|
|
13
|
+
## InfluxDB ProLogger adapter for ioBroker
|
|
14
|
+
|
|
15
|
+
Flexible InfluxDB v2 data logger with configurable logging groups, multiple buckets, cron-based and on-change triggers.
|
|
16
|
+
|
|
17
|
+
## Features
|
|
18
|
+
|
|
19
|
+
- **Multiple Logging Groups** - Define separate groups with different InfluxDB buckets and trigger types
|
|
20
|
+
- **Cron-based Logging** - Periodically collect and batch-write data points (e.g., every 15 minutes)
|
|
21
|
+
- **On-Change Logging** - Instantly write data to InfluxDB when a state value changes (spontaneous writes)
|
|
22
|
+
- **Multiple Buckets** - Each logging group can write to a different InfluxDB bucket
|
|
23
|
+
- **InfluxDB v2 Line Protocol** - Native HTTP API writes using InfluxDB line protocol
|
|
24
|
+
- **Retry with Exponential Backoff** - Configurable retry logic for failed writes
|
|
25
|
+
- **Encrypted Token Storage** - API token is stored encrypted in ioBroker's database
|
|
26
|
+
- **Connection Test** - Test your InfluxDB connection directly from the admin UI
|
|
27
|
+
- **Admin UI** - Fully configurable via the ioBroker admin interface (JSON Config)
|
|
28
|
+
|
|
29
|
+
## Requirements
|
|
30
|
+
|
|
31
|
+
- ioBroker with js-controller >= 6.0.11
|
|
32
|
+
- ioBroker Admin >= 7.0.23
|
|
33
|
+
- Node.js >= 20
|
|
34
|
+
- InfluxDB v2 instance
|
|
35
|
+
|
|
36
|
+
## Configuration
|
|
37
|
+
|
|
38
|
+
### 1. Connection Tab
|
|
39
|
+
|
|
40
|
+
Configure your InfluxDB v2 connection:
|
|
41
|
+
|
|
42
|
+
| Setting | Description |
|
|
43
|
+
|---------|-------------|
|
|
44
|
+
| Protocol | HTTP or HTTPS |
|
|
45
|
+
| Host | InfluxDB server hostname or IP (e.g., `192.168.10.191`) |
|
|
46
|
+
| Port | InfluxDB server port (default: `8086`) |
|
|
47
|
+
| Organization | Your InfluxDB organization name |
|
|
48
|
+
| API Token | InfluxDB API token (stored encrypted) |
|
|
49
|
+
|
|
50
|
+
Use the **Test Connection** button to verify connectivity.
|
|
51
|
+
|
|
52
|
+
### 2. Logging Groups Tab
|
|
53
|
+
|
|
54
|
+
Define one or more logging groups. Each group has:
|
|
55
|
+
|
|
56
|
+
| Setting | Description |
|
|
57
|
+
|---------|-------------|
|
|
58
|
+
| Enabled | Enable/disable this group |
|
|
59
|
+
| Group Name | Unique name for this group (referenced by data points) |
|
|
60
|
+
| Bucket | InfluxDB bucket to write to |
|
|
61
|
+
| Trigger Type | `Cron (periodic)` or `On Change` |
|
|
62
|
+
| Cron Expression | Cron schedule (only for cron groups), e.g., `*/15 * * * *` |
|
|
63
|
+
| Batch | Enable batch writing (for cron groups) |
|
|
64
|
+
|
|
65
|
+
**Example groups:**
|
|
66
|
+
|
|
67
|
+
| Name | Bucket | Trigger | Cron |
|
|
68
|
+
|------|--------|---------|------|
|
|
69
|
+
| Betriebsstunden | iobroker | Cron | `*/15 * * * *` |
|
|
70
|
+
| Spontanwerte | iob_spontanwerte | On Change | - |
|
|
71
|
+
|
|
72
|
+
### 3. Data Points Tab
|
|
73
|
+
|
|
74
|
+
Configure which ioBroker states to log. Each data point must reference a logging group:
|
|
75
|
+
|
|
76
|
+
| Setting | Description |
|
|
77
|
+
|---------|-------------|
|
|
78
|
+
| Enabled | Enable/disable this data point |
|
|
79
|
+
| Group | Name of the logging group (must match a group from Tab 2) |
|
|
80
|
+
| Object ID | ioBroker state to read (use the object browser) |
|
|
81
|
+
| Measurement | InfluxDB measurement name |
|
|
82
|
+
| Field | InfluxDB field name |
|
|
83
|
+
| Tags | InfluxDB tags in `key=value` format (e.g., `area=kitchen,floor=eg`) |
|
|
84
|
+
|
|
85
|
+
**Example data points:**
|
|
86
|
+
|
|
87
|
+
| Group | Object ID | Measurement | Field | Tags |
|
|
88
|
+
|-------|-----------|-------------|-------|------|
|
|
89
|
+
| Betriebsstunden | `0_userdata.0.Heizkessel` | betriebssekunden | zaehlerstand | `area=heizkessel` |
|
|
90
|
+
| Spontanwerte | `shelly.1.EM0.TotalActivePower` | energie | elektrische_leistung_haus | `area=gesamtenergiebedarf` |
|
|
91
|
+
|
|
92
|
+
### 4. Advanced Tab
|
|
93
|
+
|
|
94
|
+
| Setting | Description |
|
|
95
|
+
|---------|-------------|
|
|
96
|
+
| Write Timeout | HTTP request timeout in ms (default: 5000) |
|
|
97
|
+
| Retry on Error | Retry failed writes with exponential backoff |
|
|
98
|
+
| Max Retries | Maximum retry attempts (default: 3) |
|
|
99
|
+
| Debug Logging | Enable verbose debug logging |
|
|
100
|
+
|
|
101
|
+
## How It Works
|
|
102
|
+
|
|
103
|
+
### Cron Groups (Periodic Logging)
|
|
104
|
+
|
|
105
|
+
1. At each cron interval, the adapter reads all configured state values in the group
|
|
106
|
+
2. Values are formatted as InfluxDB line protocol
|
|
107
|
+
3. All lines are batch-written to InfluxDB in a single HTTP POST
|
|
108
|
+
|
|
109
|
+
### On-Change Groups (Spontaneous Logging)
|
|
110
|
+
|
|
111
|
+
1. The adapter subscribes to each data point's ioBroker state
|
|
112
|
+
2. When a state value changes, the new value is immediately written to InfluxDB
|
|
113
|
+
3. Each change triggers an individual HTTP POST
|
|
114
|
+
|
|
115
|
+
### InfluxDB Line Protocol
|
|
116
|
+
|
|
117
|
+
Data is written using the InfluxDB v2 line protocol format:
|
|
118
|
+
|
|
119
|
+
```
|
|
120
|
+
measurement,tag1=value1,tag2=value2 field=value
|
|
121
|
+
```
|
|
122
|
+
|
|
123
|
+
Example:
|
|
124
|
+
```
|
|
125
|
+
betriebssekunden,area=heizkessel zaehlerstand=12345.6
|
|
126
|
+
energie,area=gesamtenergiebedarf elektrische_leistung_haus=4521.3
|
|
127
|
+
```
|
|
128
|
+
|
|
129
|
+
## Migration from ioBroker Scripts
|
|
130
|
+
|
|
131
|
+
If you are currently using ioBroker JavaScript scripts for InfluxDB logging, you can migrate to this adapter:
|
|
132
|
+
|
|
133
|
+
1. Install the adapter
|
|
134
|
+
2. Configure your InfluxDB connection (same host, port, org, token)
|
|
135
|
+
3. Create logging groups matching your script setup:
|
|
136
|
+
- Scripts using `on({ id: ..., val: true })` with a trigger state -> Create a **Cron** group
|
|
137
|
+
- Scripts using `on({ id: objectId })` for each state -> Create an **On Change** group
|
|
138
|
+
4. Add all data points from your `loggingTemplate` arrays
|
|
139
|
+
5. Disable your old scripts
|
|
140
|
+
6. Verify data is flowing in InfluxDB
|
|
141
|
+
|
|
142
|
+
## Scripts in `package.json`
|
|
143
|
+
|
|
144
|
+
| Script name | Description |
|
|
145
|
+
|-------------|-------------|
|
|
146
|
+
| `build` | Compile the TypeScript sources |
|
|
147
|
+
| `watch` | Compile the TypeScript sources and watch for changes |
|
|
148
|
+
| `test:ts` | Execute the tests defined in `*.test.ts` files |
|
|
149
|
+
| `test:package` | Ensure `package.json` and `io-package.json` are valid |
|
|
150
|
+
| `test` | Perform a minimal test run on package files and your tests |
|
|
151
|
+
| `check` | Perform a type-check on your code (without compiling) |
|
|
152
|
+
| `lint` | Run ESLint to check code for formatting errors and potential bugs |
|
|
153
|
+
| `translate` | Translate texts in the adapter to all required languages |
|
|
154
|
+
| `release` | Create a new release |
|
|
155
|
+
|
|
156
|
+
## Changelog
|
|
157
|
+
<!--
|
|
158
|
+
Placeholder for the next version (at the beginning of the line):
|
|
159
|
+
### **WORK IN PROGRESS**
|
|
160
|
+
-->
|
|
161
|
+
### 1.0.0 (2026-03-21)
|
|
162
|
+
* (Simon Prosen) InfluxDB v2.x support via native HTTP API with token-based authentication
|
|
163
|
+
* (Simon Prosen) Dual-mode logging: cron-based periodic collection and on-change real-time writes
|
|
164
|
+
* (Simon Prosen) Multiple logging groups with independent bucket, trigger type, and cron schedule
|
|
165
|
+
* (Simon Prosen) Configurable data points with custom measurement names, field keys, and InfluxDB tags
|
|
166
|
+
* (Simon Prosen) InfluxDB line protocol formatting with proper type handling for strings, booleans, and numbers
|
|
167
|
+
* (Simon Prosen) Batch writing for cron groups combining all data points into a single HTTP request
|
|
168
|
+
* (Simon Prosen) Exponential backoff retry logic with smart classification (4xx no-retry, 429/5xx retry)
|
|
169
|
+
* (Simon Prosen) Configurable write timeout and retry attempts
|
|
170
|
+
* (Simon Prosen) Encrypted API token storage using ioBroker's native encryption
|
|
171
|
+
* (Simon Prosen) Connection health check on startup with `info.connection` state indicator
|
|
172
|
+
* (Simon Prosen) Admin UI with Connection, Logging Groups, Data Points, and Advanced tabs
|
|
173
|
+
* (Simon Prosen) Object browser for visual ioBroker state selection in admin UI
|
|
174
|
+
* (Simon Prosen) Connection test button for validating InfluxDB connectivity from admin UI
|
|
175
|
+
* (Simon Prosen) Cascading group rename updates across all referencing data points
|
|
176
|
+
* (Simon Prosen) Startup validation with warnings for missing or misconfigured groups and data points
|
|
177
|
+
* (Simon Prosen) Graceful shutdown with cron job cleanup and subscription removal
|
|
178
|
+
* (Simon Prosen) Debug logging mode for troubleshooting
|
|
179
|
+
* (Simon Prosen) English and German translations
|
|
180
|
+
|
|
181
|
+
### 0.0.1 (2026-03-20)
|
|
182
|
+
* (Simon Prosen) initial release
|
|
183
|
+
|
|
184
|
+
## License
|
|
185
|
+
MIT License
|
|
186
|
+
|
|
187
|
+
Copyright (c) 2026 Simon Prosen <simon@prosen.dev>
|
|
188
|
+
|
|
189
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
190
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
191
|
+
in the Software without restriction, including without limitation the rights
|
|
192
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
193
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
194
|
+
furnished to do so, subject to the following conditions:
|
|
195
|
+
|
|
196
|
+
The above copyright notice and this permission notice shall be included in all
|
|
197
|
+
copies or substantial portions of the Software.
|
|
198
|
+
|
|
199
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
200
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
201
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
202
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
203
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
204
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
205
|
+
SOFTWARE.
|