tsvesync 1.0.12 → 1.0.13

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.
@@ -35,4 +35,4 @@ export declare class VeSyncBulbESL100MC extends VeSyncBulb {
35
35
  setRgb(red: number, green: number, blue: number): Promise<boolean>;
36
36
  enableWhiteMode(): Promise<boolean>;
37
37
  }
38
- export declare const bulbModules: Record<string, any>;
38
+ export declare const bulbModules: Record<string, new (details: Record<string, any>, manager: VeSync) => VeSyncBulb>;
@@ -6,6 +6,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
6
6
  exports.bulbModules = exports.VeSyncBulbESL100MC = exports.VeSyncBulbXYD0001 = exports.VeSyncBulbESL100CW = exports.VeSyncBulbESL100 = void 0;
7
7
  const vesyncBulb_1 = require("./vesyncBulb");
8
8
  const helpers_1 = require("./helpers");
9
+ const logger_1 = require("./logger");
9
10
  /**
10
11
  * ESL100 Bulb Implementation
11
12
  */
@@ -14,6 +15,7 @@ class VeSyncBulbESL100 extends vesyncBulb_1.VeSyncBulb {
14
15
  super(details, manager);
15
16
  }
16
17
  async setColorTemp(colorTemp) {
18
+ logger_1.logger.error(`[${this.deviceName}] Color temperature control not supported`);
17
19
  return false;
18
20
  }
19
21
  }
@@ -27,19 +29,27 @@ class VeSyncBulbESL100CW extends vesyncBulb_1.VeSyncBulb {
27
29
  }
28
30
  async setColorTemp(colorTemp) {
29
31
  if (!this.features.includes('color_temp')) {
32
+ logger_1.logger.error(`[${this.deviceName}] Color temperature control not supported`);
30
33
  return false;
31
34
  }
35
+ logger_1.logger.debug(`[${this.deviceName}] Setting color temperature to ${colorTemp}`);
32
36
  const body = {
33
- ...helpers_1.Helpers.reqBody(this.manager, 'devicestatus'),
34
- uuid: this.cid,
35
- status: 'on',
36
- colorTemp: colorTemp.toString()
37
+ ...helpers_1.Helpers.reqBody(this.manager, 'bypass'),
38
+ cid: this.cid,
39
+ configModule: this.configModule,
40
+ jsonCmd: {
41
+ light: {
42
+ colorTempe: colorTemp
43
+ }
44
+ }
37
45
  };
38
- const [response] = await helpers_1.Helpers.callApi('/SmartBulb/v1/device/updateColorTemperature', 'put', body, helpers_1.Helpers.reqHeaders(this.manager));
46
+ const [response] = await helpers_1.Helpers.callApi('/cloud/v1/deviceManaged/bypass', 'post', body, helpers_1.Helpers.reqHeaders(this.manager));
39
47
  if ((response === null || response === void 0 ? void 0 : response.code) === 0) {
40
48
  this.colorTemp = colorTemp;
49
+ logger_1.logger.debug(`[${this.deviceName}] Successfully set color temperature to ${colorTemp}`);
41
50
  return true;
42
51
  }
52
+ logger_1.logger.error(`[${this.deviceName}] Failed to set color temperature: ${JSON.stringify(response)}`);
43
53
  return false;
44
54
  }
45
55
  }
@@ -53,55 +63,99 @@ class VeSyncBulbXYD0001 extends vesyncBulb_1.VeSyncBulb {
53
63
  }
