@jakobgoerke/ac-infinity-client 0.2.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.
package/README.md CHANGED
@@ -1 +1 @@
1
- # ac-infinity-client
1
+ # ac-infinity-client
@@ -1,25 +1,35 @@
1
- import type { Controller, DeviceModeSettings, DeviceSettings, User } from './types';
1
+ import type { Controller, DeviceModeSettings, DeviceModeSettingsChanges, DeviceSettings, DeviceSettingsChanges, User } from './types';
2
2
  export declare enum Url {
3
3
  AUTH = "/user/appUserLogin",
4
4
  GET_CONTROLLERS = "/user/devInfoListAll",
5
+ GET_SHARED_CONTROLLERS = "/user/shareDevList",
6
+ GET_CONTROLLER = "/dev/getDeviceInfo",
5
7
  GET_DEVICE_SETTINGS = "/dev/getDevSetting",
8
+ SET_DEVICE_SETTINGS = "/dev/updateAdvSetting",
6
9
  GET_DEVICE_MODE_SETTINGS = "/dev/getdevModeSettingList",
7
10
  SET_DEVICE_MODE_SETTINGS = "/dev/addDevMode"
8
11
  }
9
12
  export interface Response<T> {
10
13
  code: number;
14
+ msg?: string;
11
15
  data: T;
12
16
  }
13
17
  export interface AuthParams {
14
18
  email: string;
15
19
  password: string;
16
20
  }
