tsvesync 1.0.13 → 1.0.15

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.
Files changed (41) hide show
  1. package/dist/lib/vesyncOutlet.js +21 -2
  2. package/package.json +1 -1
  3. package/src/lib/vesyncOutlet.ts +21 -3
  4. package/dist/lib/helpers.js.map +0 -1
  5. package/dist/lib/vesync.js.map +0 -1
  6. package/dist/lib/vesyncBaseDevice.js.map +0 -1
  7. package/dist/lib/vesyncBulb.js.map +0 -1
  8. package/dist/lib/vesyncFan.js.map +0 -1
  9. package/dist/lib/vesyncKitchen.d.ts +0 -0
  10. package/dist/lib/vesyncKitchen.js +0 -2
  11. package/dist/lib/vesyncKitchen.js.map +0 -1
  12. package/dist/lib/vesyncOutlet.js.map +0 -1
  13. package/dist/lib/vesyncSwitch.js.map +0 -1
  14. package/dist/src/lib/helpers.d.ts +0 -88
  15. package/dist/src/lib/helpers.js +0 -244
  16. package/dist/src/lib/vesync.d.ts +0 -89
  17. package/dist/src/lib/vesync.js +0 -430
  18. package/dist/src/lib/vesyncBaseDevice.d.ts +0 -43
  19. package/dist/src/lib/vesyncBaseDevice.js +0 -87
  20. package/dist/src/lib/vesyncBulb.d.ts +0 -79
  21. package/dist/src/lib/vesyncBulb.js +0 -198
  22. package/dist/src/lib/vesyncBulbImpl.d.ts +0 -38
  23. package/dist/src/lib/vesyncBulbImpl.js +0 -161
  24. package/dist/src/lib/vesyncFan.d.ts +0 -80
  25. package/dist/src/lib/vesyncFan.js +0 -406
  26. package/dist/src/lib/vesyncFanImpl.d.ts +0 -137
  27. package/dist/src/lib/vesyncFanImpl.js +0 -643
  28. package/dist/src/lib/vesyncOutlet.d.ts +0 -53
  29. package/dist/src/lib/vesyncOutlet.js +0 -98
  30. package/dist/src/lib/vesyncOutletImpl.d.ts +0 -70
  31. package/dist/src/lib/vesyncOutletImpl.js +0 -206
  32. package/dist/src/lib/vesyncSwitch.d.ts +0 -169
  33. package/dist/src/lib/vesyncSwitch.js +0 -414
  34. package/dist/src/lib/vesyncSwitchImpl.d.ts +0 -82
  35. package/dist/src/lib/vesyncSwitchImpl.js +0 -290
  36. package/dist/test/testFeatures.d.ts +0 -4
  37. package/dist/test/testFeatures.js +0 -394
  38. package/dist/test/testService.d.ts +0 -62
  39. package/dist/test/testService.js +0 -540
  40. package/dist/test/testSpecial.d.ts +0 -5
  41. package/dist/test/testSpecial.js +0 -227
@@ -1,198 +0,0 @@
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;
@@ -1,38 +0,0 @@
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>;
@@ -1,161 +0,0 @@
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
- };
@@ -1,80 +0,0 @@
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 {};