54
64
  async setColorTemp(colorTemp) {
55
65
  if (!this.features.includes('color_temp')) {
66
+ logger_1.logger.error(`[${this.deviceName}] Color temperature control not supported`);
56
67
  return false;
57
68
  }
69
+ logger_1.logger.debug(`[${this.deviceName}] Setting color temperature to ${colorTemp}`);
58
70
  const body = {
59
- ...helpers_1.Helpers.reqBody(this.manager, 'devicestatus'),
60
- uuid: this.cid,
61
- status: 'on',
62
- colorTemp: colorTemp.toString()
71
+ ...helpers_1.Helpers.reqBody(this.manager, 'bypassV2'),
72
+ cid: this.cid,
73
+ configModule: this.configModule,
74
+ payload: {
75
+ data: {
76
+ brightness: '',
77
+ colorMode: 'white',
78
+ colorTemp: colorTemp,
79
+ force: 1,
80
+ hue: '',
81
+ saturation: '',
82
+ value: ''
83
+ },
84
+ method: 'setLightStatusV2',
85
+ source: 'APP'
86
+ }
63
87
  };
64
- const [response] = await helpers_1.Helpers.callApi('/SmartBulb/v1/device/updateColorTemperature', 'put', body, helpers_1.Helpers.reqHeaders(this.manager));
88
+ const [response] = await helpers_1.Helpers.callApi('/cloud/v2/deviceManaged/bypassV2', 'post', body, helpers_1.Helpers.reqHeaders(this.manager));
65
89
  if ((response === null || response === void 0 ? void 0 : response.code) === 0) {
66
90
  this.colorTemp = colorTemp;
91
+ logger_1.logger.debug(`[${this.deviceName}] Successfully set color temperature to ${colorTemp}`);
67
92
  return true;
68
93
  }
94
+ logger_1.logger.error(`[${this.deviceName}] Failed to set color temperature: ${JSON.stringify(response)}`);
69
95
  return false;
70
96
  }
71
97
  async setHsv(hue, saturation, value) {
72
98
  if (!this.features.includes('rgb_shift')) {
99
+ logger_1.logger.error(`[${this.deviceName}] Color control not supported`);
73
100
  return false;
74
101
  }
102
+ logger_1.logger.debug(`[${this.deviceName}] Setting HSV color to H:${hue} S:${saturation} V:${value}`);
75
103
  const body = {
76
- ...helpers_1.Helpers.reqBody(this.manager, 'devicestatus'),
77
- uuid: this.cid,
78
- status: 'on',
79
- mode: 'color',
80
- hue: Math.round(hue).toString(),
81
- saturation: Math.round(saturation).toString(),
82
- brightness: Math.round(value).toString()
104
+ ...helpers_1.Helpers.reqBody(this.manager, 'bypassV2'),
105
+ cid: this.cid,
106
+ configModule: this.configModule,
107
+ payload: {
108
+ data: {
109
+ brightness: value,
110
+ colorMode: 'hsv',
111
+ colorTemp: '',
112
+ force: 1,
113
+ hue: hue,
114
+ saturation: saturation,
115
+ value: value
116
+ },
117
+ method: 'setLightStatusV2',
118
+ source: 'APP'
119
+ }
83
120
  };
84
- const [response] = await helpers_1.Helpers.callApi('/SmartBulb/v1/device/updateColor', 'put', body, helpers_1.Helpers.reqHeaders(this.manager));
121
+ const [response] = await helpers_1.Helpers.callApi('/cloud/v2/deviceManaged/bypassV2', 'post', body, helpers_1.Helpers.reqHeaders(this.manager));
85
122
  if ((response === null || response === void 0 ? void 0 : response.code) === 0) {
86
123
  this.colorHue = hue;
87
124
  this.colorSaturation = saturation;
88
125
  this.colorValue = value;
126
+ logger_1.logger.debug(`[${this.deviceName}] Successfully set HSV color`);
89
127
  return true;
90
128
  }
129
+ logger_1.logger.error(`[${this.deviceName}] Failed to set HSV color: ${JSON.stringify(response)}`);
91
130
  return false;
92
131
  }
