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
|
@@ -1,68 +1,43 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Base class for
|
|
2
|
+
* Base class for VeSync devices
|
|
3
3
|
*/
|
|
4
4
|
import { VeSync } from './vesync';
|
|
5
|
-
export
|
|
6
|
-
deviceName: string;
|
|
7
|
-
deviceImg?: string;
|
|
8
|
-
cid: string;
|
|
9
|
-
connectionStatus: string;
|
|
10
|
-
connectionType?: string;
|
|
11
|
-
deviceType: string;
|
|
12
|
-
type?: string;
|
|
13
|
-
uuid?: string;
|
|
14
|
-
configModule: string;
|
|
15
|
-
macID?: string;
|
|
16
|
-
mode?: string;
|
|
17
|
-
speed?: number | string;
|
|
18
|
-
extension?: any;
|
|
19
|
-
currentFirmVersion?: string;
|
|
20
|
-
deviceRegion?: string;
|
|
21
|
-
deviceStatus?: string;
|
|
22
|
-
subDeviceNo?: number;
|
|
23
|
-
}
|
|
24
|
-
export declare class VeSyncBaseDevice {
|
|
5
|
+
export declare abstract class VeSyncBaseDevice {
|
|
25
6
|
protected manager: VeSync;
|
|
26
|
-
|
|
27
|
-
deviceImage: string | null;
|
|
7
|
+
protected config: Record<string, any>;
|
|
28
8
|
cid: string;
|
|
29
|
-
|
|
30
|
-
|
|
9
|
+
deviceName: string;
|
|
10
|
+
deviceStatus: string;
|
|
31
11
|
deviceType: string;
|
|
32
|
-
|
|
33
|
-
uuid: string
|
|
12
|
+
deviceRegion: string;
|
|
13
|
+
uuid: string;
|
|
34
14
|
configModule: string;
|
|
35
|
-
macId: string
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
config: {
|
|
44
|
-
[key: string]: any;
|
|
45
|
-
};
|
|
46
|
-
deviceStatus: string | null;
|
|
47
|
-
constructor(details: DeviceDetails, manager: VeSync);
|
|
15
|
+
macId: string;
|
|
16
|
+
deviceCategory: string;
|
|
17
|
+
connectionStatus: string;
|
|
18
|
+
constructor(details: Record<string, any>, manager: VeSync);
|
|
19
|
+
/**
|
|
20
|
+
* Return formatted device info to stdout
|
|
21
|
+
*/
|
|
22
|
+
display(): void;
|
|
48
23
|
/**
|
|
49
|
-
* Return
|
|
24
|
+
* Return JSON details for device
|
|
50
25
|
*/
|
|
51
|
-
|
|
26
|
+
displayJSON(): string;
|
|
52
27
|
/**
|
|
53
|
-
*
|
|
28
|
+
* Check API response for errors
|
|
54
29
|
*/
|
|
55
|
-
|
|
30
|
+
protected checkResponse(response: [any, number], method: string): boolean;
|
|
56
31
|
/**
|
|
57
|
-
*
|
|
32
|
+
* Log error with context
|
|
58
33
|
*/
|
|
59
|
-
|
|
34
|
+
protected logError(method: string, error: any): void;
|
|
60
35
|
/**
|
|
61
|
-
*
|
|
36
|
+
* Get device details
|
|
62
37
|
*/
|
|
63
|
-
|
|
38
|
+
abstract getDetails(): Promise<void>;
|
|
64
39
|
/**
|
|
65
|
-
*
|
|
40
|
+
* Update device details
|
|
66
41
|
*/
|
|
67
|
-
|
|
42
|
+
update(): Promise<void>;
|
|
68
43
|
}
|
|
@@ -1,116 +1,88 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Base class for VeSync devices
|
|
4
|
+
*/
|
|
2
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
6
|
exports.VeSyncBaseDevice = void 0;
|
|
4
|
-
const helpers_1 = require("./helpers");
|
|
5
7
|
class VeSyncBaseDevice {
|
|
6
8
|
constructor(details, manager) {
|
|
9
|
+
this.config = {};
|
|
7
10
|
this.manager = manager;
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
this.macId = details.macID || null;
|
|
19
|
-
this.mode = details.mode || null;
|
|
20
|
-
this.speed = typeof details.speed === 'string' && details.speed !== ''
|
|
21
|
-
? parseInt(details.speed)
|
|
22
|
-
: (typeof details.speed === 'number' ? details.speed : null);
|
|
23
|
-
this.extension = details.extension;
|
|
24
|
-
this.currentFirmVersion = details.currentFirmVersion || null;
|
|
25
|
-
this.deviceRegion = details.deviceRegion || null;
|
|
26
|
-
this.pid = null;
|
|
27
|
-
this.subDeviceNo = details.subDeviceNo || 0;
|
|
28
|
-
this.config = {};
|
|
29
|
-
if (typeof details.extension === 'object' && details.extension !== null) {
|
|
30
|
-
const ext = details.extension;
|
|
31
|
-
this.speed = ext.fanSpeedLevel;
|
|
32
|
-
this.mode = ext.mode;
|
|
33
|
-
}
|
|
34
|
-
if (this.connectionStatus !== 'online') {
|
|
35
|
-
this.deviceStatus = 'off';
|
|
36
|
-
}
|
|
37
|
-
else {
|
|
38
|
-
this.deviceStatus = details.deviceStatus || null;
|
|
39
|
-
}
|
|
40
|
-
}
|
|
41
|
-
else {
|
|
42
|
-
throw new Error(`No cid found for ${this.constructor.name}`);
|
|
43
|
-
}
|
|
11
|
+
this.cid = details.cid || '';
|
|
12
|
+
this.deviceName = details.deviceName || '';
|
|
13
|
+
this.deviceStatus = details.deviceStatus || 'off';
|
|
14
|
+
this.deviceType = details.deviceType || '';
|
|
15
|
+
this.deviceRegion = details.deviceRegion || '';
|
|
16
|
+
this.uuid = details.uuid || '';
|
|
17
|
+
this.configModule = details.configModule || '';
|
|
18
|
+
this.macId = details.macId || '';
|
|
19
|
+
this.deviceCategory = details.deviceCategory || '';
|
|
20
|
+
this.connectionStatus = details.connectionStatus || 'offline';
|
|
44
21
|
}
|
|
45
22
|
/**
|
|
46
|
-
* Return
|
|
23
|
+
* Return formatted device info to stdout
|
|
47
24
|
*/
|
|
48
|
-
|
|
49
|
-
|
|
25
|
+
display() {
|
|
26
|
+
console.log(`Device Name: ${this.deviceName}`);
|
|
27
|
+
console.log(`Status: ${this.deviceStatus}`);
|
|
28
|
+
console.log(`Device Type: ${this.deviceType}`);
|
|
29
|
+
console.log(`Connection: ${this.connectionStatus}`);
|
|
30
|
+
console.log(`Version: ${this.config.current_firmware_version || 'Unknown'}`);
|
|
50
31
|
}
|
|
51
32
|
/**
|
|
52
|
-
* Return
|
|
33
|
+
* Return JSON details for device
|
|
53
34
|
*/
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
35
|
+
displayJSON() {
|
|
36
|
+
return JSON.stringify({
|
|
37
|
+
'Device Name': this.deviceName,
|
|
38
|
+
'Status': this.deviceStatus,
|
|
39
|
+
'Device Type': this.deviceType,
|
|
40
|
+
'Connection': this.connectionStatus,
|
|
41
|
+
'Version': this.config.current_firmware_version || 'Unknown'
|
|
42
|
+
}, null, 4);
|
|
62
43
|
}
|
|
63
44
|
/**
|
|
64
|
-
*
|
|
45
|
+
* Check API response for errors
|
|
65
46
|
*/
|
|
66
|
-
|
|
67
|
-
const
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
if (typeof response !== 'object' ||
|
|
73
|
-
response.code !== 0 ||
|
|
74
|
-
!response.result) {
|
|
75
|
-
console.error(`Error getting config info for ${this.deviceName}`);
|
|
76
|
-
return;
|
|
47
|
+
checkResponse(response, method) {
|
|
48
|
+
const [data, status] = response;
|
|
49
|
+
// Check HTTP status
|
|
50
|
+
if (status !== 200) {
|
|
51
|
+
this.logError(method, `Invalid HTTP status: ${status}`);
|
|
52
|
+
return false;
|
|
77
53
|
}
|
|
78
|
-
|
|
54
|
+
// Check API response
|
|
55
|
+
if (!data) {
|
|
56
|
+
this.logError(method, 'No response data');
|
|
57
|
+
return false;
|
|
58
|
+
}
|
|
59
|
+
// Check error code - code 0 indicates success
|
|
60
|
+
if (data.code === 0) {
|
|
61
|
+
return true;
|
|
62
|
+
}
|
|
63
|
+
const msg = data.msg || 'Unknown error';
|
|
64
|
+
this.logError(method, `Error code ${data.code}: ${msg}`);
|
|
65
|
+
return false;
|
|
79
66
|
}
|
|
80
67
|
/**
|
|
81
|
-
*
|
|
68
|
+
* Log error with context
|
|
82
69
|
*/
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
];
|
|
93
|
-
if (this.uuid) {
|
|
94
|
-
disp.push(['UUID:', this.uuid]);
|
|
95
|
-
}
|
|
96
|
-
for (const line of disp) {
|
|
97
|
-
console.log(`${line[0].padEnd(30, '.')} ${line[1]}`);
|
|
70
|
+
logError(method, error) {
|
|
71
|
+
var _a;
|
|
72
|
+
const errorMsg = (error === null || error === void 0 ? void 0 : error.message) || error;
|
|
73
|
+
console.error(`[${this.deviceName}] ${method}: ${errorMsg}`);
|
|
74
|
+
// Log additional error details if available
|
|
75
|
+
if ((_a = error === null || error === void 0 ? void 0 : error.response) === null || _a === void 0 ? void 0 : _a.data) {
|
|
76
|
+
const responseData = error.response.data;
|
|
77
|
+
const msg = responseData.msg || responseData.message || JSON.stringify(responseData);
|
|
78
|
+
console.error(`Response: ${msg}`);
|
|
98
79
|
}
|
|
99
80
|
}
|
|
100
81
|
/**
|
|
101
|
-
*
|
|
82
|
+
* Update device details
|
|
102
83
|
*/
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
'Device Name': this.deviceName,
|
|
106
|
-
'Model': this.deviceType,
|
|
107
|
-
'Subdevice No': this.subDeviceNo.toString(),
|
|
108
|
-
'Status': this.deviceStatus,
|
|
109
|
-
'Online': this.connectionStatus,
|
|
110
|
-
'Type': this.type,
|
|
111
|
-
'CID': this.cid,
|
|
112
|
-
}, null, 4);
|
|
84
|
+
async update() {
|
|
85
|
+
await this.getDetails();
|
|
113
86
|
}
|
|
114
87
|
}
|
|
115
88
|
exports.VeSyncBaseDevice = VeSyncBaseDevice;
|
|
116
|
-
//# sourceMappingURL=vesyncBaseDevice.js.map
|
package/dist/lib/vesyncBulb.d.ts
CHANGED
|
@@ -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
|
+
}
|
package/dist/lib/vesyncBulb.js
CHANGED
|
@@ -1,2 +1,199 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
|
|
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
|
+
var _a;
|
|
34
|
+
super(details, manager);
|
|
35
|
+
this.brightness = 0;
|
|
36
|
+
this.colorTemp = 0;
|
|
37
|
+
this.colorValue = 0;
|
|
38
|
+
this.colorHue = 0;
|
|
39
|
+
this.colorSaturation = 0;
|
|
40
|
+
this.colorMode = '';
|
|
41
|
+
this.features = ((_a = featureDict[this.deviceType]) === null || _a === void 0 ? void 0 : _a.features) || [];
|
|
42
|
+
this.rgbValues = {
|
|
43
|
+
red: 0,
|
|
44
|
+
green: 0,
|
|
45
|
+
blue: 0
|
|
46
|
+
};
|
|
47
|
+
}
|
|
48
|
+
/**
|
|
49
|
+
* Get bulb details
|
|
50
|
+
*/
|
|
51
|
+
async getDetails() {
|
|
52
|
+
const body = {
|
|
53
|
+
...helpers_1.Helpers.reqBody(this.manager, 'devicedetail'),
|
|
54
|
+
uuid: this.cid,
|
|
55
|
+
method: 'devicedetail'
|
|
56
|
+
};
|
|
57
|
+
const [response] = await helpers_1.Helpers.callApi('/SmartBulb/v1/device/devicedetail', 'post', body, helpers_1.Helpers.reqHeaders(this.manager));
|
|
58
|
+
if ((response === null || response === void 0 ? void 0 : response.code) === 0 && (response === null || response === void 0 ? void 0 : response.result)) {
|
|
59
|
+
this.deviceStatus = response.result.deviceStatus || this.deviceStatus;
|
|
60
|
+
this.brightness = response.result.brightness || this.brightness;
|
|
61
|
+
if (this.features.includes('color_temp')) {
|
|
62
|
+
this.colorTemp = response.result.colorTemp || this.colorTemp;
|
|
63
|
+
}
|
|
64
|
+
if (this.features.includes('rgb_shift')) {
|
|
65
|
+
if (featureDict[this.deviceType].colorModel === 'rgb') {
|
|
66
|
+
this.rgbValues = {
|
|
67
|
+
red: response.result.red || this.rgbValues.red,
|
|
68
|
+
green: response.result.green || this.rgbValues.green,
|
|
69
|
+
blue: response.result.blue || this.rgbValues.blue
|
|
70
|
+
};
|
|
71
|
+
}
|
|
72
|
+
else {
|
|
73
|
+
this.colorHue = response.result.hue || this.colorHue;
|
|
74
|
+
this.colorSaturation = response.result.saturation || this.colorSaturation;
|
|
75
|
+
this.colorValue = response.result.value || this.colorValue;
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
/**
|
|
81
|
+
* Update bulb status
|
|
82
|
+
*/
|
|
83
|
+
async update() {
|
|
84
|
+
await this.getDetails();
|
|
85
|
+
}
|
|
86
|
+
/**
|
|
87
|
+
* Turn bulb on
|
|
88
|
+
*/
|
|
89
|
+
async turnOn() {
|
|
90
|
+
const body = {
|
|
91
|
+
...helpers_1.Helpers.reqBody(this.manager, 'devicestatus'),
|
|
92
|
+
uuid: this.cid,
|
|
93
|
+
status: 'on'
|
|
94
|
+
};
|
|
95
|
+
const [response] = await helpers_1.Helpers.callApi('/SmartBulb/v1/device/devicestatus', 'put', body, helpers_1.Helpers.reqHeaders(this.manager));
|
|
96
|
+
if ((response === null || response === void 0 ? void 0 : response.code) === 0) {
|
|
97
|
+
this.deviceStatus = 'on';
|
|
98
|
+
return true;
|
|
99
|
+
}
|
|
100
|
+
return false;
|
|
101
|
+
}
|
|
102
|
+
/**
|
|
103
|
+
* Turn bulb off
|
|
104
|
+
*/
|
|
105
|
+
async turnOff() {
|
|
106
|
+
const body = {
|
|
107
|
+
...helpers_1.Helpers.reqBody(this.manager, 'devicestatus'),
|
|
108
|
+
uuid: this.cid,
|
|
109
|
+
status: 'off'
|
|
110
|
+
};
|
|
111
|
+
const [response] = await helpers_1.Helpers.callApi('/SmartBulb/v1/device/devicestatus', 'put', body, helpers_1.Helpers.reqHeaders(this.manager));
|
|
112
|
+
if ((response === null || response === void 0 ? void 0 : response.code) === 0) {
|
|
113
|
+
this.deviceStatus = 'off';
|
|
114
|
+
return true;
|
|
115
|
+
}
|
|
116
|
+
return false;
|
|
117
|
+
}
|
|
118
|
+
/**
|
|
119
|
+
* Set bulb brightness
|
|
120
|
+
*/
|
|
121
|
+
async setBrightness(brightness) {
|
|
122
|
+
if (!this.features.includes('dimmable')) {
|
|
123
|
+
return false;
|
|
124
|
+
}
|
|
125
|
+
const body = {
|
|
126
|
+
...helpers_1.Helpers.reqBody(this.manager, 'devicestatus'),
|
|
127
|
+
uuid: this.cid,
|
|
128
|
+
status: 'on',
|
|
129
|
+
brightNess: brightness.toString()
|
|
130
|
+
};
|
|
131
|
+
const [response] = await helpers_1.Helpers.callApi('/SmartBulb/v1/device/updateBrightness', 'put', body, helpers_1.Helpers.reqHeaders(this.manager));
|
|
132
|
+
if ((response === null || response === void 0 ? void 0 : response.code) === 0) {
|
|
133
|
+
this.brightness = brightness;
|
|
134
|
+
return true;
|
|
135
|
+
}
|
|
136
|
+
return false;
|
|
137
|
+
}
|
|
138
|
+
/**
|
|
139
|
+
* Get bulb brightness
|
|
140
|
+
*/
|
|
141
|
+
getBrightness() {
|
|
142
|
+
return this.brightness;
|
|
143
|
+
}
|
|
144
|
+
/**
|
|
145
|
+
* Get color temperature in Kelvin
|
|
146
|
+
*/
|
|
147
|
+
getColorTempKelvin() {
|
|
148
|
+
if (!this.features.includes('color_temp')) {
|
|
149
|
+
return 0;
|
|
150
|
+
}
|
|
151
|
+
return ((6500 - 2700) * this.colorTemp / 100) + 2700;
|
|
152
|
+
}
|
|
153
|
+
/**
|
|
154
|
+
* Get color temperature in percent
|
|
155
|
+
*/
|
|
156
|
+
getColorTempPercent() {
|
|
157
|
+
if (!this.features.includes('color_temp')) {
|
|
158
|
+
return 0;
|
|
159
|
+
}
|
|
160
|
+
return this.colorTemp;
|
|
161
|
+
}
|
|
162
|
+
/**
|
|
163
|
+
* Get color hue
|
|
164
|
+
*/
|
|
165
|
+
getColorHue() {
|
|
166
|
+
if (!this.features.includes('rgb_shift')) {
|
|
167
|
+
return 0;
|
|
168
|
+
}
|
|
169
|
+
return this.colorHue;
|
|
170
|
+
}
|
|
171
|
+
/**
|
|
172
|
+
* Get color saturation
|
|
173
|
+
*/
|
|
174
|
+
getColorSaturation() {
|
|
175
|
+
if (!this.features.includes('rgb_shift')) {
|
|
176
|
+
return 0;
|
|
177
|
+
}
|
|
178
|
+
return this.colorSaturation;
|
|
179
|
+
}
|
|
180
|
+
/**
|
|
181
|
+
* Get color value
|
|
182
|
+
*/
|
|
183
|
+
getColorValue() {
|
|
184
|
+
if (!this.features.includes('rgb_shift')) {
|
|
185
|
+
return 0;
|
|
186
|
+
}
|
|
187
|
+
return this.colorValue;
|
|
188
|
+
}
|
|
189
|
+
/**
|
|
190
|
+
* Get RGB values
|
|
191
|
+
*/
|
|
192
|
+
getRGBValues() {
|
|
193
|
+
if (!this.features.includes('rgb_shift') || featureDict[this.deviceType].colorModel !== 'rgb') {
|
|
194
|
+
return { red: 0, green: 0, blue: 0 };
|
|
195
|
+
}
|
|
196
|
+
return this.rgbValues;
|
|
197
|
+
}
|
|
198
|
+
}
|
|
199
|
+
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>;
|