@jakobgoerke/ac-infinity-client 0.1.1 → 0.3.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.
@@ -1,153 +1,326 @@
1
1
  import { z } from 'zod';
2
2
  import { DeviceMode, DeviceType } from './Device';
3
- declare enum ControllerDeviceType {
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 = 10
8
+ UIS_CONTROLLER_69_PRO_PLUS = 18,
9
+ UIS_CONTROLLER_AI_PLUS = 20
6
10
  }
7
- export declare const ControllerPortSchema: z.ZodObject<{
8
- loadType: z.ZodNativeEnum<typeof DeviceType>;
9
- curMode: z.ZodNativeEnum<typeof DeviceMode>;
10
- port: z.ZodNumber;
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
+ }>>;
49
+ export declare const ControllerPortSchema: z.ZodPipe<z.ZodObject<{
11
50
  speak: z.ZodNumber;
51
+ port: z.ZodNumber;
52
+ curMode: z.ZodEnum<typeof DeviceMode>;
53
+ loadType: z.ZodNumber;
12
54
  portName: z.ZodString;
13
- }, "strip", z.ZodTypeAny, {
14
- loadType: DeviceType;
15
- curMode: DeviceMode;
55
+ portResistance: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
56
+ online: z.ZodCoercedBoolean<unknown>;
57
+ remainTime: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
58
+ }, z.core.$strip>, z.ZodTransform<{
16
59
  port: number;
17
- speak: number;
18
- portName: string;
60
+ currentLevel: number;
61
+ currentMode: DeviceMode;
62
+ /** NONE when no type is assigned, the controller schema then recognizes it by resistance */
63
+ deviceType: DeviceType;
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
- loadType: DeviceType;
21
- curMode: DeviceMode;
22
- port: number;
23
71
  speak: number;
72
+ port: number;
73
+ curMode: DeviceMode;
74
+ loadType: number;
24
75
  portName: string;
25
- }>;
26
- export type ControllerPort = z.infer<typeof ControllerPortSchema>;
27
- export declare const ControllerDeviceInfoSchema: z.ZodObject<{
76
+ online: boolean;
77
+ portResistance?: number | null | undefined;
78
+ remainTime?: number | null | undefined;
79
+ }>>;
80
+ export declare const ControllerDeviceInfoSchema: z.ZodPipe<z.ZodObject<{
28
81
  temperature: z.ZodNumber;
82
+ temperatureF: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
29
83
  humidity: z.ZodNumber;
30
- ports: z.ZodArray<z.ZodObject<{
31
- loadType: z.ZodNativeEnum<typeof DeviceType>;
32
- curMode: z.ZodNativeEnum<typeof DeviceMode>;
33
- port: z.ZodNumber;
84
+ vpdnums: z.ZodNumber;
85
+ ports: z.ZodArray<z.ZodPipe<z.ZodObject<{
34
86
  speak: z.ZodNumber;
87
+ port: z.ZodNumber;
88
+ curMode: z.ZodEnum<typeof DeviceMode>;
89
+ loadType: z.ZodNumber;
35
90
  portName: z.ZodString;
36
- }, "strip", z.ZodTypeAny, {
37
- loadType: DeviceType;
38
- curMode: DeviceMode;
91
+ portResistance: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
92
+ online: z.ZodCoercedBoolean<unknown>;
93
+ remainTime: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
94
+ }, z.core.$strip>, z.ZodTransform<{
39
95
  port: number;
40
- speak: number;
41
- portName: string;
96
+ currentLevel: number;
97
+ currentMode: DeviceMode;
98
+ /** NONE when no type is assigned, the controller schema then recognizes it by resistance */
99
+ deviceType: DeviceType;
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
- loadType: DeviceType;
44
- curMode: DeviceMode;
45
- port: number;
46
107
  speak: number;
108
+ port: number;
109
+ curMode: DeviceMode;
110
+ loadType: number;
47
111
  portName: string;
48
- }>, "many">;
49
- vpdnums: z.ZodNumber;
50
- }, "strip", z.ZodTypeAny, {
112
+ online: boolean;
113
+ portResistance?: number | null | undefined;
114
+ remainTime?: number | null | undefined;
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
+ }>>>>>;
131
+ }, z.core.$strip>, z.ZodTransform<{
51
132
  temperature: number;
133
+ temperatureF: number | null;
52
134
  humidity: number;
135
+ vpd: number;
53
136
  ports: {
54
- loadType: DeviceType;
55
- curMode: DeviceMode;
56
137
  port: number;
57
- speak: number;
58
- portName: string;
138
+ currentLevel: number;
139
+ currentMode: DeviceMode;
140
+ /** NONE when no type is assigned, the controller schema then recognizes it by resistance */
141
+ deviceType: DeviceType;
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
- vpdnums: number;
61
154
  }, {
62
155
  temperature: number;
63
156
  humidity: number;
157
+ vpdnums: number;
64
158
  ports: {
65
- loadType: DeviceType;
66
- curMode: DeviceMode;
67
159
  port: number;
68
- speak: number;
69
- portName: string;
160
+ currentLevel: number;
161
+ currentMode: DeviceMode;
162
+ /** NONE when no type is assigned, the controller schema then recognizes it by resistance */
163
+ deviceType: DeviceType;
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
  }[];
71
- vpdnums: number;
72
- }>;
73
- export type ControllerDeviceInfo = z.infer<typeof ControllerDeviceInfoSchema>;
74
- export declare const ControllerSchema: z.ZodObject<{
171
+ temperatureF?: number | null | undefined;
172
+ sensors?: {
173
+ port: number;
174
+ type: SensorType;
175
+ value: number | null;
176
+ }[] | null | undefined;
177
+ }>>;
178
+ export declare const ControllerSchema: z.ZodPipe<z.ZodObject<{
75
179
  devId: z.ZodString;
76
180
  devCode: z.ZodString;
77
181
  devName: z.ZodString;
78
- devType: z.ZodNativeEnum<typeof ControllerDeviceType>;
182
+ devType: z.ZodEnum<typeof ControllerDeviceType>;
79
183
  devPortCount: z.ZodNumber;
80
184
  devVersion: z.ZodNumber;
81
- online: z.ZodBoolean;
185
+ devMacAddr: z.ZodOptional<z.ZodNullable<z.ZodString>>;
186
+ zoneId: z.ZodOptional<z.ZodNullable<z.ZodString>>;
187
+ wifiName: z.ZodOptional<z.ZodNullable<z.ZodString>>;
188
+ online: z.ZodCoercedBoolean<unknown>;
82
189
  firmwareVersion: z.ZodString;
83
190
  hardwareVersion: z.ZodString;
84
- deviceInfo: z.ZodObject<{
191
+ deviceInfo: z.ZodPipe<z.ZodObject<{
85
192
  temperature: z.ZodNumber;
193
+ temperatureF: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
86
194
  humidity: z.ZodNumber;
87
- ports: z.ZodArray<z.ZodObject<{
88
- loadType: z.ZodNativeEnum<typeof DeviceType>;
89
- curMode: z.ZodNativeEnum<typeof DeviceMode>;
90
- port: z.ZodNumber;
195
+ vpdnums: z.ZodNumber;
196
+ ports: z.ZodArray<z.ZodPipe<z.ZodObject<{
91
197
  speak: z.ZodNumber;
198
+ port: z.ZodNumber;
199
+ curMode: z.ZodEnum<typeof DeviceMode>;
200
+ loadType: z.ZodNumber;
92
201
  portName: z.ZodString;
93
- }, "strip", z.ZodTypeAny, {
94
- loadType: DeviceType;
95
- curMode: DeviceMode;
202
+ portResistance: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
203
+ online: z.ZodCoercedBoolean<unknown>;
204
+ remainTime: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
205
+ }, z.core.$strip>, z.ZodTransform<{
96
206
  port: number;
97
- speak: number;
98
- portName: string;
207
+ currentLevel: number;
208
+ currentMode: DeviceMode;
209
+ /** NONE when no type is assigned, the controller schema then recognizes it by resistance */
210
+ deviceType: DeviceType;
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;
99
217
  }, {
100
- loadType: DeviceType;
101
- curMode: DeviceMode;
102
- port: number;
103
218
  speak: number;
219
+ port: number;
220
+ curMode: DeviceMode;
221
+ loadType: number;
104
222
  portName: string;
105
- }>, "many">;
106
- vpdnums: z.ZodNumber;
107
- }, "strip", z.ZodTypeAny, {
223
+ online: boolean;
224
+ portResistance?: number | null | undefined;
225
+ remainTime?: number | null | undefined;
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
+ }>>>>>;
242
+ }, z.core.$strip>, z.ZodTransform<{
108
243
  temperature: number;
244
+ temperatureF: number | null;
109
245
  humidity: number;
246
+ vpd: number;
110
247
  ports: {
111
- loadType: DeviceType;
112
- curMode: DeviceMode;
113
248
  port: number;
114
- speak: number;
115
- portName: string;
249
+ currentLevel: number;
250
+ currentMode: DeviceMode;
251
+ /** NONE when no type is assigned, the controller schema then recognizes it by resistance */
252
+ deviceType: DeviceType;
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;
116
264
  }[];
117
- vpdnums: number;
118
265
  }, {
119
266
  temperature: number;
120
267
  humidity: number;
268
+ vpdnums: number;
121
269
  ports: {
122
- loadType: DeviceType;
123
- curMode: DeviceMode;
124
270
  port: number;
125
- speak: number;
126
- portName: string;
271
+ currentLevel: number;
272
+ currentMode: DeviceMode;
273
+ /** NONE when no type is assigned, the controller schema then recognizes it by resistance */
274
+ deviceType: DeviceType;
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;
127
281
  }[];
128
- vpdnums: number;
129
- }>;
130
- }, "strip", z.ZodTypeAny, {
131
- devId: string;
132
- devCode: string;
133
- devName: string;
134
- devType: ControllerDeviceType;
135
- devPortCount: number;
136
- devVersion: number;
282
+ temperatureF?: number | null | undefined;
283
+ sensors?: {
284
+ port: number;
285
+ type: SensorType;
286
+ value: number | null;
287
+ }[] | null | undefined;
288
+ }>>;
289
+ }, z.core.$strip>, z.ZodTransform<{
137
290
  online: boolean;
138
291
  firmwareVersion: string;
139
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;
140
302
  deviceInfo: {
303
+ ports: {
304
+ deviceType: DeviceType;
305
+ port: number;
306
+ currentLevel: number;
307
+ currentMode: DeviceMode;
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
+ }[];
141
315
  temperature: number;
316
+ temperatureF: number | null;
142
317
  humidity: number;
143
- ports: {
144
- loadType: DeviceType;
145
- curMode: DeviceMode;
318
+ vpd: number;
319
+ sensors: {
146
320
  port: number;
147
- speak: number;
148
- portName: string;
321
+ type: SensorType;
322
+ value: number | null;
149
323
  }[];
150
- vpdnums: number;
151
324
  };
152
325
  }, {
153
326
  devId: string;
@@ -161,17 +334,34 @@ export declare const ControllerSchema: z.ZodObject<{
161
334
  hardwareVersion: string;
162
335
  deviceInfo: {
163
336
  temperature: number;
337
+ temperatureF: number | null;
164
338
  humidity: number;
339
+ vpd: number;
165
340
  ports: {
166
- loadType: DeviceType;
167
- curMode: DeviceMode;
168
341
  port: number;
169
- speak: number;
170
- portName: string;
342
+ currentLevel: number;
343
+ currentMode: DeviceMode;
344
+ /** NONE when no type is assigned, the controller schema then recognizes it by resistance */
345
+ deviceType: DeviceType;
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;
171
357
  }[];
172
- vpdnums: number;
173
358
  };
174
- }>;
359
+ devMacAddr?: string | null | undefined;
360
+ zoneId?: string | null | undefined;
361
+ wifiName?: string | null | undefined;
362
+ }>>;
363
+ export type ControllerSensor = z.infer<typeof ControllerSensorSchema>;
364
+ export type ControllerPort = z.infer<typeof ControllerPortSchema>;
365
+ export type ControllerDeviceInfo = z.infer<typeof ControllerDeviceInfoSchema>;
175
366
  export type Controller = z.infer<typeof ControllerSchema>;
176
- export {};
177
367
  //# sourceMappingURL=Controller.d.ts.map
@@ -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;AACxB,OAAO,EAAE,UAAU,EAAE,UAAU,EAAE,MAAM,UAAU,CAAC;AAElD,aAAK,oBAAoB;IACvB,qBAAqB,KAAK;IAC1B,0BAA0B,KAAK;CAChC;AAED,eAAO,MAAM,oBAAoB;;;;;;;;;;;;;;;;;;EAM/B,CAAC;AACH,MAAM,MAAM,cAAc,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,oBAAoB,CAAC,CAAC;AAElE,eAAO,MAAM,0BAA0B;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAK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AC;AAC9E,MAAM,MAAM,UAAU,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,gBAAgB,CAAC,CAAC"}
@@ -1,35 +1,170 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.ControllerSchema = exports.ControllerDeviceInfoSchema = exports.ControllerPortSchema = 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"] = 10] = "UIS_CONTROLLER_69_PRO_PLUS";
10
- })(ControllerDeviceType || (ControllerDeviceType = {}));
11
- exports.ControllerPortSchema = zod_1.z.object({
12
- loadType: zod_1.z.nativeEnum(Device_1.DeviceType),
13
- curMode: zod_1.z.nativeEnum(Device_1.DeviceMode),
14
- port: zod_1.z.number().positive(),
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";
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
+ }));
95
+ exports.ControllerPortSchema = zod_1.z
96
+ .object({
15
97
  speak: zod_1.z.number(),
98
+ port: zod_1.z.number().positive(),
99
+ curMode: zod_1.z.enum(Device_1.DeviceMode),
100
+ loadType: zod_1.z.number(),
16
101
  portName: zod_1.z.string(),
17
- });
18
- exports.ControllerDeviceInfoSchema = zod_1.z.object({
102
+ portResistance: zod_1.z.number().nullish(),
103
+ online: zod_1.z.coerce.boolean(),
104
+ remainTime: zod_1.z.number().nullish(),
105
+ })
106
+ .transform((v) => ({
107
+ port: v.port,
108
+ currentLevel: v.speak,
109
+ currentMode: v.curMode,
110
+ /** NONE when no type is assigned, the controller schema then recognizes it by resistance */
111
+ deviceType: (v.loadType & ~OUTLET_FLAG),
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,
118
+ }));
119
+ exports.ControllerDeviceInfoSchema = zod_1.z
120
+ .object({
19
121
  temperature: zod_1.z.number(),
122
+ temperatureF: zod_1.z.number().nullish(),
20
123
  humidity: zod_1.z.number(),
21
- ports: zod_1.z.array(exports.ControllerPortSchema),
22
124
  vpdnums: zod_1.z.number(),
23
- });
24
- exports.ControllerSchema = zod_1.z.object({
125
+ ports: zod_1.z.array(exports.ControllerPortSchema),
126
+ sensors: zod_1.z.array(exports.ControllerSensorSchema).nullish(),
127
+ })
128
+ .transform((v) => ({
129
+ temperature: v.temperature / 100,
130
+ temperatureF: v.temperatureF == null ? null : v.temperatureF / 100,
131
+ humidity: v.humidity / 100,
132
+ vpd: v.vpdnums / 100,
133
+ ports: v.ports,
134
+ sensors: v.sensors ?? [],
135
+ }));
136
+ exports.ControllerSchema = zod_1.z
137
+ .object({
25
138
  devId: zod_1.z.string(),
26
139
  devCode: zod_1.z.string(),
27
140
  devName: zod_1.z.string(),
28
- devType: zod_1.z.nativeEnum(ControllerDeviceType),
141
+ devType: zod_1.z.enum(ControllerDeviceType),
29
142
  devPortCount: zod_1.z.number().positive(),
30
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(),
31
147
  online: zod_1.z.coerce.boolean(),
32
148
  firmwareVersion: zod_1.z.string(),
33
149
  hardwareVersion: zod_1.z.string(),
34
150
  deviceInfo: exports.ControllerDeviceInfoSchema,
35
- });
151
+ })
152
+ .transform(({ devId, devCode, devName, devType, devPortCount, devVersion, devMacAddr, zoneId, wifiName, deviceInfo, ...rest }) => ({
153
+ id: devId,
154
+ code: devCode,
155
+ name: devName,
156
+ type: devType,
157
+ totalPorts: devPortCount,
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
+ },
169
+ ...rest,
170
+ }));