93
132
  async enableWhiteMode() {
133
+ logger_1.logger.debug(`[${this.deviceName}] Enabling white mode`);
94
134
  const body = {
95
- ...helpers_1.Helpers.reqBody(this.manager, 'devicestatus'),
96
- uuid: this.cid,
97
- status: 'on',
98
- colorMode: 'white'
135
+ ...helpers_1.Helpers.reqBody(this.manager, 'bypassV2'),
136
+ cid: this.cid,
137
+ configModule: this.configModule,
138
+ payload: {
139
+ data: {
140
+ brightness: '',
141
+ colorMode: 'white',
142
+ colorTemp: '',
143
+ force: 1,
144
+ red: '',
145
+ green: '',
146
+ blue: ''
147
+ },
148
+ method: 'setLightStatusV2',
149
+ source: 'APP'
150
+ }
99
151
  };
100
- const [response] = await helpers_1.Helpers.callApi('/SmartBulb/v1/device/updateColorMode', 'put', body, helpers_1.Helpers.reqHeaders(this.manager));
152
+ const [response] = await helpers_1.Helpers.callApi('/cloud/v2/deviceManaged/bypassV2', 'post', body, helpers_1.Helpers.reqHeaders(this.manager));
101
153
  if ((response === null || response === void 0 ? void 0 : response.code) === 0) {
102
154
  this.colorMode = 'white';
155
+ logger_1.logger.debug(`[${this.deviceName}] Successfully enabled white mode`);
103
156
  return true;
104
157
  }
158
+ logger_1.logger.error(`[${this.deviceName}] Failed to enable white mode: ${JSON.stringify(response)}`);
105
159
  return false;
106
160
  }
107
161
  }
@@ -114,40 +168,55 @@ class VeSyncBulbESL100MC extends vesyncBulb_1.VeSyncBulb {
114
168
  super(details, manager);
115
169
  }
116
170
  async setColorTemp(colorTemp) {
171
+ logger_1.logger.error(`[${this.deviceName}] Color temperature control not supported`);
117
172
  return false;
118
173
  }
119
174
  async setRgb(red, green, blue) {
120
175
  if (!this.features.includes('rgb_shift')) {
176
+ logger_1.logger.error(`[${this.deviceName}] Color control not supported`);
121
177
  return false;
122
178
  }
179
+ logger_1.logger.debug(`[${this.deviceName}] Setting RGB color to R:${red} G:${green} B:${blue}`);
123
180
  const body = {
124
- ...helpers_1.Helpers.reqBody(this.manager, 'devicestatus'),
125
- uuid: this.cid,
126
- status: 'on',
127
- mode: 'color',
128
- red: Math.round(red).toString(),
129
- green: Math.round(green).toString(),
130
- blue: Math.round(blue).toString()
181
+ ...helpers_1.Helpers.reqBody(this.manager, 'bypass'),
182
+ cid: this.cid,
183
+ configModule: this.configModule,
184
+ jsonCmd: {
185
+ light: {
186
+ red: Math.round(red),
187
+ green: Math.round(green),
188
+ blue: Math.round(blue)
189
+ }
190
+ }
131
191
  };
132
- const [response] = await helpers_1.Helpers.callApi('/SmartBulb/v1/device/updateColor', 'put', body, helpers_1.Helpers.reqHeaders(this.manager));
192
+ const [response] = await helpers_1.Helpers.callApi('/cloud/v1/deviceManaged/bypass', 'post', body, helpers_1.Helpers.reqHeaders(this.manager));
133
193
  if ((response === null || response === void 0 ? void 0 : response.code) === 0) {
134
194
  this.rgbValues = { red, green, blue };
195
+ logger_1.logger.debug(`[${this.deviceName}] Successfully set RGB color`);
135
196
  return true;
136
197
  }
198
+ logger_1.logger.error(`[${this.deviceName}] Failed to set RGB color: ${JSON.stringify(response)}`);
137
199
  return false;
138
200
  }
