iobroker.acinfinity 0.7.1 → 0.7.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/io-package.json +14 -1
- package/lib/client.js +84 -54
- package/lib/constants.js +96 -108
- package/lib/creators/deviceCreator.js +97 -91
- package/lib/creators/portCreator.js +238 -225
- package/lib/creators/stateCreator.js +27 -21
- package/lib/dataModels.js +25 -20
- package/lib/handlers/deviceSettingsHandler.js +55 -38
- package/lib/handlers/portModeHandler.js +72 -71
- package/lib/handlers/portSettingsHandler.js +95 -68
- package/lib/stateManager.js +62 -42
- package/lib/updaters/deviceUpdater.js +133 -96
- package/lib/updaters/portUpdater.js +256 -207
- package/main.js +102 -77
- package/package.json +4 -4
|
@@ -3,13 +3,14 @@
|
|
|
3
3
|
* Verantwortlich für das Erstellen von Gerätestrukturen in ioBroker
|
|
4
4
|
*/
|
|
5
5
|
|
|
6
|
-
|
|
6
|
+
'use strict';
|
|
7
7
|
|
|
8
|
-
const { OUTSIDE_CLIMATE_OPTIONS } = require(
|
|
8
|
+
const { OUTSIDE_CLIMATE_OPTIONS } = require('../constants');
|
|
9
9
|
|
|
10
10
|
class DeviceCreator {
|
|
11
11
|
/**
|
|
12
12
|
* Erstellt einen neuen DeviceCreator
|
|
13
|
+
*
|
|
13
14
|
* @param {object} stateManager - Referenz zum StateManager
|
|
14
15
|
*/
|
|
15
16
|
constructor(stateManager) {
|
|
@@ -20,195 +21,200 @@ class DeviceCreator {
|
|
|
20
21
|
|
|
21
22
|
/**
|
|
22
23
|
* Erstellt ein Geräteobjekt in ioBroker
|
|
24
|
+
*
|
|
23
25
|
* @param {string} deviceId - Geräte-ID
|
|
24
26
|
* @param {string} deviceName - Gerätename
|
|
25
27
|
* @returns {Promise<void>}
|
|
26
28
|
*/
|
|
27
29
|
async createDeviceObject(deviceId, deviceName) {
|
|
28
30
|
await this.stateCreator.createDevice(`devices.${deviceId}`, deviceName, {
|
|
29
|
-
id: deviceId
|
|
31
|
+
id: deviceId,
|
|
30
32
|
});
|
|
31
33
|
}
|
|
32
34
|
|
|
33
35
|
/**
|
|
34
36
|
* Erstellt Infokanal für ein Gerät
|
|
37
|
+
*
|
|
35
38
|
* @param {string} deviceId - Geräte-ID
|
|
36
39
|
* @returns {Promise<void>}
|
|
37
40
|
*/
|
|
38
41
|
async createInfoChannel(deviceId) {
|
|
39
42
|
// Erstelle Info-Kanal
|
|
40
|
-
await this.stateCreator.createChannel(`devices.${deviceId}.info`,
|
|
41
|
-
|
|
43
|
+
await this.stateCreator.createChannel(`devices.${deviceId}.info`, 'Geräteinformationen');
|
|
44
|
+
|
|
42
45
|
// Erstelle Info-States
|
|
43
46
|
await this.stateCreator.createMultipleStates([
|
|
44
47
|
{
|
|
45
48
|
id: `devices.${deviceId}.info.name`,
|
|
46
|
-
name:
|
|
47
|
-
type:
|
|
48
|
-
role:
|
|
49
|
+
name: 'Name',
|
|
50
|
+
type: 'string',
|
|
51
|
+
role: 'text',
|
|
49
52
|
},
|
|
50
53
|
{
|
|
51
54
|
id: `devices.${deviceId}.info.online`,
|
|
52
|
-
name:
|
|
53
|
-
type:
|
|
54
|
-
role:
|
|
55
|
+
name: 'Online',
|
|
56
|
+
type: 'boolean',
|
|
57
|
+
role: 'indicator.connected',
|
|
55
58
|
},
|
|
56
59
|
{
|
|
57
60
|
id: `devices.${deviceId}.info.mac`,
|
|
58
|
-
name:
|
|
59
|
-
type:
|
|
60
|
-
role:
|
|
61
|
+
name: 'MAC-Adresse',
|
|
62
|
+
type: 'string',
|
|
63
|
+
role: 'text',
|
|
61
64
|
},
|
|
62
65
|
{
|
|
63
66
|
id: `devices.${deviceId}.info.firmware`,
|
|
64
|
-
name:
|
|
65
|
-
type:
|
|
66
|
-
role:
|
|
67
|
+
name: 'Firmware-Version',
|
|
68
|
+
type: 'string',
|
|
69
|
+
role: 'text',
|
|
67
70
|
},
|
|
68
71
|
{
|
|
69
72
|
id: `devices.${deviceId}.info.hardware`,
|
|
70
|
-
name:
|
|
71
|
-
type:
|
|
72
|
-
role:
|
|
73
|
+
name: 'Hardware-Version',
|
|
74
|
+
type: 'string',
|
|
75
|
+
role: 'text',
|
|
73
76
|
},
|
|
74
77
|
{
|
|
75
78
|
id: `devices.${deviceId}.info.deviceType`,
|
|
76
|
-
name:
|
|
77
|
-
type:
|
|
78
|
-
role:
|
|
79
|
-
}
|
|
79
|
+
name: 'Gerätetyp',
|
|
80
|
+
type: 'number',
|
|
81
|
+
role: 'value',
|
|
82
|
+
},
|
|
80
83
|
]);
|
|
81
84
|
}
|
|
82
85
|
|
|
83
86
|
/**
|
|
84
87
|
* Erstellt Sensorkanal für ein Gerät
|
|
88
|
+
*
|
|
85
89
|
* @param {string} deviceId - Geräte-ID
|
|
86
90
|
* @returns {Promise<void>}
|
|
87
91
|
*/
|
|
88
92
|
async createSensorChannel(deviceId) {
|
|
89
93
|
// Erstelle Sensors-Kanal
|
|
90
|
-
await this.stateCreator.createChannel(`devices.${deviceId}.sensors`,
|
|
91
|
-
|
|
94
|
+
await this.stateCreator.createChannel(`devices.${deviceId}.sensors`, 'Sensoren');
|
|
95
|
+
|
|
92
96
|
// Erstelle Sensor-States
|
|
93
97
|
await this.stateCreator.createMultipleStates([
|
|
94
98
|
{
|
|
95
99
|
id: `devices.${deviceId}.sensors.temperature`,
|
|
96
|
-
name:
|
|
97
|
-
type:
|
|
98
|
-
role:
|
|
99
|
-
unit:
|
|
100
|
+
name: 'Temperatur',
|
|
101
|
+
type: 'number',
|
|
102
|
+
role: 'value.temperature',
|
|
103
|
+
unit: '°C',
|
|
100
104
|
},
|
|
101
105
|
{
|
|
102
106
|
id: `devices.${deviceId}.sensors.humidity`,
|
|
103
|
-
name:
|
|
104
|
-
type:
|
|
105
|
-
role:
|
|
106
|
-
unit:
|
|
107
|
+
name: 'Luftfeuchtigkeit',
|
|
108
|
+
type: 'number',
|
|
109
|
+
role: 'value.humidity',
|
|
110
|
+
unit: '%',
|
|
107
111
|
},
|
|
108
112
|
{
|
|
109
113
|
id: `devices.${deviceId}.sensors.vpd`,
|
|
110
|
-
name:
|
|
111
|
-
type:
|
|
112
|
-
role:
|
|
113
|
-
unit:
|
|
114
|
+
name: 'Sättigungsdefizit (VPD)',
|
|
115
|
+
type: 'number',
|
|
116
|
+
role: 'value',
|
|
117
|
+
unit: 'kPa',
|
|
114
118
|
},
|
|
115
119
|
{
|
|
116
120
|
id: `devices.${deviceId}.sensors.co2`,
|
|
117
|
-
name:
|
|
118
|
-
type:
|
|
119
|
-
role:
|
|
120
|
-
unit:
|
|
121
|
+
name: 'CO₂',
|
|
122
|
+
type: 'number',
|
|
123
|
+
role: 'value.co2',
|
|
124
|
+
unit: 'ppm',
|
|
121
125
|
},
|
|
122
126
|
{
|
|
123
127
|
id: `devices.${deviceId}.sensors.soilMoisture`,
|
|
124
|
-
name:
|
|
125
|
-
type:
|
|
126
|
-
role:
|
|
127
|
-
unit:
|
|
128
|
+
name: 'Bodenfeuchtigkeit',
|
|
129
|
+
type: 'number',
|
|
130
|
+
role: 'value.humidity',
|
|
131
|
+
unit: '%',
|
|
128
132
|
},
|
|
129
133
|
{
|
|
130
134
|
id: `devices.${deviceId}.sensors.waterLevel`,
|
|
131
|
-
name:
|
|
132
|
-
type:
|
|
133
|
-
role:
|
|
134
|
-
unit:
|
|
135
|
+
name: 'Wasserstand',
|
|
136
|
+
type: 'number',
|
|
137
|
+
role: 'value',
|
|
138
|
+
unit: '%',
|
|
135
139
|
},
|
|
136
140
|
{
|
|
137
141
|
id: `devices.${deviceId}.sensors.pluggedIn`,
|
|
138
|
-
name:
|
|
139
|
-
type:
|
|
140
|
-
role:
|
|
141
|
-
}
|
|
142
|
+
name: 'Angeschlossen',
|
|
143
|
+
type: 'boolean',
|
|
144
|
+
role: 'indicator',
|
|
145
|
+
},
|
|
142
146
|
]);
|
|
143
|
-
|
|
147
|
+
|
|
144
148
|
// Erstelle Einstellungen-Kanal
|
|
145
149
|
await this.createSettingsChannel(deviceId);
|
|
146
150
|
}
|
|
147
|
-
|
|
151
|
+
|
|
148
152
|
/**
|
|
149
153
|
* Erstellt Einstellungskanal für ein Gerät
|
|
154
|
+
*
|
|
150
155
|
* @param {string} deviceId - Geräte-ID
|
|
151
156
|
* @returns {Promise<void>}
|
|
152
157
|
*/
|
|
153
158
|
async createSettingsChannel(deviceId) {
|
|
154
159
|
// Erstelle Settings-Kanal
|
|
155
|
-
await this.stateCreator.createChannel(`devices.${deviceId}.settings`,
|
|
156
|
-
|
|
160
|
+
await this.stateCreator.createChannel(`devices.${deviceId}.settings`, 'Einstellungen');
|
|
161
|
+
|
|
157
162
|
// Erstelle Einstellungs-States
|
|
158
163
|
await this.stateCreator.createMultipleStates([
|
|
159
164
|
{
|
|
160
165
|
id: `devices.${deviceId}.settings.temperatureUnit`,
|
|
161
|
-
name:
|
|
162
|
-
type:
|
|
163
|
-
role:
|
|
166
|
+
name: 'Temperatureinheit',
|
|
167
|
+
type: 'string',
|
|
168
|
+
role: 'text',
|
|
164
169
|
write: false,
|
|
165
|
-
states: [
|
|
170
|
+
states: ['C', 'F'],
|
|
166
171
|
},
|
|
167
172
|
{
|
|
168
173
|
id: `devices.${deviceId}.settings.temperatureCalibration`,
|
|
169
|
-
name:
|
|
170
|
-
type:
|
|
171
|
-
role:
|
|
172
|
-
unit:
|
|
173
|
-
write: true
|
|
174
|
+
name: 'Temperaturkalibrierung',
|
|
175
|
+
type: 'number',
|
|
176
|
+
role: 'level',
|
|
177
|
+
unit: '°',
|
|
178
|
+
write: true,
|
|
174
179
|
},
|
|
175
180
|
{
|
|
176
181
|
id: `devices.${deviceId}.settings.humidityCalibration`,
|
|
177
|
-
name:
|
|
178
|
-
type:
|
|
179
|
-
role:
|
|
180
|
-
unit:
|
|
181
|
-
write: true
|
|
182
|
+
name: 'Feuchtigkeitskalibrierung',
|
|
183
|
+
type: 'number',
|
|
184
|
+
role: 'level',
|
|
185
|
+
unit: '%',
|
|
186
|
+
write: true,
|
|
182
187
|
},
|
|
183
188
|
{
|
|
184
189
|
id: `devices.${deviceId}.settings.vpdLeafTemperatureOffset`,
|
|
185
|
-
name:
|
|
186
|
-
type:
|
|
187
|
-
role:
|
|
188
|
-
unit:
|
|
189
|
-
write: true
|
|
190
|
+
name: 'VPD Blatttemperatur-Offset',
|
|
191
|
+
type: 'number',
|
|
192
|
+
role: 'level',
|
|
193
|
+
unit: '°',
|
|
194
|
+
write: true,
|
|
190
195
|
},
|
|
191
196
|
{
|
|
192
197
|
id: `devices.${deviceId}.settings.outsideTemperature`,
|
|
193
|
-
name:
|
|
194
|
-
type:
|
|
195
|
-
role:
|
|
198
|
+
name: 'Außentemperatur',
|
|
199
|
+
type: 'string',
|
|
200
|
+
role: 'text',
|
|
196
201
|
write: true,
|
|
197
|
-
states: OUTSIDE_CLIMATE_OPTIONS
|
|
202
|
+
states: OUTSIDE_CLIMATE_OPTIONS,
|
|
198
203
|
},
|
|
199
204
|
{
|
|
200
205
|
id: `devices.${deviceId}.settings.outsideHumidity`,
|
|
201
|
-
name:
|
|
202
|
-
type:
|
|
203
|
-
role:
|
|
206
|
+
name: 'Außenfeuchtigkeit',
|
|
207
|
+
type: 'string',
|
|
208
|
+
role: 'text',
|
|
204
209
|
write: true,
|
|
205
|
-
states: OUTSIDE_CLIMATE_OPTIONS
|
|
206
|
-
}
|
|
210
|
+
states: OUTSIDE_CLIMATE_OPTIONS,
|
|
211
|
+
},
|
|
207
212
|
]);
|
|
208
213
|
}
|
|
209
|
-
|
|
214
|
+
|
|
210
215
|
/**
|
|
211
216
|
* Erstellt eine vollständige Gerätestruktur mit allen notwendigen Unterkanälen
|
|
217
|
+
*
|
|
212
218
|
* @param {string} deviceId - Geräte-ID
|
|
213
219
|
* @param {string} deviceName - Gerätename
|
|
214
220
|
* @returns {Promise<void>}
|
|
@@ -216,14 +222,14 @@ class DeviceCreator {
|
|
|
216
222
|
async createCompleteDeviceStructure(deviceId, deviceName) {
|
|
217
223
|
// Erstelle das Hauptgeräteobjekt
|
|
218
224
|
await this.createDeviceObject(deviceId, deviceName);
|
|
219
|
-
|
|
225
|
+
|
|
220
226
|
// Erstelle alle Unterkanäle
|
|
221
227
|
await this.createInfoChannel(deviceId);
|
|
222
228
|
await this.createSensorChannel(deviceId);
|
|
223
|
-
|
|
229
|
+
|
|
224
230
|
// Erstelle Ports-Ordner
|
|
225
|
-
await this.stateCreator.createFolder(`devices.${deviceId}.ports`,
|
|
231
|
+
await this.stateCreator.createFolder(`devices.${deviceId}.ports`, 'Ports');
|
|
226
232
|
}
|
|
227
233
|
}
|
|
228
234
|
|
|
229
|
-
module.exports = DeviceCreator;
|
|
235
|
+
module.exports = DeviceCreator;
|