tsvesync 1.0.12 → 1.0.14
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/dist/lib/helpers.js +3 -2
- package/dist/lib/logger.d.ts +23 -0
- package/dist/lib/logger.js +54 -0
- package/dist/lib/vesync.js +42 -41
- package/dist/lib/vesyncBaseDevice.js +8 -7
- package/dist/lib/vesyncBulb.d.ts +9 -0
- package/dist/lib/vesyncBulb.js +125 -28
- package/dist/lib/vesyncBulbImpl.d.ts +1 -1
- package/dist/lib/vesyncBulbImpl.js +105 -36
- package/dist/lib/vesyncFan.js +2 -1
- package/dist/lib/vesyncFanImpl.d.ts +36 -0
- package/dist/lib/vesyncFanImpl.js +307 -42
- package/dist/lib/vesyncOutlet.d.ts +17 -0
- package/dist/lib/vesyncOutlet.js +124 -8
- package/dist/lib/vesyncOutletImpl.js +39 -0
- package/dist/lib/vesyncSwitch.d.ts +0 -124
- package/dist/lib/vesyncSwitch.js +3 -343
- package/dist/lib/vesyncSwitchImpl.d.ts +6 -6
- package/dist/lib/vesyncSwitchImpl.js +69 -15
- package/package.json +1 -1
- package/src/lib/helpers.ts +3 -2
- package/src/lib/logger.ts +60 -0
- package/src/lib/vesync.ts +42 -43
- package/src/lib/vesyncBaseDevice.ts +8 -7
- package/src/lib/vesyncBulb.ts +138 -30
- package/src/lib/vesyncBulbImpl.ts +113 -44
- package/src/lib/vesyncFan.ts +2 -4
- package/src/lib/vesyncFanImpl.ts +314 -42
- package/src/lib/vesyncOutlet.ts +140 -13
- package/src/lib/vesyncOutletImpl.ts +41 -0
- package/src/lib/vesyncSwitch.ts +3 -454
- package/src/lib/vesyncSwitchImpl.ts +66 -16
- package/dist/lib/helpers.js.map +0 -1
- package/dist/lib/vesync.js.map +0 -1
- package/dist/lib/vesyncBaseDevice.js.map +0 -1
- package/dist/lib/vesyncBulb.js.map +0 -1
- package/dist/lib/vesyncFan.js.map +0 -1
- package/dist/lib/vesyncKitchen.d.ts +0 -0
- package/dist/lib/vesyncKitchen.js +0 -2
- package/dist/lib/vesyncKitchen.js.map +0 -1
- package/dist/lib/vesyncOutlet.js.map +0 -1
- package/dist/lib/vesyncSwitch.js.map +0 -1
- package/dist/src/lib/helpers.d.ts +0 -88
- package/dist/src/lib/helpers.js +0 -244
- package/dist/src/lib/vesync.d.ts +0 -89
- package/dist/src/lib/vesync.js +0 -430
- package/dist/src/lib/vesyncBaseDevice.d.ts +0 -43
- package/dist/src/lib/vesyncBaseDevice.js +0 -87
- package/dist/src/lib/vesyncBulb.d.ts +0 -79
- package/dist/src/lib/vesyncBulb.js +0 -198
- package/dist/src/lib/vesyncBulbImpl.d.ts +0 -38
- package/dist/src/lib/vesyncBulbImpl.js +0 -161
- package/dist/src/lib/vesyncFan.d.ts +0 -80
- package/dist/src/lib/vesyncFan.js +0 -406
- package/dist/src/lib/vesyncFanImpl.d.ts +0 -137
- package/dist/src/lib/vesyncFanImpl.js +0 -643
- package/dist/src/lib/vesyncOutlet.d.ts +0 -53
- package/dist/src/lib/vesyncOutlet.js +0 -98
- package/dist/src/lib/vesyncOutletImpl.d.ts +0 -70
- package/dist/src/lib/vesyncOutletImpl.js +0 -206
- package/dist/src/lib/vesyncSwitch.d.ts +0 -169
- package/dist/src/lib/vesyncSwitch.js +0 -414
- package/dist/src/lib/vesyncSwitchImpl.d.ts +0 -82
- package/dist/src/lib/vesyncSwitchImpl.js +0 -290
- package/dist/test/testFeatures.d.ts +0 -4
- package/dist/test/testFeatures.js +0 -394
- package/dist/test/testService.d.ts +0 -62
- package/dist/test/testService.js +0 -540
- package/dist/test/testSpecial.d.ts +0 -5
- package/dist/test/testSpecial.js +0 -227
|
@@ -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, '
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
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('/
|
|
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, '
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
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('/
|
|
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, '
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
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('/
|
|
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, '
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
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('/
|
|
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, '
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
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('/
|
|
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, '
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
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('/
|
|
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
|
}
|
package/dist/lib/vesyncFan.js
CHANGED
|
@@ -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
|
-
|
|
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
|