139
201
  async enableWhiteMode() {
202
+ logger_1.logger.debug(`[${this.deviceName}] Enabling white mode`);
140
203
  const body = {
141
- ...helpers_1.Helpers.reqBody(this.manager, 'devicestatus'),
142
- uuid: this.cid,
143
- status: 'on',
144
- colorMode: 'white'
204
+ ...helpers_1.Helpers.reqBody(this.manager, 'bypass'),
205
+ cid: this.cid,
206
+ configModule: this.configModule,
207
+ jsonCmd: {
208
+ light: {
209
+ mode: 'white'
210
+ }
211
+ }
145
212
  };
146
- const [response] = await helpers_1.Helpers.callApi('/SmartBulb/v1/device/updateColorMode', 'put', body, helpers_1.Helpers.reqHeaders(this.manager));
213
+ const [response] = await helpers_1.Helpers.callApi('/cloud/v1/deviceManaged/bypass', 'post', body, helpers_1.Helpers.reqHeaders(this.manager));
147
214
  if ((response === null || response === void 0 ? void 0 : response.code) === 0) {
148
215
  this.colorMode = 'white';
216
+ logger_1.logger.debug(`[${this.deviceName}] Successfully enabled white mode`);
149
217
  return true;
150
218
  }
219
+ logger_1.logger.error(`[${this.deviceName}] Failed to enable white mode: ${JSON.stringify(response)}`);
151
220
  return false;
152
221
  }
153
222
  }
@@ -5,6 +5,7 @@
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
6
  exports.VeSyncFan = exports.fanConfig = void 0;
7
7
  const vesyncBaseDevice_1 = require("./vesyncBaseDevice");
8
+ const logger_1 = require("./logger");
8
9
  // Fan configuration
9
10
  exports.fanConfig = {
10
11
  // Core Series
@@ -374,7 +375,7 @@ class VeSyncFan extends vesyncBaseDevice_1.VeSyncBaseDevice {
374
375
  info.push(['Timer: ', this.timer, 'hours']);
375
376
  }
376
377
  for (const [key, value, unit = ''] of info) {
377
- console.log(`${key.toString().padEnd(30, '.')} ${value}${unit}`);
378
+ logger_1.logger.info(`${key.toString().padEnd(30, '.')} ${value}${unit}`);
378
379
  }
379
380
  }
380
381
  /**
@@ -56,6 +56,26 @@ export declare class VeSyncAirBypass extends VeSyncFan {
56
56
  * Turn automatic stop off
57
57
  */
58
58
  automaticStopOff(): Promise<boolean>;
59
+ /**
60
+ * Set auto mode
61
+ */
62
+ autoMode(): Promise<boolean>;
63
+ /**
64
+ * Set manual mode
65
+ */
66
+ manualMode(): Promise<boolean>;
67
+ /**
68
+ * Set sleep mode
69
+ */
70
+ sleepMode(): Promise<boolean>;
71
+ /**
72
+ * Turn off display
73
+ */
74
+ turnOffDisplay(): Promise<boolean>;
75
+ /**
76
+ * Turn on display
77
+ */
78
+ turnOnDisplay(): Promise<boolean>;
59
79
  }
60
80
  /**
61
81
  * VeSync Humidifier Base Class
@@ -118,6 +138,22 @@ export declare class VeSyncHumidifier extends VeSyncFan {
118
138
  * Turn automatic stop off
119
139
  */
120
140
  automaticStopOff(): Promise<boolean>;
141
+ /**
142
+ * Set auto mode
143
+ */
144
+ setAutoMode(): Promise<boolean>;
145
+ /**
146
+ * Set manual mode
147
+ */
148
+ setManualMode(): Promise<boolean>;
149
+ /**
150
+ * Turn off display
151
+ */
152
+ turnOffDisplay(): Promise<boolean>;
153
+ /**
154
+ * Turn on display
155
+ */
156
+ turnOnDisplay(): Promise<boolean>;
121
157
  }
122
158
  /**
123
159
  * VeSync Warm Humidifier Class