17
- interface GetDeviceParams {
21
+ export interface ControllerParams {
18
22
  controllerId: string;
23
+ }
24
+ export interface GetDeviceParams extends ControllerParams {
25
+ /** 0 addresses the controller itself, 1..n the devices plugged into its ports */
19
26
  port: number;
20
27
  }
21
- interface SetDeviceModeSettingsParams extends GetDeviceParams {
22
- settings: Pick<Partial<DeviceModeSettings>, 'levelWhileOn'>;
28
+ export interface SetDeviceModeSettingsParams extends GetDeviceParams {
29
+ settings: DeviceModeSettingsChanges;
30
+ }
31
+ export interface SetDeviceSettingsParams extends GetDeviceParams {
32
+ settings: DeviceSettingsChanges;
23
33
  }
24
34
  declare class AcInfinityClient {
25
35
  constructor(args: AuthParams);
@@ -28,13 +38,17 @@ declare class AcInfinityClient {
28
38
  private email;
29
39
  private password;
30
40
  authenticate(): Promise<User>;
31
- private ensureSuccess;
41
+ private request;
32
42
  getControllers(): Promise<Controller[]>;
43
+ getSharedControllers(): Promise<Controller[]>;
44
+ getController({ controllerId }: ControllerParams): Promise<Controller>;
33
45
  getDeviceSettings({ controllerId, port }: GetDeviceParams): Promise<DeviceSettings>;
46
+ setDeviceSettings({ controllerId, port, settings }: SetDeviceSettingsParams): Promise<void>;
47
+ private getDeviceName;
34
48
  getDeviceModeSettings({ controllerId, port }: GetDeviceParams): Promise<DeviceModeSettings>;
35
49
  setDeviceModeSettings({ controllerId, port, settings }: SetDeviceModeSettingsParams): Promise<void>;
36
50
  static build(args: AuthParams): Promise<AcInfinityClient>;
37
51
  }
52
+ export type { Controller, DeviceModeSettings, DeviceModeSettingsChanges, DeviceSettings, DeviceSettingsChanges, User };
38
53
  export { AcInfinityClient };
39
- export type { Controller, DeviceModeSettings, DeviceSettings, User };
40
54
  //# sourceMappingURL=AcInfinityClient.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"AcInfinityClient.d.ts","sourceRoot":"","sources":["../../src/AcInfinityClient.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,UAAU,EAAE,kBAAkB,EAA2B,cAAc,EAAE,IAAI,EAAE,MAAM,SAAS,CAAC;AAG7G,oBAAY,GAAG;IACb,IAAI,uBAAuB;IAC3B,eAAe,yBAAyB;IACxC,mBAAmB,uBAAuB;IAC1C,wBAAwB,+BAA+B;IACvD,wBAAwB,oBAAoB;CAC7C;AAED,MAAM,WAAW,QAAQ,CAAC,CAAC;IACzB,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,CAAC,CAAC;CACT;AAOD,MAAM,WAAW,UAAU;IACzB,KAAK,EAAE,MAAM,CAAC;IACd,QAAQ,EAAE,MAAM,CAAC;CAClB;AAED,UAAU,eAAe;IACvB,YAAY,EAAE,MAAM,CAAC;IACrB,IAAI,EAAE,MAAM,CAAC;CACd;AAED,UAAU,2B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,IAAI,EAAE,EAAE,eAAe,GAAG,OAAO,CAAC,kBAAkB,CAAC;IAS3F,qBAAqB,CAAC,EAAE,YAAY,EAAE,IAAI,EAAE,QAAQ,EAAE,EAAE,2BAA2B,GAAG,OAAO,CAAC,IAAI,CAAC;WAYnG,KAAK,CAAC,IAAI,EAAE,UAAU;CAKpC;AAED,YAAY,EAAE,UAAU,EAAE,kBAAkB,EAAE,yBAAyB,EAAE,cAAc,EAAE,qBAAqB,EAAE,IAAI,EAAE,CAAC;AACvH,OAAO,EAAE,gBAAgB,EAAE,CAAC"}
@@ -11,10 +11,26 @@ var Url;
11
11
  (function (Url) {
12
12
  Url["AUTH"] = "/user/appUserLogin";
13
13
  Url["GET_CONTROLLERS"] = "/user/devInfoListAll";
14
+ Url["GET_SHARED_CONTROLLERS"] = "/user/shareDevList";
15
+ Url["GET_CONTROLLER"] = "/dev/getDeviceInfo";
14
16
  Url["GET_DEVICE_SETTINGS"] = "/dev/getDevSetting";
17
+ Url["SET_DEVICE_SETTINGS"] = "/dev/updateAdvSetting";
15
18
  Url["GET_DEVICE_MODE_SETTINGS"] = "/dev/getdevModeSettingList";
16
19
  Url["SET_DEVICE_MODE_SETTINGS"] = "/dev/addDevMode";
17
20
  })(Url || (exports.Url = Url = {}));
21
+ // fahrenheit values below freezing are raised to 32 before sending mode settings
22
+ const FAHRENHEIT_FIELDS = ['devHtf', 'devLtf', 'targetTempF', 'waterTempHighValueF', 'waterTempLowValueF', 'waterTempTargetValueF'];
23
+ // only send flat values: nested objects and empty fields are left out
24
+ const toFormPayload = (values) => Object.fromEntries(Object.entries(values).filter(([, value]) => value !== null && value !== undefined && typeof value !== 'object'));
25
+ const clampFahrenheit = (payload) => {
26
+ for (const field of FAHRENHEIT_FIELDS) {
27
+ const value = payload[field];
28
+ if (typeof value === 'number' && value < 32) {
29
+ payload[field] = 32;
30
+ }
31
+ }
32
+ return payload;
33
+ };
18
34
  class AcInfinityClient {
19
35
  constructor(args) {
20
36
  const { email, password } = args;
@@ -46,40 +62,68 @@ class AcInfinityClient {
46
62
  this.api.defaults.headers.common.token = user.id;
47
63
  return user;
48
64
  }
49
- ensureSuccess(response) {
50
- if (response.code !== 200) {
51
- throw new Error(`API request failed [code="${response.code}", msg="${response.msg}"]`);
65
+ async request(url, params) {
66
+ const response = await this.api.post(url, params);
67
+ if (response.data.code !== 200) {
68
+ throw new errors_1.ApiError(response.data.code, response.data.msg);
52
69
  }
70
+ return response.data.data;
53
71
  }
54
72
  async getControllers() {
55
- const response = await this.api.post(Url.GET_CONTROLLERS, {
73
+ const controllers = await this.request(Url.GET_CONTROLLERS, {
56
74
  userId: this.token,
57
75
  });
58
- return response.data.data.map((device) => types_1.ControllerSchema.parse(device));
76
+ return controllers.map((device) => types_1.ControllerSchema.parse(device));
77
+ }
78
+ async getSharedControllers() {
79
+ const controllers = await this.request(Url.GET_SHARED_CONTROLLERS, {
80
+ userId: this.token,
81
+ });
82
+ return controllers.map((device) => types_1.ControllerSchema.parse(device));
83
+ }
84
+ async getController({ controllerId }) {
85
+ const controller = await this.request(Url.GET_CONTROLLER, {
86
+ devId: controllerId,
87
+ });
88
+ return types_1.ControllerSchema.parse(controller);
59
89
  }
60
90
  async getDeviceSettings({ controllerId, port }) {
61
- const response = await this.api.post(Url.GET_DEVICE_SETTINGS, {
91
+ const settings = await this.request(Url.GET_DEVICE_SETTINGS, {
92
+ devId: controllerId,
93
+ port,
94
+ });
95
+ return types_1.DeviceSettingsSchema.parse(settings);
96
+ }
97
+ async setDeviceSettings({ controllerId, port, settings }) {
98
+ const vendorChanges = (0, types_1.encodeDeviceSettings)(settings);
99
+ const currentSettings = await this.request(Url.GET_DEVICE_SETTINGS, {
62
100
  devId: controllerId,
63
101
  port,
64
102
  });
65
- return types_1.DeviceSettingsSchema.parse(response.data.data);
103
+ // the name is required, but often not stored in the settings themselves
104
+ const devName = vendorChanges.devName ?? currentSettings.devName ?? (await this.getDeviceName({ controllerId, port }));
105
+ const payload = toFormPayload({ ...currentSettings, ...vendorChanges, devName });
106
+ await this.request(Url.SET_DEVICE_SETTINGS, payload);
107
+ }
108
+ async getDeviceName({ controllerId, port }) {
109
+ const controller = await this.getController({ controllerId });
110
+ return port === 0 ? controller.name : controller.deviceInfo.ports.find((p) => p.port === port)?.deviceName;
66
111
  }
67
112
  async getDeviceModeSettings({ controllerId, port }) {
68
- const response = await this.api.post(Url.GET_DEVICE_MODE_SETTINGS, {
113
+ const settings = await this.request(Url.GET_DEVICE_MODE_SETTINGS, {
69
114
  devId: controllerId,
70
115
  port,
71
116
  });
72
- return types_1.DeviceModeSettingsSchema.parse(response.data.data);
117
+ return types_1.DeviceModeSettingsSchema.parse(settings);
73
118
  }
74
119
  async setDeviceModeSettings({ controllerId, port, settings }) {
75
- const rawCurrentSettings = await this.api.post(Url.GET_DEVICE_MODE_SETTINGS, {
120
+ const vendorChanges = (0, types_1.encodeDeviceModeSettings)(settings);
121
+ const currentSettings = await this.request(Url.GET_DEVICE_MODE_SETTINGS, {
76
122
  devId: controllerId,
77
123
  port,
78
124
  });
79
- const vendorChanges = (0, types_1.encodeDeviceModeSettings)(settings);
80
- const payload = { ...rawCurrentSettings.data.data, ...vendorChanges };
81
- const response = await this.api.post(Url.SET_DEVICE_MODE_SETTINGS, payload);
82
- this.ensureSuccess(response.data);
125
+ const payload = clampFahrenheit(toFormPayload({ ...currentSettings, ...vendorChanges, onlyUpdateSpeed: 0 }));
126
+ await this.request(Url.SET_DEVICE_MODE_SETTINGS, payload);
83
127
  }
84
128
  static async build(args) {
85
129
  const instance = new AcInfinityClient(args);
@@ -1,5 +1,10 @@
1
1
  declare class AuthenticationError extends Error {
2
2
  constructor(message?: string);
3
3
  }
4
- export { AuthenticationError };
4
+ declare class ApiError extends Error {
5
+ readonly code: number;
6
+ readonly msg?: string | undefined;
7
+ constructor(code: number, msg?: string | undefined);
8
+ }
9
+ export { ApiError, AuthenticationError };
5
10
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/errors/index.ts"],"names":[],"mappings":"AAAA,cAAM,mBAAoB,SAAQ,KAAK;gBACzB,OAAO,CAAC,EAAE,MAAM;CAQ7B;AAED,OAAO,EAAE,mBAAmB,EAAE,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/errors/index.ts"],"names":[],"mappings":"AAAA,cAAM,mBAAoB,SAAQ,KAAK;gBACzB,OAAO,CAAC,EAAE,MAAM;CAQ7B;AAED,cAAM,QAAS,SAAQ,KAAK;aAER,IAAI,EAAE,MAAM;aACZ,GAAG,CAAC,EAAE,MAAM;gBADZ,IAAI,EAAE,MAAM,EACZ,GAAG,CAAC,EAAE,MAAM,YAAA;CAS/B;AAED,OAAO,EAAE,QAAQ,EAAE,mBAAmB,EAAE,CAAC"}
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.AuthenticationError = void 0;
3
+ exports.AuthenticationError = exports.ApiError = void 0;
4
4
  class AuthenticationError extends Error {
5
5
  constructor(message) {
6
6
  super(message);
@@ -10,3 +10,16 @@ class AuthenticationError extends Error {
10
10
  }
11
11
  }
12
12
  exports.AuthenticationError = AuthenticationError;
13
+ class ApiError extends Error {
14
+ code;
15
+ msg;
16
+ constructor(code, msg) {
17
+ super(`API request failed [code="${code}", msg="${msg}"]`);
18
+ this.code = code;
19
+ this.msg = msg;
20
+ this.name = this.constructor.name;
21
+ Error.captureStackTrace(this, this.constructor);
22
+ Object.setPrototypeOf(this, ApiError.prototype);
23
+ }
24
+ }
25
+ exports.ApiError = ApiError;
@@ -1,2 +1,5 @@
1
1
  export * from './AcInfinityClient';
2
+ export * from './errors';
3
+ export type { ControllerDeviceInfo, ControllerPort, ControllerSensor } from './types';
4
+ export { ControllerDeviceType, DeviceMode, DeviceType, SensorType, TemperatureUnit } from './types';
2
5
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,oBAAoB,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,oBAAoB,CAAC;AACnC,cAAc,UAAU,CAAC;AACzB,YAAY,EAAE,oBAAoB,EAAE,cAAc,EAAE,gBAAgB,EAAE,MAAM,SAAS,CAAC;AACtF,OAAO,EAAE,oBAAoB,EAAE,UAAU,EAAE,UAAU,EAAE,UAAU,EAAE,eAAe,EAAE,MAAM,SAAS,CAAC"}
@@ -14,4 +14,12 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
14
  for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
15
  };
16
16
  Object.defineProperty(exports, "__esModule", { value: true });
17
+ exports.TemperatureUnit = exports.SensorType = exports.DeviceType = exports.DeviceMode = exports.ControllerDeviceType = void 0;
17
18
  __exportStar(require("./AcInfinityClient"), exports);
19
+ __exportStar(require("./errors"), exports);
20
+ var types_1 = require("./types");
21
+ Object.defineProperty(exports, "ControllerDeviceType", { enumerable: true, get: function () { return types_1.ControllerDeviceType; } });
22
+ Object.defineProperty(exports, "DeviceMode", { enumerable: true, get: function () { return types_1.DeviceMode; } });
23
+ Object.defineProperty(exports, "DeviceType", { enumerable: true, get: function () { return types_1.DeviceType; } });
24
+ Object.defineProperty(exports, "SensorType", { enumerable: true, get: function () { return types_1.SensorType; } });
25
+ Object.defineProperty(exports, "TemperatureUnit", { enumerable: true, get: function () { return types_1.TemperatureUnit; } });
@@ -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 = 10
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.ZodEnum<typeof DeviceType>;
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: DeviceType;
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.ZodEnum<typeof DeviceType>;
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: DeviceType;
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.ZodEnum<typeof DeviceType>;
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: DeviceType;
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;CAChC;AAED,eAAO,MAAM,oBAAoB;;;;;;;;;;;;;;;;;;GAc5B,CAAC;AAEN,eAAO,MAAM,0BAA0B;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAYlC,CAAC;AAEN,eAAO,MAAM,gBAAgB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAqBxB,CAAC;AAEN,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
+ {"version":3,"file":"Controller.d.ts","sourceRoot":"","sources":["../../../src/types/Controller.ts"],"names":[],"mappings":"AAAA,O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