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,79 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* VeSync Bulb Base Class
|
|
3
|
+
*/
|
|
4
|
+
import { VeSyncBaseDevice } from './vesyncBaseDevice';
|
|
5
|
+
import { VeSync } from './vesync';
|
|
6
|
+
/**
|
|
7
|
+
* VeSync Bulb Base Class
|
|
8
|
+
*/
|
|
9
|
+
export declare abstract class VeSyncBulb extends VeSyncBaseDevice {
|
|
10
|
+
protected brightness: number;
|
|
11
|
+
protected colorTemp: number;
|
|
12
|
+
protected colorValue: number;
|
|
13
|
+
protected colorHue: number;
|
|
14
|
+
protected colorSaturation: number;
|
|
15
|
+
protected colorMode: string;
|
|
16
|
+
protected features: string[];
|
|
17
|
+
protected rgbValues: {
|
|
18
|
+
red: number;
|
|
19
|
+
green: number;
|
|
20
|
+
blue: number;
|
|
21
|
+
};
|
|
22
|
+
constructor(details: Record<string, any>, manager: VeSync);
|
|
23
|
+
/**
|
|
24
|
+
* Get bulb details
|
|
25
|
+
*/
|
|
26
|
+
getDetails(): Promise<void>;
|
|
27
|
+
/**
|
|
28
|
+
* Update bulb status
|
|
29
|
+
*/
|
|
30
|
+
update(): Promise<void>;
|
|
31
|
+
/**
|
|
32
|
+
* Turn bulb on
|
|
33
|
+
*/
|
|
34
|
+
turnOn(): Promise<boolean>;
|
|
35
|
+
/**
|
|
36
|
+
* Turn bulb off
|
|
37
|
+
*/
|
|
38
|
+
turnOff(): Promise<boolean>;
|
|
39
|
+
/**
|
|
40
|
+
* Set bulb brightness
|
|
41
|
+
*/
|
|
42
|
+
setBrightness(brightness: number): Promise<boolean>;
|
|
43
|
+
/**
|
|
44
|
+
* Get bulb brightness
|
|
45
|
+
*/
|
|
46
|
+
getBrightness(): number;
|
|
47
|
+
/**
|
|
48
|
+
* Get color temperature in Kelvin
|
|
49
|
+
*/
|
|
50
|
+
getColorTempKelvin(): number;
|
|
51
|
+
/**
|
|
52
|
+
* Get color temperature in percent
|
|
53
|
+
*/
|
|
54
|
+
getColorTempPercent(): number;
|
|
55
|
+
/**
|
|
56
|
+
* Get color hue
|
|
57
|
+
*/
|
|
58
|
+
getColorHue(): number;
|
|
59
|
+
/**
|
|
60
|
+
* Get color saturation
|
|
61
|
+
*/
|
|
62
|
+
getColorSaturation(): number;
|
|
63
|
+
/**
|
|
64
|
+
* Get color value
|
|
65
|
+
*/
|
|
66
|
+
getColorValue(): number;
|
|
67
|
+
/**
|
|
68
|
+
* Get RGB values
|
|
69
|
+
*/
|
|
70
|
+
getRGBValues(): {
|
|
71
|
+
red: number;
|
|
72
|
+
green: number;
|
|
73
|
+
blue: number;
|
|
74
|
+
};
|
|
75
|
+
/**
|
|
76
|
+
* Set color temperature - Abstract method to be implemented by subclasses
|
|
77
|
+
*/
|
|
78
|
+
abstract setColorTemp(colorTemp: number): Promise<boolean>;
|
|
79
|
+
}
|
|
@@ -0,0 +1,198 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* VeSync Bulb Base Class
|
|
4
|
+
*/
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.VeSyncBulb = void 0;
|
|
7
|
+
const vesyncBaseDevice_1 = require("./vesyncBaseDevice");
|
|
8
|
+
const helpers_1 = require("./helpers");
|
|
9
|
+
// Feature dictionary for bulb types
|
|
10
|
+
const featureDict = {
|
|
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
|
+
* VeSync Bulb Base Class
|
|
30
|
+
*/
|
|
31
|
+
class VeSyncBulb extends vesyncBaseDevice_1.VeSyncBaseDevice {
|
|
32
|
+
constructor(details, manager) {
|
|
33
|
+
super(details, manager);
|
|
34
|
+
this.brightness = 0;
|
|
35
|
+
this.colorTemp = 0;
|
|
36
|
+
this.colorValue = 0;
|
|
37
|
+
this.colorHue = 0;
|
|
38
|
+
this.colorSaturation = 0;
|
|
39
|
+
this.colorMode = '';
|
|
40
|
+
this.features = featureDict[this.deviceType]?.features || [];
|
|
41
|
+
this.rgbValues = {
|
|
42
|
+
red: 0,
|
|
43
|
+
green: 0,
|
|
44
|
+
blue: 0
|
|
45
|
+
};
|
|
46
|
+
}
|
|
47
|
+
/**
|
|
48
|
+
* Get bulb details
|
|
49
|
+
*/
|
|
50
|
+
async getDetails() {
|
|
51
|
+
const body = {
|
|
52
|
+
...helpers_1.Helpers.reqBody(this.manager, 'devicedetail'),
|
|
53
|
+
uuid: this.cid,
|
|
54
|
+
method: 'devicedetail'
|
|
55
|
+
};
|
|
56
|
+
const [response] = await helpers_1.Helpers.callApi('/SmartBulb/v1/device/devicedetail', 'post', body, helpers_1.Helpers.reqHeaders(this.manager));
|
|
57
|
+
if (response?.code === 0 && response?.result) {
|
|
58
|
+
this.deviceStatus = response.result.deviceStatus || this.deviceStatus;
|
|
59
|
+
this.brightness = response.result.brightness || this.brightness;
|
|
60
|
+
if (this.features.includes('color_temp')) {
|
|
61
|
+
this.colorTemp = response.result.colorTemp || this.colorTemp;
|
|
62
|
+
}
|
|
63
|
+
if (this.features.includes('rgb_shift')) {
|
|
64
|
+
if (featureDict[this.deviceType].colorModel === 'rgb') {
|
|
65
|
+
this.rgbValues = {
|
|
66
|
+
red: response.result.red || this.rgbValues.red,
|
|
67
|
+
green: response.result.green || this.rgbValues.green,
|
|
68
|
+
blue: response.result.blue || this.rgbValues.blue
|
|
69
|
+
};
|
|
70
|
+
}
|
|
71
|
+
else {
|
|
72
|
+
this.colorHue = response.result.hue || this.colorHue;
|
|
73
|
+
this.colorSaturation = response.result.saturation || this.colorSaturation;
|
|
74
|
+
this.colorValue = response.result.value || this.colorValue;
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
/**
|
|
80
|
+
* Update bulb status
|
|
81
|
+
*/
|
|
82
|
+
async update() {
|
|
83
|
+
await this.getDetails();
|
|
84
|
+
}
|
|
85
|
+
/**
|
|
86
|
+
* Turn bulb on
|
|
87
|
+
*/
|
|
88
|
+
async turnOn() {
|
|
89
|
+
const body = {
|
|
90
|
+
...helpers_1.Helpers.reqBody(this.manager, 'devicestatus'),
|
|
91
|
+
uuid: this.cid,
|
|
92
|
+
status: 'on'
|
|
93
|
+
};
|
|
94
|
+
const [response] = await helpers_1.Helpers.callApi('/SmartBulb/v1/device/devicestatus', 'put', body, helpers_1.Helpers.reqHeaders(this.manager));
|
|
95
|
+
if (response?.code === 0) {
|
|
96
|
+
this.deviceStatus = 'on';
|
|
97
|
+
return true;
|
|
98
|
+
}
|
|
99
|
+
return false;
|
|
100
|
+
}
|
|
101
|
+
/**
|
|
102
|
+
* Turn bulb off
|
|
103
|
+
*/
|
|
104
|
+
async turnOff() {
|
|
105
|
+
const body = {
|
|
106
|
+
...helpers_1.Helpers.reqBody(this.manager, 'devicestatus'),
|
|
107
|
+
uuid: this.cid,
|
|
108
|
+
status: 'off'
|
|
109
|
+
};
|
|
110
|
+
const [response] = await helpers_1.Helpers.callApi('/SmartBulb/v1/device/devicestatus', 'put', body, helpers_1.Helpers.reqHeaders(this.manager));
|
|
111
|
+
if (response?.code === 0) {
|
|
112
|
+
this.deviceStatus = 'off';
|
|
113
|
+
return true;
|
|
114
|
+
}
|
|
115
|
+
return false;
|
|
116
|
+
}
|
|
117
|
+
/**
|
|
118
|
+
* Set bulb brightness
|
|
119
|
+
*/
|
|
120
|
+
async setBrightness(brightness) {
|
|
121
|
+
if (!this.features.includes('dimmable')) {
|
|
122
|
+
return false;
|
|
123
|
+
}
|
|
124
|
+
const body = {
|
|
125
|
+
...helpers_1.Helpers.reqBody(this.manager, 'devicestatus'),
|
|
126
|
+
uuid: this.cid,
|
|
127
|
+
status: 'on',
|
|
128
|
+
brightNess: brightness.toString()
|
|
129
|
+
};
|
|
130
|
+
const [response] = await helpers_1.Helpers.callApi('/SmartBulb/v1/device/updateBrightness', 'put', body, helpers_1.Helpers.reqHeaders(this.manager));
|
|
131
|
+
if (response?.code === 0) {
|
|
132
|
+
this.brightness = brightness;
|
|
133
|
+
return true;
|
|
134
|
+
}
|
|
135
|
+
return false;
|
|
136
|
+
}
|
|
137
|
+
/**
|
|
138
|
+
* Get bulb brightness
|
|
139
|
+
*/
|
|
140
|
+
getBrightness() {
|
|
141
|
+
return this.brightness;
|
|
142
|
+
}
|
|
143
|
+
/**
|
|
144
|
+
* Get color temperature in Kelvin
|
|
145
|
+
*/
|
|
146
|
+
getColorTempKelvin() {
|
|
147
|
+
if (!this.features.includes('color_temp')) {
|
|
148
|
+
return 0;
|
|
149
|
+
}
|
|
150
|
+
return ((6500 - 2700) * this.colorTemp / 100) + 2700;
|
|
151
|
+
}
|
|
152
|
+
/**
|
|
153
|
+
* Get color temperature in percent
|
|
154
|
+
*/
|
|
155
|
+
getColorTempPercent() {
|
|
156
|
+
if (!this.features.includes('color_temp')) {
|
|
157
|
+
return 0;
|
|
158
|
+
}
|
|
159
|
+
return this.colorTemp;
|
|
160
|
+
}
|
|
161
|
+
/**
|
|
162
|
+
* Get color hue
|
|
163
|
+
*/
|
|
164
|
+
getColorHue() {
|
|
165
|
+
if (!this.features.includes('rgb_shift')) {
|
|
166
|
+
return 0;
|
|
167
|
+
}
|
|
168
|
+
return this.colorHue;
|
|
169
|
+
}
|
|
170
|
+
/**
|
|
171
|
+
* Get color saturation
|
|
172
|
+
*/
|
|
173
|
+
getColorSaturation() {
|
|
174
|
+
if (!this.features.includes('rgb_shift')) {
|
|
175
|
+
return 0;
|
|
176
|
+
}
|
|
177
|
+
return this.colorSaturation;
|
|
178
|
+
}
|
|
179
|
+
/**
|
|
180
|
+
* Get color value
|
|
181
|
+
*/
|
|
182
|
+
getColorValue() {
|
|
183
|
+
if (!this.features.includes('rgb_shift')) {
|
|
184
|
+
return 0;
|
|
185
|
+
}
|
|
186
|
+
return this.colorValue;
|
|
187
|
+
}
|
|
188
|
+
/**
|
|
189
|
+
* Get RGB values
|
|
190
|
+
*/
|
|
191
|
+
getRGBValues() {
|
|
192
|
+
if (!this.features.includes('rgb_shift') || featureDict[this.deviceType].colorModel !== 'rgb') {
|
|
193
|
+
return { red: 0, green: 0, blue: 0 };
|
|
194
|
+
}
|
|
195
|
+
return this.rgbValues;
|
|
196
|
+
}
|
|
197
|
+
}
|
|
198
|
+
exports.VeSyncBulb = VeSyncBulb;
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* VeSync Bulb Implementations
|
|
3
|
+
*/
|
|
4
|
+
import { VeSyncBulb } from './vesyncBulb';
|
|
5
|
+
import { VeSync } from './vesync';
|
|
6
|
+
/**
|
|
7
|
+
* ESL100 Bulb Implementation
|
|
8
|
+
*/
|
|
9
|
+
export declare class VeSyncBulbESL100 extends VeSyncBulb {
|
|
10
|
+
constructor(details: Record<string, any>, manager: VeSync);
|
|
11
|
+
setColorTemp(colorTemp: number): Promise<boolean>;
|
|
12
|
+
}
|
|
13
|
+
/**
|
|
14
|
+
* ESL100CW Bulb Implementation
|
|
15
|
+
*/
|
|
16
|
+
export declare class VeSyncBulbESL100CW extends VeSyncBulb {
|
|
17
|
+
constructor(details: Record<string, any>, manager: VeSync);
|
|
18
|
+
setColorTemp(colorTemp: number): Promise<boolean>;
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* XYD0001 Bulb Implementation
|
|
22
|
+
*/
|
|
23
|
+
export declare class VeSyncBulbXYD0001 extends VeSyncBulb {
|
|
24
|
+
constructor(details: Record<string, any>, manager: VeSync);
|
|
25
|
+
setColorTemp(colorTemp: number): Promise<boolean>;
|
|
26
|
+
setHsv(hue: number, saturation: number, value: number): Promise<boolean>;
|
|
27
|
+
enableWhiteMode(): Promise<boolean>;
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
* ESL100MC Bulb Implementation
|
|
31
|
+
*/
|
|
32
|
+
export declare class VeSyncBulbESL100MC extends VeSyncBulb {
|
|
33
|
+
constructor(details: Record<string, any>, manager: VeSync);
|
|
34
|
+
setColorTemp(colorTemp: number): Promise<boolean>;
|
|
35
|
+
setRgb(red: number, green: number, blue: number): Promise<boolean>;
|
|
36
|
+
enableWhiteMode(): Promise<boolean>;
|
|
37
|
+
}
|
|
38
|
+
export declare const bulbModules: Record<string, any>;
|
|
@@ -0,0 +1,161 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* VeSync Bulb Implementations
|
|
4
|
+
*/
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.bulbModules = exports.VeSyncBulbESL100MC = exports.VeSyncBulbXYD0001 = exports.VeSyncBulbESL100CW = exports.VeSyncBulbESL100 = void 0;
|
|
7
|
+
const vesyncBulb_1 = require("./vesyncBulb");
|
|
8
|
+
const helpers_1 = require("./helpers");
|
|
9
|
+
/**
|
|
10
|
+
* ESL100 Bulb Implementation
|
|
11
|
+
*/
|
|
12
|
+
class VeSyncBulbESL100 extends vesyncBulb_1.VeSyncBulb {
|
|
13
|
+
constructor(details, manager) {
|
|
14
|
+
super(details, manager);
|
|
15
|
+
}
|
|
16
|
+
async setColorTemp(colorTemp) {
|
|
17
|
+
return false;
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
exports.VeSyncBulbESL100 = VeSyncBulbESL100;
|
|
21
|
+
/**
|
|
22
|
+
* ESL100CW Bulb Implementation
|
|
23
|
+
*/
|
|
24
|
+
class VeSyncBulbESL100CW extends vesyncBulb_1.VeSyncBulb {
|
|
25
|
+
constructor(details, manager) {
|
|
26
|
+
super(details, manager);
|
|
27
|
+
}
|
|
28
|
+
async setColorTemp(colorTemp) {
|
|
29
|
+
if (!this.features.includes('color_temp')) {
|
|
30
|
+
return false;
|
|
31
|
+
}
|
|
32
|
+
const body = {
|
|
33
|
+
...helpers_1.Helpers.reqBody(this.manager, 'devicestatus'),
|
|
34
|
+
uuid: this.cid,
|
|
35
|
+
status: 'on',
|
|
36
|
+
colorTemp: colorTemp.toString()
|
|
37
|
+
};
|
|
38
|
+
const [response] = await helpers_1.Helpers.callApi('/SmartBulb/v1/device/updateColorTemperature', 'put', body, helpers_1.Helpers.reqHeaders(this.manager));
|
|
39
|
+
if (response?.code === 0) {
|
|
40
|
+
this.colorTemp = colorTemp;
|
|
41
|
+
return true;
|
|
42
|
+
}
|
|
43
|
+
return false;
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
exports.VeSyncBulbESL100CW = VeSyncBulbESL100CW;
|
|
47
|
+
/**
|
|
48
|
+
* XYD0001 Bulb Implementation
|
|
49
|
+
*/
|
|
50
|
+
class VeSyncBulbXYD0001 extends vesyncBulb_1.VeSyncBulb {
|
|
51
|
+
constructor(details, manager) {
|
|
52
|
+
super(details, manager);
|
|
53
|
+
}
|
|
54
|
+
async setColorTemp(colorTemp) {
|
|
55
|
+
if (!this.features.includes('color_temp')) {
|
|
56
|
+
return false;
|
|
57
|
+
}
|
|
58
|
+
const body = {
|
|
59
|
+
...helpers_1.Helpers.reqBody(this.manager, 'devicestatus'),
|
|
60
|
+
uuid: this.cid,
|
|
61
|
+
status: 'on',
|
|
62
|
+
colorTemp: colorTemp.toString()
|
|
63
|
+
};
|
|
64
|
+
const [response] = await helpers_1.Helpers.callApi('/SmartBulb/v1/device/updateColorTemperature', 'put', body, helpers_1.Helpers.reqHeaders(this.manager));
|
|
65
|
+
if (response?.code === 0) {
|
|
66
|
+
this.colorTemp = colorTemp;
|
|
67
|
+
return true;
|
|
68
|
+
}
|
|
69
|
+
return false;
|
|
70
|
+
}
|
|
71
|
+
async setHsv(hue, saturation, value) {
|
|
72
|
+
if (!this.features.includes('rgb_shift')) {
|
|
73
|
+
return false;
|
|
74
|
+
}
|
|
75
|
+
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()
|
|
83
|
+
};
|
|
84
|
+
const [response] = await helpers_1.Helpers.callApi('/SmartBulb/v1/device/updateColor', 'put', body, helpers_1.Helpers.reqHeaders(this.manager));
|
|
85
|
+
if (response?.code === 0) {
|
|
86
|
+
this.colorHue = hue;
|
|
87
|
+
this.colorSaturation = saturation;
|
|
88
|
+
this.colorValue = value;
|
|
89
|
+
return true;
|
|
90
|
+
}
|
|
91
|
+
return false;
|
|
92
|
+
}
|
|
93
|
+
async enableWhiteMode() {
|
|
94
|
+
const body = {
|
|
95
|
+
...helpers_1.Helpers.reqBody(this.manager, 'devicestatus'),
|
|
96
|
+
uuid: this.cid,
|
|
97
|
+
status: 'on',
|
|
98
|
+
colorMode: 'white'
|
|
99
|
+
};
|
|
100
|
+
const [response] = await helpers_1.Helpers.callApi('/SmartBulb/v1/device/updateColorMode', 'put', body, helpers_1.Helpers.reqHeaders(this.manager));
|
|
101
|
+
if (response?.code === 0) {
|
|
102
|
+
this.colorMode = 'white';
|
|
103
|
+
return true;
|
|
104
|
+
}
|
|
105
|
+
return false;
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
exports.VeSyncBulbXYD0001 = VeSyncBulbXYD0001;
|
|
109
|
+
/**
|
|
110
|
+
* ESL100MC Bulb Implementation
|
|
111
|
+
*/
|
|
112
|
+
class VeSyncBulbESL100MC extends vesyncBulb_1.VeSyncBulb {
|
|
113
|
+
constructor(details, manager) {
|
|
114
|
+
super(details, manager);
|
|
115
|
+
}
|
|
116
|
+
async setColorTemp(colorTemp) {
|
|
117
|
+
return false;
|
|
118
|
+
}
|
|
119
|
+
async setRgb(red, green, blue) {
|
|
120
|
+
if (!this.features.includes('rgb_shift')) {
|
|
121
|
+
return false;
|
|
122
|
+
}
|
|
123
|
+
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()
|
|
131
|
+
};
|
|
132
|
+
const [response] = await helpers_1.Helpers.callApi('/SmartBulb/v1/device/updateColor', 'put', body, helpers_1.Helpers.reqHeaders(this.manager));
|
|
133
|
+
if (response?.code === 0) {
|
|
134
|
+
this.rgbValues = { red, green, blue };
|
|
135
|
+
return true;
|
|
136
|
+
}
|
|
137
|
+
return false;
|
|
138
|
+
}
|
|
139
|
+
async enableWhiteMode() {
|
|
140
|
+
const body = {
|
|
141
|
+
...helpers_1.Helpers.reqBody(this.manager, 'devicestatus'),
|
|
142
|
+
uuid: this.cid,
|
|
143
|
+
status: 'on',
|
|
144
|
+
colorMode: 'white'
|
|
145
|
+
};
|
|
146
|
+
const [response] = await helpers_1.Helpers.callApi('/SmartBulb/v1/device/updateColorMode', 'put', body, helpers_1.Helpers.reqHeaders(this.manager));
|
|
147
|
+
if (response?.code === 0) {
|
|
148
|
+
this.colorMode = 'white';
|
|
149
|
+
return true;
|
|
150
|
+
}
|
|
151
|
+
return false;
|
|
152
|
+
}
|
|
153
|
+
}
|
|
154
|
+
exports.VeSyncBulbESL100MC = VeSyncBulbESL100MC;
|
|
155
|
+
// Export the bulb modules dictionary
|
|
156
|
+
exports.bulbModules = {
|
|
157
|
+
'ESL100': VeSyncBulbESL100,
|
|
158
|
+
'ESL100CW': VeSyncBulbESL100CW,
|
|
159
|
+
'XYD0001': VeSyncBulbXYD0001,
|
|
160
|
+
'ESL100MC': VeSyncBulbESL100MC
|
|
161
|
+
};
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* VeSync Fan Classes
|
|
3
|
+
*/
|
|
4
|
+
import { VeSyncBaseDevice } from './vesyncBaseDevice';
|
|
5
|
+
import { VeSync } from './vesync';
|
|
6
|
+
interface FanConfig {
|
|
7
|
+
[key: string]: {
|
|
8
|
+
module: 'VeSyncAirBypass' | 'VeSyncHumidifier' | 'VeSyncWarmHumidifier';
|
|
9
|
+
features: string[];
|
|
10
|
+
};
|
|
11
|
+
}
|
|
12
|
+
export declare const fanConfig: FanConfig;
|
|
13
|
+
/**
|
|
14
|
+
* Base class for VeSync Fans
|
|
15
|
+
*/
|
|
16
|
+
export declare abstract class VeSyncFan extends VeSyncBaseDevice {
|
|
17
|
+
protected details: Record<string, any>;
|
|
18
|
+
protected mode_dict: Record<string, any>;
|
|
19
|
+
protected speed_dict: Record<string, any>;
|
|
20
|
+
protected features: string[];
|
|
21
|
+
constructor(details: Record<string, any>, manager: VeSync);
|
|
22
|
+
/**
|
|
23
|
+
* Check if feature is supported
|
|
24
|
+
*/
|
|
25
|
+
hasFeature(feature: string): boolean;
|
|
26
|
+
/**
|
|
27
|
+
* Get current mode
|
|
28
|
+
*/
|
|
29
|
+
get mode(): string;
|
|
30
|
+
/**
|
|
31
|
+
* Get current speed
|
|
32
|
+
*/
|
|
33
|
+
get speed(): number;
|
|
34
|
+
/**
|
|
35
|
+
* Get filter life percentage
|
|
36
|
+
*/
|
|
37
|
+
get filterLife(): number;
|
|
38
|
+
/**
|
|
39
|
+
* Get screen status
|
|
40
|
+
*/
|
|
41
|
+
get screenStatus(): string;
|
|
42
|
+
/**
|
|
43
|
+
* Get child lock status
|
|
44
|
+
*/
|
|
45
|
+
get childLock(): string;
|
|
46
|
+
/**
|
|
47
|
+
* Get air quality (if supported)
|
|
48
|
+
*/
|
|
49
|
+
get airQuality(): string;
|
|
50
|
+
/**
|
|
51
|
+
* Get humidity level (if supported)
|
|
52
|
+
*/
|
|
53
|
+
get humidity(): number;
|
|
54
|
+
/**
|
|
55
|
+
* Get mist level (if supported)
|
|
56
|
+
*/
|
|
57
|
+
get mistLevel(): number;
|
|
58
|
+
/**
|
|
59
|
+
* Get warm level (if supported)
|
|
60
|
+
*/
|
|
61
|
+
get warmLevel(): number;
|
|
62
|
+
/**
|
|
63
|
+
* Get timer status
|
|
64
|
+
*/
|
|
65
|
+
get timer(): number;
|
|
66
|
+
/**
|
|
67
|
+
* Return formatted device info to stdout
|
|
68
|
+
*/
|
|
69
|
+
display(): void;
|
|
70
|
+
/**
|
|
71
|
+
* Return JSON details for fan
|
|
72
|
+
*/
|
|
73
|
+
displayJSON(): string;
|
|
74
|
+
abstract getDetails(): Promise<void>;
|
|
75
|
+
abstract turnOn(): Promise<boolean>;
|
|
76
|
+
abstract turnOff(): Promise<boolean>;
|
|
77
|
+
abstract changeFanSpeed(speed: number): Promise<boolean>;
|
|
78
|
+
abstract setMode(mode: string): Promise<boolean>;
|
|
79
|
+
}
|
|
80
|
+
export {};
|