tsvesync 1.0.11
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/LICENSE +21 -0
- package/README.md +227 -0
- package/api/vesync/VeSync.yaml +33 -0
- package/api/vesyncbulb/ESL100.yaml +74 -0
- package/api/vesyncbulb/ESL100CW.yaml +123 -0
- package/api/vesyncbulb/ESL100MC.yaml +169 -0
- package/api/vesyncbulb/XYD0001.yaml +193 -0
- package/api/vesyncfan/Classic200S.yaml +280 -0
- package/api/vesyncfan/Classic300S.yaml +278 -0
- package/api/vesyncfan/Core200S.yaml +256 -0
- package/api/vesyncfan/Core300S.yaml +281 -0
- package/api/vesyncfan/Core400S.yaml +281 -0
- package/api/vesyncfan/Core600S.yaml +281 -0
- package/api/vesyncfan/Dual200S.yaml +278 -0
- package/api/vesyncfan/LAP-C201S-AUSR.yaml +256 -0
- package/api/vesyncfan/LAP-C202S-WUSR.yaml +256 -0
- package/api/vesyncfan/LAP-C301S-WAAA.yaml +281 -0
- package/api/vesyncfan/LAP-C301S-WJP.yaml +281 -0
- package/api/vesyncfan/LAP-C302S-WUSB.yaml +281 -0
- package/api/vesyncfan/LAP-C401S-WAAA.yaml +281 -0
- package/api/vesyncfan/LAP-C401S-WJP.yaml +281 -0
- package/api/vesyncfan/LAP-C401S-WUSR.yaml +281 -0
- package/api/vesyncfan/LAP-C601S-WEU.yaml +281 -0
- package/api/vesyncfan/LAP-C601S-WUS.yaml +281 -0
- package/api/vesyncfan/LAP-C601S-WUSR.yaml +281 -0
- package/api/vesyncfan/LAP-EL551S-AEUR.yaml +167 -0
- package/api/vesyncfan/LAP-EL551S-AUS.yaml +167 -0
- package/api/vesyncfan/LAP-EL551S-WEU.yaml +167 -0
- package/api/vesyncfan/LAP-EL551S-WUS.yaml +167 -0
- package/api/vesyncfan/LAP-V102S-AASR.yaml +167 -0
- package/api/vesyncfan/LAP-V102S-AUSR.yaml +167 -0
- package/api/vesyncfan/LAP-V102S-WEU.yaml +167 -0
- package/api/vesyncfan/LAP-V102S-WJP.yaml +167 -0
- package/api/vesyncfan/LAP-V102S-WUS.yaml +167 -0
- package/api/vesyncfan/LAP-V201-AUSR.yaml +167 -0
- package/api/vesyncfan/LAP-V201S-AASR.yaml +167 -0
- package/api/vesyncfan/LAP-V201S-AEUR.yaml +167 -0
- package/api/vesyncfan/LAP-V201S-AUSR.yaml +167 -0
- package/api/vesyncfan/LAP-V201S-WEU.yaml +167 -0
- package/api/vesyncfan/LAP-V201S-WJP.yaml +167 -0
- package/api/vesyncfan/LAP-V201S-WUS.yaml +167 -0
- package/api/vesyncfan/LEH-S601S-WUS.yaml +303 -0
- package/api/vesyncfan/LEH-S601S-WUSR.yaml +82 -0
- package/api/vesyncfan/LTF-F422S-KEU.yaml +165 -0
- package/api/vesyncfan/LTF-F422S-WUS.yaml +165 -0
- package/api/vesyncfan/LTF-F422S-WUSR.yaml +167 -0
- package/api/vesyncfan/LTF-F422_WJP.yaml +165 -0
- package/api/vesyncfan/LUH-A601S-AUSW.yaml +82 -0
- package/api/vesyncfan/LUH-A601S-WUSB.yaml +305 -0
- package/api/vesyncfan/LUH-A602S-WEU.yaml +305 -0
- package/api/vesyncfan/LUH-A602S-WEUR.yaml +305 -0
- package/api/vesyncfan/LUH-A602S-WJP.yaml +305 -0
- package/api/vesyncfan/LUH-A602S-WUS.yaml +305 -0
- package/api/vesyncfan/LUH-A602S-WUSC.yaml +305 -0
- package/api/vesyncfan/LUH-A602S-WUSR.yaml +305 -0
- package/api/vesyncfan/LUH-D301S-WEU.yaml +305 -0
- package/api/vesyncfan/LUH-D301S-WJP.yaml +305 -0
- package/api/vesyncfan/LUH-D301S-WUSR.yaml +305 -0
- package/api/vesyncfan/LUH-M101S-WUS.yaml +278 -0
- package/api/vesyncfan/LUH-O451S-WEU.yaml +278 -0
- package/api/vesyncfan/LUH-O451S-WUS.yaml +278 -0
- package/api/vesyncfan/LUH-O451S-WUSR.yaml +305 -0
- package/api/vesyncfan/LUH-O601S-KUS.yaml +305 -0
- package/api/vesyncfan/LUH-O601S-WUS.yaml +305 -0
- package/api/vesyncfan/LV-PUR131S.yaml +108 -0
- package/api/vesyncfan/LV-RH131S.yaml +108 -0
- package/api/vesyncoutlet/ESO15-TB.yaml +124 -0
- package/api/vesyncoutlet/ESW01-EU.yaml +122 -0
- package/api/vesyncoutlet/ESW03-USA.yaml +122 -0
- package/api/vesyncoutlet/ESW15-USA.yaml +156 -0
- package/api/vesyncoutlet/wifi-switch-1.3.yaml +60 -0
- package/api/vesyncswitch/ESWD16.yaml +128 -0
- package/api/vesyncswitch/ESWL01.yaml +56 -0
- package/api/vesyncswitch/ESWL03.yaml +56 -0
- package/dist/lib/helpers.d.ts +87 -0
- package/dist/lib/helpers.js +222 -0
- package/dist/lib/helpers.js.map +1 -0
- package/dist/lib/vesync.d.ts +47 -0
- package/dist/lib/vesync.js +309 -0
- package/dist/lib/vesync.js.map +1 -0
- package/dist/lib/vesyncBaseDevice.d.ts +68 -0
- package/dist/lib/vesyncBaseDevice.js +116 -0
- package/dist/lib/vesyncBaseDevice.js.map +1 -0
- package/dist/lib/vesyncBulb.d.ts +0 -0
- package/dist/lib/vesyncBulb.js +2 -0
- package/dist/lib/vesyncBulb.js.map +1 -0
- package/dist/lib/vesyncFan.d.ts +92 -0
- package/dist/lib/vesyncFan.js +265 -0
- package/dist/lib/vesyncFan.js.map +1 -0
- package/dist/lib/vesyncKitchen.d.ts +0 -0
- package/dist/lib/vesyncKitchen.js +2 -0
- package/dist/lib/vesyncKitchen.js.map +1 -0
- package/dist/lib/vesyncOutlet.d.ts +0 -0
- package/dist/lib/vesyncOutlet.js +2 -0
- package/dist/lib/vesyncOutlet.js.map +1 -0
- package/dist/lib/vesyncSwitch.d.ts +0 -0
- package/dist/lib/vesyncSwitch.js +2 -0
- package/dist/lib/vesyncSwitch.js.map +1 -0
- package/dist/src/lib/helpers.d.ts +88 -0
- package/dist/src/lib/helpers.js +244 -0
- package/dist/src/lib/vesync.d.ts +89 -0
- package/dist/src/lib/vesync.js +430 -0
- package/dist/src/lib/vesyncBaseDevice.d.ts +43 -0
- package/dist/src/lib/vesyncBaseDevice.js +87 -0
- package/dist/src/lib/vesyncBulb.d.ts +79 -0
- package/dist/src/lib/vesyncBulb.js +198 -0
- package/dist/src/lib/vesyncBulbImpl.d.ts +38 -0
- package/dist/src/lib/vesyncBulbImpl.js +161 -0
- package/dist/src/lib/vesyncFan.d.ts +80 -0
- package/dist/src/lib/vesyncFan.js +406 -0
- package/dist/src/lib/vesyncFanImpl.d.ts +137 -0
- package/dist/src/lib/vesyncFanImpl.js +643 -0
- package/dist/src/lib/vesyncOutlet.d.ts +53 -0
- package/dist/src/lib/vesyncOutlet.js +98 -0
- package/dist/src/lib/vesyncOutletImpl.d.ts +70 -0
- package/dist/src/lib/vesyncOutletImpl.js +206 -0
- package/dist/src/lib/vesyncSwitch.d.ts +169 -0
- package/dist/src/lib/vesyncSwitch.js +414 -0
- package/dist/src/lib/vesyncSwitchImpl.d.ts +82 -0
- package/dist/src/lib/vesyncSwitchImpl.js +290 -0
- package/dist/test/testFeatures.d.ts +4 -0
- package/dist/test/testFeatures.js +394 -0
- package/dist/test/testService.d.ts +62 -0
- package/dist/test/testService.js +540 -0
- package/dist/test/testSpecial.d.ts +5 -0
- package/dist/test/testSpecial.js +227 -0
- package/package.json +53 -0
- package/src/lib/helpers.ts +290 -0
- package/src/lib/vesync.ts +530 -0
- package/src/lib/vesyncBaseDevice.ts +114 -0
- package/src/lib/vesyncBulb.ts +252 -0
- package/src/lib/vesyncBulbImpl.ts +215 -0
- package/src/lib/vesyncFan.ts +447 -0
- package/src/lib/vesyncFanImpl.ts +848 -0
- package/src/lib/vesyncOutlet.ts +148 -0
- package/src/lib/vesyncOutletImpl.ts +284 -0
- package/src/lib/vesyncSwitch.ts +546 -0
- package/src/lib/vesyncSwitchImpl.ts +408 -0
|
@@ -0,0 +1,252 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* VeSync Bulb Base Class
|
|
3
|
+
*/
|
|
4
|
+
|
|
5
|
+
import { VeSyncBaseDevice } from './vesyncBaseDevice';
|
|
6
|
+
import { VeSync } from './vesync';
|
|
7
|
+
import { Helpers } from './helpers';
|
|
8
|
+
|
|
9
|
+
// Feature dictionary for bulb types
|
|
10
|
+
const featureDict: Record<string, { features: string[], colorModel: string }> = {
|
|
11
|
+
'ESL100': {
|
|
12
|
+
features: ['dimmable'],
|
|
13
|
+
colorModel: 'none'
|
|
14
|
+
},
|
|
15
|
+
'ESL100CW': {
|
|
16
|
+
features: ['dimmable', 'color_temp'],
|
|
17
|
+
colorModel: 'none'
|
|
18
|
+
},
|
|
19
|
+
'XYD0001': {
|
|
20
|
+
features: ['dimmable', 'color_temp', 'rgb_shift'],
|
|
21
|
+
colorModel: 'hsv'
|
|
22
|
+
},
|
|
23
|
+
'ESL100MC': {
|
|
24
|
+
features: ['dimmable', 'rgb_shift'],
|
|
25
|
+
colorModel: 'rgb'
|
|
26
|
+
}
|
|
27
|
+
};
|
|
28
|
+
|
|
29
|
+
/**
|
|
30
|
+
* VeSync Bulb Base Class
|
|
31
|
+
*/
|
|
32
|
+
export abstract class VeSyncBulb extends VeSyncBaseDevice {
|
|
33
|
+
protected brightness: number;
|
|
34
|
+
protected colorTemp: number;
|
|
35
|
+
protected colorValue: number;
|
|
36
|
+
protected colorHue: number;
|
|
37
|
+
protected colorSaturation: number;
|
|
38
|
+
protected colorMode: string;
|
|
39
|
+
protected features: string[];
|
|
40
|
+
protected rgbValues: { red: number, green: number, blue: number };
|
|
41
|
+
|
|
42
|
+
constructor(details: Record<string, any>, manager: VeSync) {
|
|
43
|
+
super(details, manager);
|
|
44
|
+
this.brightness = 0;
|
|
45
|
+
this.colorTemp = 0;
|
|
46
|
+
this.colorValue = 0;
|
|
47
|
+
this.colorHue = 0;
|
|
48
|
+
this.colorSaturation = 0;
|
|
49
|
+
this.colorMode = '';
|
|
50
|
+
this.features = featureDict[this.deviceType]?.features || [];
|
|
51
|
+
this.rgbValues = {
|
|
52
|
+
red: 0,
|
|
53
|
+
green: 0,
|
|
54
|
+
blue: 0
|
|
55
|
+
};
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
/**
|
|
59
|
+
* Get bulb details
|
|
60
|
+
*/
|
|
61
|
+
async getDetails(): Promise<void> {
|
|
62
|
+
const body = {
|
|
63
|
+
...Helpers.reqBody(this.manager, 'devicedetail'),
|
|
64
|
+
uuid: this.cid,
|
|
65
|
+
method: 'devicedetail'
|
|
66
|
+
};
|
|
67
|
+
|
|
68
|
+
const [response] = await Helpers.callApi(
|
|
69
|
+
'/SmartBulb/v1/device/devicedetail',
|
|
70
|
+
'post',
|
|
71
|
+
body,
|
|
72
|
+
Helpers.reqHeaders(this.manager)
|
|
73
|
+
);
|
|
74
|
+
|
|
75
|
+
if (response?.code === 0 && response?.result) {
|
|
76
|
+
this.deviceStatus = response.result.deviceStatus || this.deviceStatus;
|
|
77
|
+
this.brightness = response.result.brightness || this.brightness;
|
|
78
|
+
if (this.features.includes('color_temp')) {
|
|
79
|
+
this.colorTemp = response.result.colorTemp || this.colorTemp;
|
|
80
|
+
}
|
|
81
|
+
if (this.features.includes('rgb_shift')) {
|
|
82
|
+
if (featureDict[this.deviceType].colorModel === 'rgb') {
|
|
83
|
+
this.rgbValues = {
|
|
84
|
+
red: response.result.red || this.rgbValues.red,
|
|
85
|
+
green: response.result.green || this.rgbValues.green,
|
|
86
|
+
blue: response.result.blue || this.rgbValues.blue
|
|
87
|
+
};
|
|
88
|
+
} else {
|
|
89
|
+
this.colorHue = response.result.hue || this.colorHue;
|
|
90
|
+
this.colorSaturation = response.result.saturation || this.colorSaturation;
|
|
91
|
+
this.colorValue = response.result.value || this.colorValue;
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
/**
|
|
98
|
+
* Update bulb status
|
|
99
|
+
*/
|
|
100
|
+
async update(): Promise<void> {
|
|
101
|
+
await this.getDetails();
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
/**
|
|
105
|
+
* Turn bulb on
|
|
106
|
+
*/
|
|
107
|
+
async turnOn(): Promise<boolean> {
|
|
108
|
+
const body = {
|
|
109
|
+
...Helpers.reqBody(this.manager, 'devicestatus'),
|
|
110
|
+
uuid: this.cid,
|
|
111
|
+
status: 'on'
|
|
112
|
+
};
|
|
113
|
+
|
|
114
|
+
const [response] = await Helpers.callApi(
|
|
115
|
+
'/SmartBulb/v1/device/devicestatus',
|
|
116
|
+
'put',
|
|
117
|
+
body,
|
|
118
|
+
Helpers.reqHeaders(this.manager)
|
|
119
|
+
);
|
|
120
|
+
|
|
121
|
+
if (response?.code === 0) {
|
|
122
|
+
this.deviceStatus = 'on';
|
|
123
|
+
return true;
|
|
124
|
+
}
|
|
125
|
+
return false;
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
/**
|
|
129
|
+
* Turn bulb off
|
|
130
|
+
*/
|
|
131
|
+
async turnOff(): Promise<boolean> {
|
|
132
|
+
const body = {
|
|
133
|
+
...Helpers.reqBody(this.manager, 'devicestatus'),
|
|
134
|
+
uuid: this.cid,
|
|
135
|
+
status: 'off'
|
|
136
|
+
};
|
|
137
|
+
|
|
138
|
+
const [response] = await Helpers.callApi(
|
|
139
|
+
'/SmartBulb/v1/device/devicestatus',
|
|
140
|
+
'put',
|
|
141
|
+
body,
|
|
142
|
+
Helpers.reqHeaders(this.manager)
|
|
143
|
+
);
|
|
144
|
+
|
|
145
|
+
if (response?.code === 0) {
|
|
146
|
+
this.deviceStatus = 'off';
|
|
147
|
+
return true;
|
|
148
|
+
}
|
|
149
|
+
return false;
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
/**
|
|
153
|
+
* Set bulb brightness
|
|
154
|
+
*/
|
|
155
|
+
async setBrightness(brightness: number): Promise<boolean> {
|
|
156
|
+
if (!this.features.includes('dimmable')) {
|
|
157
|
+
return false;
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
const body = {
|
|
161
|
+
...Helpers.reqBody(this.manager, 'devicestatus'),
|
|
162
|
+
uuid: this.cid,
|
|
163
|
+
status: 'on',
|
|
164
|
+
brightNess: brightness.toString()
|
|
165
|
+
};
|
|
166
|
+
|
|
167
|
+
const [response] = await Helpers.callApi(
|
|
168
|
+
'/SmartBulb/v1/device/updateBrightness',
|
|
169
|
+
'put',
|
|
170
|
+
body,
|
|
171
|
+
Helpers.reqHeaders(this.manager)
|
|
172
|
+
);
|
|
173
|
+
|
|
174
|
+
if (response?.code === 0) {
|
|
175
|
+
this.brightness = brightness;
|
|
176
|
+
return true;
|
|
177
|
+
}
|
|
178
|
+
return false;
|
|
179
|
+
}
|
|
180
|
+
|
|
181
|
+
/**
|
|
182
|
+
* Get bulb brightness
|
|
183
|
+
*/
|
|
184
|
+
getBrightness(): number {
|
|
185
|
+
return this.brightness;
|
|
186
|
+
}
|
|
187
|
+
|
|
188
|
+
/**
|
|
189
|
+
* Get color temperature in Kelvin
|
|
190
|
+
*/
|
|
191
|
+
getColorTempKelvin(): number {
|
|
192
|
+
if (!this.features.includes('color_temp')) {
|
|
193
|
+
return 0;
|
|
194
|
+
}
|
|
195
|
+
return ((6500 - 2700) * this.colorTemp / 100) + 2700;
|
|
196
|
+
}
|
|
197
|
+
|
|
198
|
+
/**
|
|
199
|
+
* Get color temperature in percent
|
|
200
|
+
*/
|
|
201
|
+
getColorTempPercent(): number {
|
|
202
|
+
if (!this.features.includes('color_temp')) {
|
|
203
|
+
return 0;
|
|
204
|
+
}
|
|
205
|
+
return this.colorTemp;
|
|
206
|
+
}
|
|
207
|
+
|
|
208
|
+
/**
|
|
209
|
+
* Get color hue
|
|
210
|
+
*/
|
|
211
|
+
getColorHue(): number {
|
|
212
|
+
if (!this.features.includes('rgb_shift')) {
|
|
213
|
+
return 0;
|
|
214
|
+
}
|
|
215
|
+
return this.colorHue;
|
|
216
|
+
}
|
|
217
|
+
|
|
218
|
+
/**
|
|
219
|
+
* Get color saturation
|
|
220
|
+
*/
|
|
221
|
+
getColorSaturation(): number {
|
|
222
|
+
if (!this.features.includes('rgb_shift')) {
|
|
223
|
+
return 0;
|
|
224
|
+
}
|
|
225
|
+
return this.colorSaturation;
|
|
226
|
+
}
|
|
227
|
+
|
|
228
|
+
/**
|
|
229
|
+
* Get color value
|
|
230
|
+
*/
|
|
231
|
+
getColorValue(): number {
|
|
232
|
+
if (!this.features.includes('rgb_shift')) {
|
|
233
|
+
return 0;
|
|
234
|
+
}
|
|
235
|
+
return this.colorValue;
|
|
236
|
+
}
|
|
237
|
+
|
|
238
|
+
/**
|
|
239
|
+
* Get RGB values
|
|
240
|
+
*/
|
|
241
|
+
getRGBValues(): { red: number, green: number, blue: number } {
|
|
242
|
+
if (!this.features.includes('rgb_shift') || featureDict[this.deviceType].colorModel !== 'rgb') {
|
|
243
|
+
return { red: 0, green: 0, blue: 0 };
|
|
244
|
+
}
|
|
245
|
+
return this.rgbValues;
|
|
246
|
+
}
|
|
247
|
+
|
|
248
|
+
/**
|
|
249
|
+
* Set color temperature - Abstract method to be implemented by subclasses
|
|
250
|
+
*/
|
|
251
|
+
abstract setColorTemp(colorTemp: number): Promise<boolean>;
|
|
252
|
+
}
|
|
@@ -0,0 +1,215 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* VeSync Bulb Implementations
|
|
3
|
+
*/
|
|
4
|
+
|
|
5
|
+
import { VeSyncBulb } from './vesyncBulb';
|
|
6
|
+
import { VeSync } from './vesync';
|
|
7
|
+
import { Helpers } from './helpers';
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* ESL100 Bulb Implementation
|
|
11
|
+
*/
|
|
12
|
+
export class VeSyncBulbESL100 extends VeSyncBulb {
|
|
13
|
+
constructor(details: Record<string, any>, manager: VeSync) {
|
|
14
|
+
super(details, manager);
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
async setColorTemp(colorTemp: number): Promise<boolean> {
|
|
18
|
+
return false;
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
/**
|
|
23
|
+
* ESL100CW Bulb Implementation
|
|
24
|
+
*/
|
|
25
|
+
export class VeSyncBulbESL100CW extends VeSyncBulb {
|
|
26
|
+
constructor(details: Record<string, any>, manager: VeSync) {
|
|
27
|
+
super(details, manager);
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
async setColorTemp(colorTemp: number): Promise<boolean> {
|
|
31
|
+
if (!this.features.includes('color_temp')) {
|
|
32
|
+
return false;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
const body = {
|
|
36
|
+
...Helpers.reqBody(this.manager, 'devicestatus'),
|
|
37
|
+
uuid: this.cid,
|
|
38
|
+
status: 'on',
|
|
39
|
+
colorTemp: colorTemp.toString()
|
|
40
|
+
};
|
|
41
|
+
|
|
42
|
+
const [response] = await Helpers.callApi(
|
|
43
|
+
'/SmartBulb/v1/device/updateColorTemperature',
|
|
44
|
+
'put',
|
|
45
|
+
body,
|
|
46
|
+
Helpers.reqHeaders(this.manager)
|
|
47
|
+
);
|
|
48
|
+
|
|
49
|
+
if (response?.code === 0) {
|
|
50
|
+
this.colorTemp = colorTemp;
|
|
51
|
+
return true;
|
|
52
|
+
}
|
|
53
|
+
return false;
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
/**
|
|
58
|
+
* XYD0001 Bulb Implementation
|
|
59
|
+
*/
|
|
60
|
+
export class VeSyncBulbXYD0001 extends VeSyncBulb {
|
|
61
|
+
constructor(details: Record<string, any>, manager: VeSync) {
|
|
62
|
+
super(details, manager);
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
async setColorTemp(colorTemp: number): Promise<boolean> {
|
|
66
|
+
if (!this.features.includes('color_temp')) {
|
|
67
|
+
return false;
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
const body = {
|
|
71
|
+
...Helpers.reqBody(this.manager, 'devicestatus'),
|
|
72
|
+
uuid: this.cid,
|
|
73
|
+
status: 'on',
|
|
74
|
+
colorTemp: colorTemp.toString()
|
|
75
|
+
};
|
|
76
|
+
|
|
77
|
+
const [response] = await Helpers.callApi(
|
|
78
|
+
'/SmartBulb/v1/device/updateColorTemperature',
|
|
79
|
+
'put',
|
|
80
|
+
body,
|
|
81
|
+
Helpers.reqHeaders(this.manager)
|
|
82
|
+
);
|
|
83
|
+
|
|
84
|
+
if (response?.code === 0) {
|
|
85
|
+
this.colorTemp = colorTemp;
|
|
86
|
+
return true;
|
|
87
|
+
}
|
|
88
|
+
return false;
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
async setHsv(hue: number, saturation: number, value: number): Promise<boolean> {
|
|
92
|
+
if (!this.features.includes('rgb_shift')) {
|
|
93
|
+
return false;
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
const body = {
|
|
97
|
+
...Helpers.reqBody(this.manager, 'devicestatus'),
|
|
98
|
+
uuid: this.cid,
|
|
99
|
+
status: 'on',
|
|
100
|
+
mode: 'color',
|
|
101
|
+
hue: Math.round(hue).toString(),
|
|
102
|
+
saturation: Math.round(saturation).toString(),
|
|
103
|
+
brightness: Math.round(value).toString()
|
|
104
|
+
};
|
|
105
|
+
|
|
106
|
+
const [response] = await Helpers.callApi(
|
|
107
|
+
'/SmartBulb/v1/device/updateColor',
|
|
108
|
+
'put',
|
|
109
|
+
body,
|
|
110
|
+
Helpers.reqHeaders(this.manager)
|
|
111
|
+
);
|
|
112
|
+
|
|
113
|
+
if (response?.code === 0) {
|
|
114
|
+
this.colorHue = hue;
|
|
115
|
+
this.colorSaturation = saturation;
|
|
116
|
+
this.colorValue = value;
|
|
117
|
+
return true;
|
|
118
|
+
}
|
|
119
|
+
return false;
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
async enableWhiteMode(): Promise<boolean> {
|
|
123
|
+
const body = {
|
|
124
|
+
...Helpers.reqBody(this.manager, 'devicestatus'),
|
|
125
|
+
uuid: this.cid,
|
|
126
|
+
status: 'on',
|
|
127
|
+
colorMode: 'white'
|
|
128
|
+
};
|
|
129
|
+
|
|
130
|
+
const [response] = await Helpers.callApi(
|
|
131
|
+
'/SmartBulb/v1/device/updateColorMode',
|
|
132
|
+
'put',
|
|
133
|
+
body,
|
|
134
|
+
Helpers.reqHeaders(this.manager)
|
|
135
|
+
);
|
|
136
|
+
|
|
137
|
+
if (response?.code === 0) {
|
|
138
|
+
this.colorMode = 'white';
|
|
139
|
+
return true;
|
|
140
|
+
}
|
|
141
|
+
return false;
|
|
142
|
+
}
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
/**
|
|
146
|
+
* ESL100MC Bulb Implementation
|
|
147
|
+
*/
|
|
148
|
+
export class VeSyncBulbESL100MC extends VeSyncBulb {
|
|
149
|
+
constructor(details: Record<string, any>, manager: VeSync) {
|
|
150
|
+
super(details, manager);
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
async setColorTemp(colorTemp: number): Promise<boolean> {
|
|
154
|
+
return false;
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
async setRgb(red: number, green: number, blue: number): Promise<boolean> {
|
|
158
|
+
if (!this.features.includes('rgb_shift')) {
|
|
159
|
+
return false;
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
const body = {
|
|
163
|
+
...Helpers.reqBody(this.manager, 'devicestatus'),
|
|
164
|
+
uuid: this.cid,
|
|
165
|
+
status: 'on',
|
|
166
|
+
mode: 'color',
|
|
167
|
+
red: Math.round(red).toString(),
|
|
168
|
+
green: Math.round(green).toString(),
|
|
169
|
+
blue: Math.round(blue).toString()
|
|
170
|
+
};
|
|
171
|
+
|
|
172
|
+
const [response] = await Helpers.callApi(
|
|
173
|
+
'/SmartBulb/v1/device/updateColor',
|
|
174
|
+
'put',
|
|
175
|
+
body,
|
|
176
|
+
Helpers.reqHeaders(this.manager)
|
|
177
|
+
);
|
|
178
|
+
|
|
179
|
+
if (response?.code === 0) {
|
|
180
|
+
this.rgbValues = { red, green, blue };
|
|
181
|
+
return true;
|
|
182
|
+
}
|
|
183
|
+
return false;
|
|
184
|
+
}
|
|
185
|
+
|
|
186
|
+
async enableWhiteMode(): Promise<boolean> {
|
|
187
|
+
const body = {
|
|
188
|
+
...Helpers.reqBody(this.manager, 'devicestatus'),
|
|
189
|
+
uuid: this.cid,
|
|
190
|
+
status: 'on',
|
|
191
|
+
colorMode: 'white'
|
|
192
|
+
};
|
|
193
|
+
|
|
194
|
+
const [response] = await Helpers.callApi(
|
|
195
|
+
'/SmartBulb/v1/device/updateColorMode',
|
|
196
|
+
'put',
|
|
197
|
+
body,
|
|
198
|
+
Helpers.reqHeaders(this.manager)
|
|
199
|
+
);
|
|
200
|
+
|
|
201
|
+
if (response?.code === 0) {
|
|
202
|
+
this.colorMode = 'white';
|
|
203
|
+
return true;
|
|
204
|
+
}
|
|
205
|
+
return false;
|
|
206
|
+
}
|
|
207
|
+
}
|
|
208
|
+
|
|
209
|
+
// Export the bulb modules dictionary
|
|
210
|
+
export const bulbModules: Record<string, any> = {
|
|
211
|
+
'ESL100': VeSyncBulbESL100,
|
|
212
|
+
'ESL100CW': VeSyncBulbESL100CW,
|
|
213
|
+
'XYD0001': VeSyncBulbXYD0001,
|
|
214
|
+
'ESL100MC': VeSyncBulbESL100MC
|
|
215
|
+
};
|