@jakobgoerke/ac-infinity-client 0.2.1 → 0.3.1
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 +259 -1
- package/build/src/AcInfinityClient.d.ts +20 -6
- package/build/src/AcInfinityClient.d.ts.map +1 -1
- package/build/src/AcInfinityClient.js +58 -14
- package/build/src/errors/index.d.ts +6 -1
- package/build/src/errors/index.d.ts.map +1 -1
- package/build/src/errors/index.js +14 -1
- package/build/src/index.d.ts +3 -0
- package/build/src/index.d.ts.map +1 -1
- package/build/src/index.js +8 -0
- package/build/src/types/Controller.d.ts +208 -17
- package/build/src/types/Controller.d.ts.map +1 -1
- package/build/src/types/Controller.js +115 -5
- package/build/src/types/Device.d.ts +401 -4
- package/build/src/types/Device.d.ts.map +1 -1
- package/build/src/types/Device.js +216 -5
- package/build/src/types/index.d.ts +4 -4
- package/build/src/types/index.d.ts.map +1 -1
- package/build/src/types/index.js +6 -1
- package/package.json +15 -11
|
@@ -1,61 +1,155 @@
|
|
|
1
1
|
import { z } from 'zod';
|
|
2
2
|
import { DeviceMode, DeviceType } from './Device';
|
|
3
3
|
export declare enum ControllerDeviceType {
|
|
4
|
+
CONTROLLER_67 = 1,
|
|
5
|
+
CONTROLLER_69 = 7,
|
|
6
|
+
CONTROLLER_69_WIFI = 8,
|
|
4
7
|
UIS_CONTROLLER_69_PRO = 11,
|
|
5
|
-
UIS_CONTROLLER_69_PRO_PLUS =
|
|
8
|
+
UIS_CONTROLLER_69_PRO_PLUS = 18,
|
|
9
|
+
UIS_CONTROLLER_AI_PLUS = 20
|
|
6
10
|
}
|
|
11
|
+
export declare enum SensorType {
|
|
12
|
+
TEMPERATURE_F = 0,
|
|
13
|
+
TEMPERATURE_C = 1,
|
|
14
|
+
HUMIDITY = 2,
|
|
15
|
+
VPD = 3,
|
|
16
|
+
ZONE_TEMPERATURE_F = 4,
|
|
17
|
+
ZONE_TEMPERATURE_C = 5,
|
|
18
|
+
ZONE_HUMIDITY = 6,
|
|
19
|
+
ZONE_VPD = 7,
|
|
20
|
+
LEAF_TEMPERATURE_F = 8,
|
|
21
|
+
LEAF_TEMPERATURE_C = 9,
|
|
22
|
+
SOIL_MOISTURE = 10,
|
|
23
|
+
CO2 = 11,
|
|
24
|
+
LIGHT = 12,
|
|
25
|
+
PH = 13,
|
|
26
|
+
EC_US = 14,
|
|
27
|
+
EC_MS = 15,
|
|
28
|
+
TDS_PPM = 16,
|
|
29
|
+
TDS_PPT = 17,
|
|
30
|
+
WATER_TEMPERATURE_F = 18,
|
|
31
|
+
WATER_TEMPERATURE_C = 19,
|
|
32
|
+
WATER_LEVEL = 20
|
|
33
|
+
}
|
|
34
|
+
export declare const ControllerSensorSchema: z.ZodPipe<z.ZodObject<{
|
|
35
|
+
accessPort: z.ZodNumber;
|
|
36
|
+
sensorType: z.ZodNumber;
|
|
37
|
+
sensorPrecision: z.ZodNumber;
|
|
38
|
+
sensorData: z.ZodNumber;
|
|
39
|
+
}, z.core.$strip>, z.ZodTransform<{
|
|
40
|
+
port: number;
|
|
41
|
+
type: SensorType;
|
|
42
|
+
value: number | null;
|
|
43
|
+
}, {
|
|
44
|
+
accessPort: number;
|
|
45
|
+
sensorType: number;
|
|
46
|
+
sensorPrecision: number;
|
|
47
|
+
sensorData: number;
|
|
48
|
+
}>>;
|
|
7
49
|
export declare const ControllerPortSchema: z.ZodPipe<z.ZodObject<{
|
|
8
50
|
speak: z.ZodNumber;
|
|
9
51
|
port: z.ZodNumber;
|
|
10
52
|
curMode: z.ZodEnum<typeof DeviceMode>;
|
|
11
|
-
loadType: z.
|
|
53
|
+
loadType: z.ZodNumber;
|
|
12
54
|
portName: z.ZodString;
|
|
55
|
+
portResistance: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
|
|
56
|
+
online: z.ZodCoercedBoolean<unknown>;
|
|
57
|
+
remainTime: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
|
|
13
58
|
}, z.core.$strip>, z.ZodTransform<{
|
|
14
59
|
port: number;
|
|
15
60
|
currentLevel: number;
|
|
16
61
|
currentMode: DeviceMode;
|
|
62
|
+
/** NONE when no type is assigned, the controller schema then recognizes it by resistance */
|
|
17
63
|
deviceType: DeviceType;
|
|
18
64
|
deviceName: string;
|
|
65
|
+
/** id resistor of the plugged in device, in ohms */
|
|
66
|
+
resistance: number | null;
|
|
67
|
+
online: boolean;
|
|
68
|
+
/** seconds left until the current timer, cycle or schedule step switches */
|
|
69
|
+
remainingTime: number | null;
|
|
19
70
|
}, {
|
|
20
71
|
speak: number;
|
|
21
72
|
port: number;
|
|
22
73
|
curMode: DeviceMode;
|
|
23
|
-
loadType:
|
|
74
|
+
loadType: number;
|
|
24
75
|
portName: string;
|
|
76
|
+
online: boolean;
|
|
77
|
+
portResistance?: number | null | undefined;
|
|
78
|
+
remainTime?: number | null | undefined;
|
|
25
79
|
}>>;
|
|
26
80
|
export declare const ControllerDeviceInfoSchema: z.ZodPipe<z.ZodObject<{
|
|
27
81
|
temperature: z.ZodNumber;
|
|
82
|
+
temperatureF: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
|
|
28
83
|
humidity: z.ZodNumber;
|
|
29
84
|
vpdnums: z.ZodNumber;
|
|
30
85
|
ports: z.ZodArray<z.ZodPipe<z.ZodObject<{
|
|
31
86
|
speak: z.ZodNumber;
|
|
32
87
|
port: z.ZodNumber;
|
|
33
88
|
curMode: z.ZodEnum<typeof DeviceMode>;
|
|
34
|
-
loadType: z.
|
|
89
|
+
loadType: z.ZodNumber;
|
|
35
90
|
portName: z.ZodString;
|
|
91
|
+
portResistance: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
|
|
92
|
+
online: z.ZodCoercedBoolean<unknown>;
|
|
93
|
+
remainTime: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
|
|
36
94
|
}, z.core.$strip>, z.ZodTransform<{
|
|
37
95
|
port: number;
|
|
38
96
|
currentLevel: number;
|
|
39
97
|
currentMode: DeviceMode;
|
|
98
|
+
/** NONE when no type is assigned, the controller schema then recognizes it by resistance */
|
|
40
99
|
deviceType: DeviceType;
|
|
41
100
|
deviceName: string;
|
|
101
|
+
/** id resistor of the plugged in device, in ohms */
|
|
102
|
+
resistance: number | null;
|
|
103
|
+
online: boolean;
|
|
104
|
+
/** seconds left until the current timer, cycle or schedule step switches */
|
|
105
|
+
remainingTime: number | null;
|
|
42
106
|
}, {
|
|
43
107
|
speak: number;
|
|
44
108
|
port: number;
|
|
45
109
|
curMode: DeviceMode;
|
|
46
|
-
loadType:
|
|
110
|
+
loadType: number;
|
|
47
111
|
portName: string;
|
|
112
|
+
online: boolean;
|
|
113
|
+
portResistance?: number | null | undefined;
|
|
114
|
+
remainTime?: number | null | undefined;
|
|
48
115
|
}>>>;
|
|
116
|
+
sensors: z.ZodOptional<z.ZodNullable<z.ZodArray<z.ZodPipe<z.ZodObject<{
|
|
117
|
+
accessPort: z.ZodNumber;
|
|
118
|
+
sensorType: z.ZodNumber;
|
|
119
|
+
sensorPrecision: z.ZodNumber;
|
|
120
|
+
sensorData: z.ZodNumber;
|
|
121
|
+
}, z.core.$strip>, z.ZodTransform<{
|
|
122
|
+
port: number;
|
|
123
|
+
type: SensorType;
|
|
124
|
+
value: number | null;
|
|
125
|
+
}, {
|
|
126
|
+
accessPort: number;
|
|
127
|
+
sensorType: number;
|
|
128
|
+
sensorPrecision: number;
|
|
129
|
+
sensorData: number;
|
|
130
|
+
}>>>>>;
|
|
49
131
|
}, z.core.$strip>, z.ZodTransform<{
|
|
50
132
|
temperature: number;
|
|
133
|
+
temperatureF: number | null;
|
|
51
134
|
humidity: number;
|
|
52
135
|
vpd: number;
|
|
53
136
|
ports: {
|
|
54
137
|
port: number;
|
|
55
138
|
currentLevel: number;
|
|
56
139
|
currentMode: DeviceMode;
|
|
140
|
+
/** NONE when no type is assigned, the controller schema then recognizes it by resistance */
|
|
57
141
|
deviceType: DeviceType;
|
|
58
142
|
deviceName: string;
|
|
143
|
+
/** id resistor of the plugged in device, in ohms */
|
|
144
|
+
resistance: number | null;
|
|
145
|
+
online: boolean;
|
|
146
|
+
/** seconds left until the current timer, cycle or schedule step switches */
|
|
147
|
+
remainingTime: number | null;
|
|
148
|
+
}[];
|
|
149
|
+
sensors: {
|
|
150
|
+
port: number;
|
|
151
|
+
type: SensorType;
|
|
152
|
+
value: number | null;
|
|
59
153
|
}[];
|
|
60
154
|
}, {
|
|
61
155
|
temperature: number;
|
|
@@ -65,9 +159,21 @@ export declare const ControllerDeviceInfoSchema: z.ZodPipe<z.ZodObject<{
|
|
|
65
159
|
port: number;
|
|
66
160
|
currentLevel: number;
|
|
67
161
|
currentMode: DeviceMode;
|
|
162
|
+
/** NONE when no type is assigned, the controller schema then recognizes it by resistance */
|
|
68
163
|
deviceType: DeviceType;
|
|
69
164
|
deviceName: string;
|
|
165
|
+
/** id resistor of the plugged in device, in ohms */
|
|
166
|
+
resistance: number | null;
|
|
167
|
+
online: boolean;
|
|
168
|
+
/** seconds left until the current timer, cycle or schedule step switches */
|
|
169
|
+
remainingTime: number | null;
|
|
70
170
|
}[];
|
|
171
|
+
temperatureF?: number | null | undefined;
|
|
172
|
+
sensors?: {
|
|
173
|
+
port: number;
|
|
174
|
+
type: SensorType;
|
|
175
|
+
value: number | null;
|
|
176
|
+
}[] | null | undefined;
|
|
71
177
|
}>>;
|
|
72
178
|
export declare const ControllerSchema: z.ZodPipe<z.ZodObject<{
|
|
73
179
|
devId: z.ZodString;
|
|
@@ -76,42 +182,85 @@ export declare const ControllerSchema: z.ZodPipe<z.ZodObject<{
|
|
|
76
182
|
devType: z.ZodEnum<typeof ControllerDeviceType>;
|
|
77
183
|
devPortCount: z.ZodNumber;
|
|
78
184
|
devVersion: z.ZodNumber;
|
|
185
|
+
devMacAddr: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
186
|
+
zoneId: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
187
|
+
wifiName: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
79
188
|
online: z.ZodCoercedBoolean<unknown>;
|
|
80
189
|
firmwareVersion: z.ZodString;
|
|
81
190
|
hardwareVersion: z.ZodString;
|
|
82
191
|
deviceInfo: z.ZodPipe<z.ZodObject<{
|
|
83
192
|
temperature: z.ZodNumber;
|
|
193
|
+
temperatureF: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
|
|
84
194
|
humidity: z.ZodNumber;
|
|
85
195
|
vpdnums: z.ZodNumber;
|
|
86
196
|
ports: z.ZodArray<z.ZodPipe<z.ZodObject<{
|
|
87
197
|
speak: z.ZodNumber;
|
|
88
198
|
port: z.ZodNumber;
|
|
89
199
|
curMode: z.ZodEnum<typeof DeviceMode>;
|
|
90
|
-
loadType: z.
|
|
200
|
+
loadType: z.ZodNumber;
|
|
91
201
|
portName: z.ZodString;
|
|
202
|
+
portResistance: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
|
|
203
|
+
online: z.ZodCoercedBoolean<unknown>;
|
|
204
|
+
remainTime: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
|
|
92
205
|
}, z.core.$strip>, z.ZodTransform<{
|
|
93
206
|
port: number;
|
|
94
207
|
currentLevel: number;
|
|
95
208
|
currentMode: DeviceMode;
|
|
209
|
+
/** NONE when no type is assigned, the controller schema then recognizes it by resistance */
|
|
96
210
|
deviceType: DeviceType;
|
|
97
211
|
deviceName: string;
|
|
212
|
+
/** id resistor of the plugged in device, in ohms */
|
|
213
|
+
resistance: number | null;
|
|
214
|
+
online: boolean;
|
|
215
|
+
/** seconds left until the current timer, cycle or schedule step switches */
|
|
216
|
+
remainingTime: number | null;
|
|
98
217
|
}, {
|
|
99
218
|
speak: number;
|
|
100
219
|
port: number;
|
|
101
220
|
curMode: DeviceMode;
|
|
102
|
-
loadType:
|
|
221
|
+
loadType: number;
|
|
103
222
|
portName: string;
|
|
223
|
+
online: boolean;
|
|
224
|
+
portResistance?: number | null | undefined;
|
|
225
|
+
remainTime?: number | null | undefined;
|
|
104
226
|
}>>>;
|
|
227
|
+
sensors: z.ZodOptional<z.ZodNullable<z.ZodArray<z.ZodPipe<z.ZodObject<{
|
|
228
|
+
accessPort: z.ZodNumber;
|
|
229
|
+
sensorType: z.ZodNumber;
|
|
230
|
+
sensorPrecision: z.ZodNumber;
|
|
231
|
+
sensorData: z.ZodNumber;
|
|
232
|
+
}, z.core.$strip>, z.ZodTransform<{
|
|
233
|
+
port: number;
|
|
234
|
+
type: SensorType;
|
|
235
|
+
value: number | null;
|
|
236
|
+
}, {
|
|
237
|
+
accessPort: number;
|
|
238
|
+
sensorType: number;
|
|
239
|
+
sensorPrecision: number;
|
|
240
|
+
sensorData: number;
|
|
241
|
+
}>>>>>;
|
|
105
242
|
}, z.core.$strip>, z.ZodTransform<{
|
|
106
243
|
temperature: number;
|
|
244
|
+
temperatureF: number | null;
|
|
107
245
|
humidity: number;
|
|
108
246
|
vpd: number;
|
|
109
247
|
ports: {
|
|
110
248
|
port: number;
|
|
111
249
|
currentLevel: number;
|
|
112
250
|
currentMode: DeviceMode;
|
|
251
|
+
/** NONE when no type is assigned, the controller schema then recognizes it by resistance */
|
|
113
252
|
deviceType: DeviceType;
|
|
114
253
|
deviceName: string;
|
|
254
|
+
/** id resistor of the plugged in device, in ohms */
|
|
255
|
+
resistance: number | null;
|
|
256
|
+
online: boolean;
|
|
257
|
+
/** seconds left until the current timer, cycle or schedule step switches */
|
|
258
|
+
remainingTime: number | null;
|
|
259
|
+
}[];
|
|
260
|
+
sensors: {
|
|
261
|
+
port: number;
|
|
262
|
+
type: SensorType;
|
|
263
|
+
value: number | null;
|
|
115
264
|
}[];
|
|
116
265
|
}, {
|
|
117
266
|
temperature: number;
|
|
@@ -121,32 +270,58 @@ export declare const ControllerSchema: z.ZodPipe<z.ZodObject<{
|
|
|
121
270
|
port: number;
|
|
122
271
|
currentLevel: number;
|
|
123
272
|
currentMode: DeviceMode;
|
|
273
|
+
/** NONE when no type is assigned, the controller schema then recognizes it by resistance */
|
|
124
274
|
deviceType: DeviceType;
|
|
125
275
|
deviceName: string;
|
|
276
|
+
/** id resistor of the plugged in device, in ohms */
|
|
277
|
+
resistance: number | null;
|
|
278
|
+
online: boolean;
|
|
279
|
+
/** seconds left until the current timer, cycle or schedule step switches */
|
|
280
|
+
remainingTime: number | null;
|
|
126
281
|
}[];
|
|
282
|
+
temperatureF?: number | null | undefined;
|
|
283
|
+
sensors?: {
|
|
284
|
+
port: number;
|
|
285
|
+
type: SensorType;
|
|
286
|
+
value: number | null;
|
|
287
|
+
}[] | null | undefined;
|
|
127
288
|
}>>;
|
|
128
289
|
}, z.core.$strip>, z.ZodTransform<{
|
|
129
290
|
online: boolean;
|
|
130
291
|
firmwareVersion: string;
|
|
131
292
|
hardwareVersion: string;
|
|
293
|
+
id: string;
|
|
294
|
+
code: string;
|
|
295
|
+
name: string;
|
|
296
|
+
type: ControllerDeviceType;
|
|
297
|
+
totalPorts: number;
|
|
298
|
+
version: number;
|
|
299
|
+
macAddress: string | null;
|
|
300
|
+
timeZone: string | null;
|
|
301
|
+
wifiName: string | null;
|
|
132
302
|
deviceInfo: {
|
|
133
|
-
temperature: number;
|
|
134
|
-
humidity: number;
|
|
135
|
-
vpd: number;
|
|
136
303
|
ports: {
|
|
304
|
+
deviceType: DeviceType;
|
|
137
305
|
port: number;
|
|
138
306
|
currentLevel: number;
|
|
139
307
|
currentMode: DeviceMode;
|
|
140
|
-
deviceType: DeviceType;
|
|
141
308
|
deviceName: string;
|
|
309
|
+
/** id resistor of the plugged in device, in ohms */
|
|
310
|
+
resistance: number | null;
|
|
311
|
+
online: boolean;
|
|
312
|
+
/** seconds left until the current timer, cycle or schedule step switches */
|
|
313
|
+
remainingTime: number | null;
|
|
314
|
+
}[];
|
|
315
|
+
temperature: number;
|
|
316
|
+
temperatureF: number | null;
|
|
317
|
+
humidity: number;
|
|
318
|
+
vpd: number;
|
|
319
|
+
sensors: {
|
|
320
|
+
port: number;
|
|
321
|
+
type: SensorType;
|
|
322
|
+
value: number | null;
|
|
142
323
|
}[];
|
|
143
324
|
};
|
|
144
|
-
id: string;
|
|
145
|
-
code: string;
|
|
146
|
-
name: string;
|
|
147
|
-
type: ControllerDeviceType;
|
|
148
|
-
totalPorts: number;
|
|
149
|
-
version: number;
|
|
150
325
|
}, {
|
|
151
326
|
devId: string;
|
|
152
327
|
devCode: string;
|
|
@@ -159,17 +334,33 @@ export declare const ControllerSchema: z.ZodPipe<z.ZodObject<{
|
|
|
159
334
|
hardwareVersion: string;
|
|
160
335
|
deviceInfo: {
|
|
161
336
|
temperature: number;
|
|
337
|
+
temperatureF: number | null;
|
|
162
338
|
humidity: number;
|
|
163
339
|
vpd: number;
|
|
164
340
|
ports: {
|
|
165
341
|
port: number;
|
|
166
342
|
currentLevel: number;
|
|
167
343
|
currentMode: DeviceMode;
|
|
344
|
+
/** NONE when no type is assigned, the controller schema then recognizes it by resistance */
|
|
168
345
|
deviceType: DeviceType;
|
|
169
346
|
deviceName: string;
|
|
347
|
+
/** id resistor of the plugged in device, in ohms */
|
|
348
|
+
resistance: number | null;
|
|
349
|
+
online: boolean;
|
|
350
|
+
/** seconds left until the current timer, cycle or schedule step switches */
|
|
351
|
+
remainingTime: number | null;
|
|
352
|
+
}[];
|
|
353
|
+
sensors: {
|
|
354
|
+
port: number;
|
|
355
|
+
type: SensorType;
|
|
356
|
+
value: number | null;
|
|
170
357
|
}[];
|
|
171
358
|
};
|
|
359
|
+
devMacAddr?: string | null | undefined;
|
|
360
|
+
zoneId?: string | null | undefined;
|
|
361
|
+
wifiName?: string | null | undefined;
|
|
172
362
|
}>>;
|
|
363
|
+
export type ControllerSensor = z.infer<typeof ControllerSensorSchema>;
|
|
173
364
|
export type ControllerPort = z.infer<typeof ControllerPortSchema>;
|
|
174
365
|
export type ControllerDeviceInfo = z.infer<typeof ControllerDeviceInfoSchema>;
|
|
175
366
|
export type Controller = z.infer<typeof ControllerSchema>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Controller.d.ts","sourceRoot":"","sources":["../../../src/types/Controller.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,OAAO,EAAE,UAAU,EAAE,UAAU,EAAE,MAAM,UAAU,CAAC;AAElD,oBAAY,oBAAoB;IAC9B,qBAAqB,KAAK;IAC1B,0BAA0B,KAAK;
|
|
1
|
+
{"version":3,"file":"Controller.d.ts","sourceRoot":"","sources":["../../../src/types/Controller.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,OAAO,EAAE,UAAU,EAAE,UAAU,EAAE,MAAM,UAAU,CAAC;AAElD,oBAAY,oBAAoB;IAC9B,aAAa,IAAI;IACjB,aAAa,IAAI;IACjB,kBAAkB,IAAI;IACtB,qBAAqB,KAAK;IAC1B,0BAA0B,KAAK;IAC/B,sBAAsB,KAAK;CAC5B;AAKD,oBAAY,UAAU;IACpB,aAAa,IAAI;IACjB,aAAa,IAAI;IACjB,QAAQ,IAAI;IACZ,GAAG,IAAI;IACP,kBAAkB,IAAI;IACtB,kBAAkB,IAAI;IACtB,aAAa,IAAI;IACjB,QAAQ,IAAI;IACZ,kBAAkB,IAAI;IACtB,kBAAkB,IAAI;IACtB,aAAa,KAAK;IAClB,GAAG,KAAK;IACR,KAAK,KAAK;IACV,EAAE,KAAK;IACP,KAAK,KAAK;IACV,KAAK,KAAK;IACV,OAAO,KAAK;IACZ,OAAO,KAAK;IACZ,mBAAmB,KAAK;IACxB,mBAAmB,KAAK;IACxB,WAAW,KAAK;CACjB;AAqDD,eAAO,MAAM,sBAAsB;;;;;;;UAST,UAAU;;;;;;;GAE/B,CAAC;AAEN,eAAO,MAAM,oBAAoB;;;;;;;;;;;;;IAe7B,4FAA4F;gBACjD,UAAU;;IAErD,oDAAoD;;;IAGpD,4EAA4E;;;;;;;;;;;GAE3E,CAAC;AAEN,eAAO,MAAM,0BAA0B;;;;;;;;;;;;;;;;;;QAVnC,4FAA4F;oBACjD,UAAU;;QAErD,oDAAoD;;;QAGpD,4EAA4E;;;;;;;;;;;;;;;;;;;cAzBtD,UAAU;;;;;;;;;;;;;;;;;QAmBhC,4FAA4F;oBACjD,UAAU;;QAErD,oDAAoD;;;QAGpD,4EAA4E;;;;;cAzBtD,UAAU;;;;;;;;;;;QAmBhC,4FAA4F;oBACjD,UAAU;;QAErD,oDAAoD;;;QAGpD,4EAA4E;;;;;;cAzBtD,UAAU;;;GA6C/B,CAAC;AAEN,eAAO,MAAM,gBAAgB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;YA5BzB,4FAA4F;wBACjD,UAAU;;YAErD,oDAAoD;;;YAGpD,4EAA4E;;;;;;;;;;;;;;;;;;;kBAzBtD,UAAU;;;;;;;;;;;;;;;;;YAmBhC,4FAA4F;wBACjD,UAAU;;YAErD,oDAAoD;;;YAGpD,4EAA4E;;;;;kBAzBtD,UAAU;;;;;;;;;;;YAmBhC,4FAA4F;wBACjD,UAAU;;YAErD,oDAAoD;;;YAGpD,4EAA4E;;;;;;kBAzBtD,UAAU;;;;;;;;;;;;;;;;;;;;;;;;YAsBhC,oDAAoD;;;YAGpD,4EAA4E;;;;;;;;;kBAzBtD,UAAU;;;;;;;;;;;;;;;;;;;;;;;YAmBhC,4FAA4F;wBACjD,UAAU;;YAErD,oDAAoD;;;YAGpD,4EAA4E;;;;;kBAzBtD,UAAU;;;;;;;GAiF/B,CAAC;AAEN,MAAM,MAAM,gBAAgB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,sBAAsB,CAAC,CAAC;AACtE,MAAM,MAAM,cAAc,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,oBAAoB,CAAC,CAAC;AAClE,MAAM,MAAM,oBAAoB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,0BAA0B,CAAC,CAAC;AAC9E,MAAM,MAAM,UAAU,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,gBAAgB,CAAC,CAAC"}
|
|
@@ -1,40 +1,137 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.ControllerSchema = exports.ControllerDeviceInfoSchema = exports.ControllerPortSchema = exports.ControllerDeviceType = void 0;
|
|
3
|
+
exports.ControllerSchema = exports.ControllerDeviceInfoSchema = exports.ControllerPortSchema = exports.ControllerSensorSchema = exports.SensorType = exports.ControllerDeviceType = void 0;
|
|
4
4
|
const zod_1 = require("zod");
|
|
5
5
|
const Device_1 = require("./Device");
|
|
6
6
|
var ControllerDeviceType;
|
|
7
7
|
(function (ControllerDeviceType) {
|
|
8
|
+
ControllerDeviceType[ControllerDeviceType["CONTROLLER_67"] = 1] = "CONTROLLER_67";
|
|
9
|
+
ControllerDeviceType[ControllerDeviceType["CONTROLLER_69"] = 7] = "CONTROLLER_69";
|
|
10
|
+
ControllerDeviceType[ControllerDeviceType["CONTROLLER_69_WIFI"] = 8] = "CONTROLLER_69_WIFI";
|
|
8
11
|
ControllerDeviceType[ControllerDeviceType["UIS_CONTROLLER_69_PRO"] = 11] = "UIS_CONTROLLER_69_PRO";
|
|
9
|
-
ControllerDeviceType[ControllerDeviceType["UIS_CONTROLLER_69_PRO_PLUS"] =
|
|
12
|
+
ControllerDeviceType[ControllerDeviceType["UIS_CONTROLLER_69_PRO_PLUS"] = 18] = "UIS_CONTROLLER_69_PRO_PLUS";
|
|
13
|
+
ControllerDeviceType[ControllerDeviceType["UIS_CONTROLLER_AI_PLUS"] = 20] = "UIS_CONTROLLER_AI_PLUS";
|
|
10
14
|
})(ControllerDeviceType || (exports.ControllerDeviceType = ControllerDeviceType = {}));
|
|
15
|
+
// these controllers report pumps as PUMP instead of WATER_PUMP
|
|
16
|
+
const PUMP_CONTROLLERS = [ControllerDeviceType.UIS_CONTROLLER_69_PRO, ControllerDeviceType.UIS_CONTROLLER_69_PRO_PLUS];
|
|
17
|
+
var SensorType;
|
|
18
|
+
(function (SensorType) {
|
|
19
|
+
SensorType[SensorType["TEMPERATURE_F"] = 0] = "TEMPERATURE_F";
|
|
20
|
+
SensorType[SensorType["TEMPERATURE_C"] = 1] = "TEMPERATURE_C";
|
|
21
|
+
SensorType[SensorType["HUMIDITY"] = 2] = "HUMIDITY";
|
|
22
|
+
SensorType[SensorType["VPD"] = 3] = "VPD";
|
|
23
|
+
SensorType[SensorType["ZONE_TEMPERATURE_F"] = 4] = "ZONE_TEMPERATURE_F";
|
|
24
|
+
SensorType[SensorType["ZONE_TEMPERATURE_C"] = 5] = "ZONE_TEMPERATURE_C";
|
|
25
|
+
SensorType[SensorType["ZONE_HUMIDITY"] = 6] = "ZONE_HUMIDITY";
|
|
26
|
+
SensorType[SensorType["ZONE_VPD"] = 7] = "ZONE_VPD";
|
|
27
|
+
SensorType[SensorType["LEAF_TEMPERATURE_F"] = 8] = "LEAF_TEMPERATURE_F";
|
|
28
|
+
SensorType[SensorType["LEAF_TEMPERATURE_C"] = 9] = "LEAF_TEMPERATURE_C";
|
|
29
|
+
SensorType[SensorType["SOIL_MOISTURE"] = 10] = "SOIL_MOISTURE";
|
|
30
|
+
SensorType[SensorType["CO2"] = 11] = "CO2";
|
|
31
|
+
SensorType[SensorType["LIGHT"] = 12] = "LIGHT";
|
|
32
|
+
SensorType[SensorType["PH"] = 13] = "PH";
|
|
33
|
+
SensorType[SensorType["EC_US"] = 14] = "EC_US";
|
|
34
|
+
SensorType[SensorType["EC_MS"] = 15] = "EC_MS";
|
|
35
|
+
SensorType[SensorType["TDS_PPM"] = 16] = "TDS_PPM";
|
|
36
|
+
SensorType[SensorType["TDS_PPT"] = 17] = "TDS_PPT";
|
|
37
|
+
SensorType[SensorType["WATER_TEMPERATURE_F"] = 18] = "WATER_TEMPERATURE_F";
|
|
38
|
+
SensorType[SensorType["WATER_TEMPERATURE_C"] = 19] = "WATER_TEMPERATURE_C";
|
|
39
|
+
SensorType[SensorType["WATER_LEVEL"] = 20] = "WATER_LEVEL";
|
|
40
|
+
})(SensorType || (exports.SensorType = SensorType = {}));
|
|
41
|
+
// outlet ports report their device type with this bit set
|
|
42
|
+
const OUTLET_FLAG = 0x80;
|
|
43
|
+
// ports without an assigned device type are recognized by the id resistor in the plug, in ohms
|
|
44
|
+
const RESISTANCE_RANGES = [
|
|
45
|
+
[380, 420, Device_1.DeviceType.GROW_LIGHT],
|
|
46
|
+
[3135, 3465, Device_1.DeviceType.GROW_LIGHT],
|
|
47
|
+
[4845, 10500, Device_1.DeviceType.FAN],
|
|
48
|
+
[10501, 12600, Device_1.DeviceType.HUMIDIFIER],
|
|
49
|
+
[12601, 14385, Device_1.DeviceType.DEHUMIDIFIER],
|
|
50
|
+
[16591, 18900, Device_1.DeviceType.HEATER],
|
|
51
|
+
[18901, 21525, Device_1.DeviceType.AIR_CONDITION],
|
|
52
|
+
[35100, 42900, Device_1.DeviceType.DEHUMIDIFIER],
|
|
53
|
+
];
|
|
54
|
+
const PUMP_RESISTANCE_RANGE = [1350, 1650];
|
|
55
|
+
const deviceTypeByResistance = (resistance, controllerType) => {
|
|
56
|
+
if (resistance === null) {
|
|
57
|
+
return Device_1.DeviceType.NONE;
|
|
58
|
+
}
|
|
59
|
+
const ohms = resistance < 0 ? resistance & 0xffff : resistance;
|
|
60
|
+
const [pumpMin, pumpMax] = PUMP_RESISTANCE_RANGE;
|
|
61
|
+
if (ohms >= pumpMin && ohms <= pumpMax) {
|
|
62
|
+
return PUMP_CONTROLLERS.includes(controllerType) ? Device_1.DeviceType.PUMP : Device_1.DeviceType.WATER_PUMP;
|
|
63
|
+
}
|
|
64
|
+
return RESISTANCE_RANGES.find(([min, max]) => ohms >= min && ohms <= max)?.[2] ?? Device_1.DeviceType.NONE;
|
|
65
|
+
};
|
|
66
|
+
// the vendor reports this value for a sensor that has no reading
|
|
67
|
+
const SENSOR_NO_DATA = -32768;
|
|
68
|
+
const decodeSensorValue = (data, precision) => {
|
|
69
|
+
if (data === SENSOR_NO_DATA) {
|
|
70
|
+
return null;
|
|
71
|
+
}
|
|
72
|
+
switch (precision) {
|
|
73
|
+
case 0:
|
|
74
|
+
return data * 10;
|
|
75
|
+
case 2:
|
|
76
|
+
return data / 10;
|
|
77
|
+
case 3:
|
|
78
|
+
return data / 100;
|
|
79
|
+
default:
|
|
80
|
+
return data;
|
|
81
|
+
}
|
|
82
|
+
};
|
|
83
|
+
exports.ControllerSensorSchema = zod_1.z
|
|
84
|
+
.object({
|
|
85
|
+
accessPort: zod_1.z.number(),
|
|
86
|
+
sensorType: zod_1.z.number(),
|
|
87
|
+
sensorPrecision: zod_1.z.number(),
|
|
88
|
+
sensorData: zod_1.z.number(),
|
|
89
|
+
})
|
|
90
|
+
.transform((v) => ({
|
|
91
|
+
port: v.accessPort,
|
|
92
|
+
type: v.sensorType,
|
|
93
|
+
value: decodeSensorValue(v.sensorData, v.sensorPrecision),
|
|
94
|
+
}));
|
|
11
95
|
exports.ControllerPortSchema = zod_1.z
|
|
12
96
|
.object({
|
|
13
97
|
speak: zod_1.z.number(),
|
|
14
98
|
port: zod_1.z.number().positive(),
|
|
15
99
|
curMode: zod_1.z.enum(Device_1.DeviceMode),
|
|
16
|
-
loadType: zod_1.z.
|
|
100
|
+
loadType: zod_1.z.number(),
|
|
17
101
|
portName: zod_1.z.string(),
|
|
102
|
+
portResistance: zod_1.z.number().nullish(),
|
|
103
|
+
online: zod_1.z.coerce.boolean(),
|
|
104
|
+
remainTime: zod_1.z.number().nullish(),
|
|
18
105
|
})
|
|
19
106
|
.transform((v) => ({
|
|
20
107
|
port: v.port,
|
|
21
108
|
currentLevel: v.speak,
|
|
22
109
|
currentMode: v.curMode,
|
|
23
|
-
|
|
110
|
+
/** NONE when no type is assigned, the controller schema then recognizes it by resistance */
|
|
111
|
+
deviceType: (v.loadType & ~OUTLET_FLAG),
|
|
24
112
|
deviceName: v.portName,
|
|
113
|
+
/** id resistor of the plugged in device, in ohms */
|
|
114
|
+
resistance: v.portResistance ?? null,
|
|
115
|
+
online: v.online,
|
|
116
|
+
/** seconds left until the current timer, cycle or schedule step switches */
|
|
117
|
+
remainingTime: v.remainTime ?? null,
|
|
25
118
|
}));
|
|
26
119
|
exports.ControllerDeviceInfoSchema = zod_1.z
|
|
27
120
|
.object({
|
|
28
121
|
temperature: zod_1.z.number(),
|
|
122
|
+
temperatureF: zod_1.z.number().nullish(),
|
|
29
123
|
humidity: zod_1.z.number(),
|
|
30
124
|
vpdnums: zod_1.z.number(),
|
|
31
125
|
ports: zod_1.z.array(exports.ControllerPortSchema),
|
|
126
|
+
sensors: zod_1.z.array(exports.ControllerSensorSchema).nullish(),
|
|
32
127
|
})
|
|
33
128
|
.transform((v) => ({
|
|
34
129
|
temperature: v.temperature / 100,
|
|
130
|
+
temperatureF: v.temperatureF == null ? null : v.temperatureF / 100,
|
|
35
131
|
humidity: v.humidity / 100,
|
|
36
132
|
vpd: v.vpdnums / 100,
|
|
37
133
|
ports: v.ports,
|
|
134
|
+
sensors: v.sensors ?? [],
|
|
38
135
|
}));
|
|
39
136
|
exports.ControllerSchema = zod_1.z
|
|
40
137
|
.object({
|
|
@@ -44,17 +141,30 @@ exports.ControllerSchema = zod_1.z
|
|
|
44
141
|
devType: zod_1.z.enum(ControllerDeviceType),
|
|
45
142
|
devPortCount: zod_1.z.number().positive(),
|
|
46
143
|
devVersion: zod_1.z.number(),
|
|
144
|
+
devMacAddr: zod_1.z.string().nullish(),
|
|
145
|
+
zoneId: zod_1.z.string().nullish(),
|
|
146
|
+
wifiName: zod_1.z.string().nullish(),
|
|
47
147
|
online: zod_1.z.coerce.boolean(),
|
|
48
148
|
firmwareVersion: zod_1.z.string(),
|
|
49
149
|
hardwareVersion: zod_1.z.string(),
|
|
50
150
|
deviceInfo: exports.ControllerDeviceInfoSchema,
|
|
51
151
|
})
|
|
52
|
-
.transform(({ devId, devCode, devName, devType, devPortCount, devVersion, ...rest }) => ({
|
|
152
|
+
.transform(({ devId, devCode, devName, devType, devPortCount, devVersion, devMacAddr, zoneId, wifiName, deviceInfo, ...rest }) => ({
|
|
53
153
|
id: devId,
|
|
54
154
|
code: devCode,
|
|
55
155
|
name: devName,
|
|
56
156
|
type: devType,
|
|
57
157
|
totalPorts: devPortCount,
|
|
58
158
|
version: devVersion,
|
|
159
|
+
macAddress: devMacAddr ?? null,
|
|
160
|
+
timeZone: zoneId ?? null,
|
|
161
|
+
wifiName: wifiName ?? null,
|
|
162
|
+
deviceInfo: {
|
|
163
|
+
...deviceInfo,
|
|
164
|
+
ports: deviceInfo.ports.map((port) => ({
|
|
165
|
+
...port,
|
|
166
|
+
deviceType: port.deviceType || deviceTypeByResistance(port.resistance, devType),
|
|
167
|
+
})),
|
|
168
|
+
},
|
|
59
169
|
...rest,
|
|
60
170
|
}));
|