tsvesync 1.0.11 → 1.0.12
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/index.d.ts +7 -0
- package/dist/index.js +25 -0
- package/dist/lib/helpers.d.ts +52 -51
- package/dist/lib/helpers.js +134 -112
- package/dist/lib/vesync.d.ts +57 -15
- package/dist/lib/vesync.js +339 -216
- package/dist/lib/vesyncBaseDevice.d.ts +25 -50
- package/dist/lib/vesyncBaseDevice.js +62 -90
- package/dist/lib/vesyncBulb.d.ts +79 -0
- package/dist/lib/vesyncBulb.js +198 -1
- package/dist/lib/vesyncBulbImpl.d.ts +38 -0
- package/dist/lib/vesyncBulbImpl.js +161 -0
- package/dist/lib/vesyncFan.d.ts +55 -67
- package/dist/lib/vesyncFan.js +365 -213
- package/dist/lib/vesyncFanImpl.d.ts +137 -0
- package/dist/lib/vesyncFanImpl.js +644 -0
- package/dist/lib/vesyncOutlet.d.ts +53 -0
- package/dist/lib/vesyncOutlet.js +97 -1
- package/dist/lib/vesyncOutletImpl.d.ts +70 -0
- package/dist/lib/vesyncOutletImpl.js +206 -0
- package/dist/lib/vesyncSwitch.d.ts +169 -0
- package/dist/lib/vesyncSwitch.js +417 -1
- package/dist/lib/vesyncSwitchImpl.d.ts +82 -0
- package/dist/lib/vesyncSwitchImpl.js +290 -0
- package/package.json +1 -1
- package/src/index.ts +14 -0
|
@@ -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 === null || response === void 0 ? void 0 : 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 === null || response === void 0 ? void 0 : 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 === null || response === void 0 ? void 0 : 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 === null || response === void 0 ? void 0 : 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 === null || response === void 0 ? void 0 : 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 === null || response === void 0 ? void 0 : 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
|
+
};
|
package/dist/lib/vesyncFan.d.ts
CHANGED
|
@@ -1,92 +1,80 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* VeSync
|
|
2
|
+
* VeSync Fan Classes
|
|
3
3
|
*/
|
|
4
4
|
import { VeSyncBaseDevice } from './vesyncBaseDevice';
|
|
5
|
-
import {
|
|
6
|
-
interface
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
mist_levels: number[];
|
|
12
|
-
warm_mist_levels?: number[];
|
|
5
|
+
import { VeSync } from './vesync';
|
|
6
|
+
interface FanConfig {
|
|
7
|
+
[key: string]: {
|
|
8
|
+
module: 'VeSyncAirBypass' | 'VeSyncHumidifier' | 'VeSyncWarmHumidifier';
|
|
9
|
+
features: string[];
|
|
10
|
+
};
|
|
13
11
|
}
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
export declare function modelDict(): {
|
|
29
|
-
[key: string]: string;
|
|
30
|
-
};
|
|
31
|
-
export declare function modelFeatures(devType: string): AirFeatures | HumidFeatures;
|
|
32
|
-
export declare const fanClasses: Set<string>;
|
|
33
|
-
export declare const fanModules: {
|
|
34
|
-
[key: string]: string;
|
|
35
|
-
};
|
|
36
|
-
interface AirDetails {
|
|
37
|
-
filter_life: number;
|
|
38
|
-
mode: string;
|
|
39
|
-
level: number;
|
|
40
|
-
display: boolean;
|
|
41
|
-
child_lock: boolean;
|
|
42
|
-
night_light: string;
|
|
43
|
-
air_quality?: number;
|
|
44
|
-
air_quality_value?: number;
|
|
45
|
-
display_forever?: boolean;
|
|
46
|
-
}
|
|
47
|
-
export declare class VeSyncAirBypass extends VeSyncBaseDevice {
|
|
48
|
-
private _configDict;
|
|
49
|
-
private _features;
|
|
50
|
-
details: AirDetails;
|
|
51
|
-
timer: Timer | null;
|
|
52
|
-
enabled: boolean;
|
|
53
|
-
constructor(details: any, manager: any);
|
|
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;
|
|
54
26
|
/**
|
|
55
|
-
* Get
|
|
27
|
+
* Get current mode
|
|
56
28
|
*/
|
|
57
|
-
|
|
29
|
+
get mode(): string;
|
|
58
30
|
/**
|
|
59
|
-
*
|
|
31
|
+
* Get current speed
|
|
60
32
|
*/
|
|
61
|
-
|
|
33
|
+
get speed(): number;
|
|
62
34
|
/**
|
|
63
|
-
*
|
|
35
|
+
* Get filter life percentage
|
|
64
36
|
*/
|
|
65
|
-
|
|
66
|
-
turnOff(): Promise<boolean>;
|
|
37
|
+
get filterLife(): number;
|
|
67
38
|
/**
|
|
68
|
-
*
|
|
39
|
+
* Get screen status
|
|
69
40
|
*/
|
|
70
|
-
|
|
41
|
+
get screenStatus(): string;
|
|
71
42
|
/**
|
|
72
|
-
*
|
|
43
|
+
* Get child lock status
|
|
73
44
|
*/
|
|
74
|
-
|
|
45
|
+
get childLock(): string;
|
|
75
46
|
/**
|
|
76
|
-
*
|
|
47
|
+
* Get air quality (if supported)
|
|
77
48
|
*/
|
|
78
|
-
|
|
49
|
+
get airQuality(): string;
|
|
79
50
|
/**
|
|
80
|
-
*
|
|
51
|
+
* Get humidity level (if supported)
|
|
81
52
|
*/
|
|
82
|
-
|
|
53
|
+
get humidity(): number;
|
|
83
54
|
/**
|
|
84
|
-
*
|
|
55
|
+
* Get mist level (if supported)
|
|
85
56
|
*/
|
|
86
|
-
|
|
57
|
+
get mistLevel(): number;
|
|
87
58
|
/**
|
|
88
|
-
*
|
|
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
|
|
89
68
|
*/
|
|
90
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>;
|
|
91
79
|
}
|
|
92
80
|
export {};
|