tsvesync 1.0.13 → 1.0.14

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 (39) hide show
  1. package/package.json +1 -1
  2. package/dist/lib/helpers.js.map +0 -1
  3. package/dist/lib/vesync.js.map +0 -1
  4. package/dist/lib/vesyncBaseDevice.js.map +0 -1
  5. package/dist/lib/vesyncBulb.js.map +0 -1
  6. package/dist/lib/vesyncFan.js.map +0 -1
  7. package/dist/lib/vesyncKitchen.d.ts +0 -0
  8. package/dist/lib/vesyncKitchen.js +0 -2
  9. package/dist/lib/vesyncKitchen.js.map +0 -1
  10. package/dist/lib/vesyncOutlet.js.map +0 -1
  11. package/dist/lib/vesyncSwitch.js.map +0 -1
  12. package/dist/src/lib/helpers.d.ts +0 -88
  13. package/dist/src/lib/helpers.js +0 -244
  14. package/dist/src/lib/vesync.d.ts +0 -89
  15. package/dist/src/lib/vesync.js +0 -430
  16. package/dist/src/lib/vesyncBaseDevice.d.ts +0 -43
  17. package/dist/src/lib/vesyncBaseDevice.js +0 -87
  18. package/dist/src/lib/vesyncBulb.d.ts +0 -79
  19. package/dist/src/lib/vesyncBulb.js +0 -198
  20. package/dist/src/lib/vesyncBulbImpl.d.ts +0 -38
  21. package/dist/src/lib/vesyncBulbImpl.js +0 -161
  22. package/dist/src/lib/vesyncFan.d.ts +0 -80
  23. package/dist/src/lib/vesyncFan.js +0 -406
  24. package/dist/src/lib/vesyncFanImpl.d.ts +0 -137
  25. package/dist/src/lib/vesyncFanImpl.js +0 -643
  26. package/dist/src/lib/vesyncOutlet.d.ts +0 -53
  27. package/dist/src/lib/vesyncOutlet.js +0 -98
  28. package/dist/src/lib/vesyncOutletImpl.d.ts +0 -70
  29. package/dist/src/lib/vesyncOutletImpl.js +0 -206
  30. package/dist/src/lib/vesyncSwitch.d.ts +0 -169
  31. package/dist/src/lib/vesyncSwitch.js +0 -414
  32. package/dist/src/lib/vesyncSwitchImpl.d.ts +0 -82
  33. package/dist/src/lib/vesyncSwitchImpl.js +0 -290
  34. package/dist/test/testFeatures.d.ts +0 -4
  35. package/dist/test/testFeatures.js +0 -394
  36. package/dist/test/testService.d.ts +0 -62
  37. package/dist/test/testService.js +0 -540
  38. package/dist/test/testSpecial.d.ts +0 -5
  39. package/dist/test/testSpecial.js +0 -227
@@ -1,414 +0,0 @@
1
- "use strict";
2
- /**
3
- * VeSync Switch Classes
4
- */
5
- Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.switchModules = exports.VeSyncDimmerSwitch = exports.VeSyncWallSwitch = exports.VeSyncSwitch = exports.switchConfig = void 0;
7
- const vesyncBaseDevice_1 = require("./vesyncBaseDevice");
8
- const helpers_1 = require("./helpers");
9
- // Switch configuration
10
- exports.switchConfig = {
11
- 'ESWL01': {
12
- module: 'VeSyncWallSwitch',
13
- features: []
14
- },
15
- 'ESWD16': {
16
- module: 'VeSyncDimmerSwitch',
17
- features: ['dimmable']
18
- },
19
- 'ESWL03': {
20
- module: 'VeSyncWallSwitch',
21
- features: []
22
- }
23
- };
24
- /**
25
- * Base class for VeSync Switches
26
- */
27
- class VeSyncSwitch extends vesyncBaseDevice_1.VeSyncBaseDevice {
28
- constructor(details, manager) {
29
- super(details, manager);
30
- this.details = {};
31
- this.features = [];
32
- this.details = details;
33
- this.features = exports.switchConfig[this.deviceType]?.features || [];
34
- }
35
- /**
36
- * Get active time of switch
37
- */
38
- get activeTime() {
39
- return this.details.active_time ?? 0;
40
- }
41
- /**
42
- * Return true if switch is dimmable
43
- */
44
- isDimmable() {
45
- return this.features.includes('dimmable');
46
- }
47
- /**
48
- * Return formatted device info to stdout
49
- */
50
- display() {
51
- super.display();
52
- const info = [
53
- ['Active Time:', this.activeTime]
54
- ];
55
- for (const [key, value] of info) {
56
- console.log(`${key.toString().padEnd(30, '.')} ${value}`);
57
- }
58
- }
59
- /**
60
- * Return JSON details for switch
61
- */
62
- displayJSON() {
63
- const baseInfo = JSON.parse(super.displayJSON());
64
- return JSON.stringify({
65
- ...baseInfo,
66
- 'Active Time': this.activeTime
67
- }, null, 4);
68
- }
69
- /**
70
- * Update device details
71
- */
72
- async update() {
73
- await this.getDetails();
74
- }
75
- }
76
- exports.VeSyncSwitch = VeSyncSwitch;
77
- /**
78
- * VeSync Wall Switch
79
- */
80
- class VeSyncWallSwitch extends VeSyncSwitch {
81
- constructor(details, manager) {
82
- super(details, manager);
83
- }
84
- /**
85
- * Get wall switch details
86
- */
87
- async getDetails() {
88
- const body = helpers_1.Helpers.reqBody(this.manager, 'devicedetail');
89
- body.uuid = this.uuid;
90
- const [response] = await helpers_1.Helpers.callApi('/inwallswitch/v1/device/devicedetail', 'post', body, helpers_1.Helpers.reqHeaders(this.manager));
91
- if (response?.code === 0 && response?.result) {
92
- const result = response.result;
93
- this.deviceStatus = result.deviceStatus ?? this.deviceStatus;
94
- this.details.active_time = result.activeTime ?? 0;
95
- this.connectionStatus = result.connectionStatus ?? this.connectionStatus;
96
- }
97
- else {
98
- console.debug(`Error getting ${this.deviceName} details`);
99
- }
100
- }
101
- /**
102
- * Get switch device configuration info
103
- */
104
- async getConfig() {
105
- const body = helpers_1.Helpers.reqBody(this.manager, 'devicedetail');
106
- body.method = 'configurations';
107
- body.uuid = this.uuid;
108
- const [response] = await helpers_1.Helpers.callApi('/inwallswitch/v1/device/configurations', 'post', body, helpers_1.Helpers.reqHeaders(this.manager));
109
- if (response?.code === 0) {
110
- this.config = helpers_1.Helpers.buildConfigDict(response);
111
- }
112
- else {
113
- console.debug(`Unable to get ${this.deviceName} config info`);
114
- }
115
- }
116
- /**
117
- * Turn off wall switch
118
- */
119
- async turnOff() {
120
- const body = helpers_1.Helpers.reqBody(this.manager, 'devicestatus');
121
- body.status = 'off';
122
- body.uuid = this.uuid;
123
- const [response] = await helpers_1.Helpers.callApi('/inwallswitch/v1/device/devicestatus', 'put', body, helpers_1.Helpers.reqHeaders(this.manager));
124
- if (response?.code === 0) {
125
- this.deviceStatus = 'off';
126
- return true;
127
- }
128
- console.debug(`Error turning ${this.deviceName} off`);
129
- return false;
130
- }
131
- /**
132
- * Turn on wall switch
133
- */
134
- async turnOn() {
135
- const body = helpers_1.Helpers.reqBody(this.manager, 'devicestatus');
136
- body.status = 'on';
137
- body.uuid = this.uuid;
138
- const [response] = await helpers_1.Helpers.callApi('/inwallswitch/v1/device/devicestatus', 'put', body, helpers_1.Helpers.reqHeaders(this.manager));
139
- if (response?.code === 0) {
140
- this.deviceStatus = 'on';
141
- return true;
142
- }
143
- console.debug(`Error turning ${this.deviceName} on`);
144
- return false;
145
- }
146
- }
147
- exports.VeSyncWallSwitch = VeSyncWallSwitch;
148
- /**
149
- * VeSync Dimmer Switch
150
- */
151
- class VeSyncDimmerSwitch extends VeSyncSwitch {
152
- constructor(details, manager) {
153
- super(details, manager);
154
- this._brightness = 0;
155
- this._rgbValue = { red: 0, blue: 0, green: 0 };
156
- this._rgbStatus = 'unknown';
157
- this._indicatorLight = 'unknown';
158
- }
159
- /**
160
- * Get dimmer switch details
161
- */
162
- async getDetails() {
163
- const body = helpers_1.Helpers.reqBody(this.manager, 'devicedetail');
164
- body.uuid = this.uuid;
165
- const [response] = await helpers_1.Helpers.callApi('/dimmer/v1/device/devicedetail', 'post', body, helpers_1.Helpers.reqHeaders(this.manager));
166
- if (response?.code === 0 && response?.result) {
167
- const result = response.result;
168
- this.deviceStatus = result.deviceStatus ?? this.deviceStatus;
169
- this.details.active_time = result.activeTime ?? 0;
170
- this.connectionStatus = result.connectionStatus ?? this.connectionStatus;
171
- this._brightness = result.brightness ?? this._brightness;
172
- this._rgbStatus = result.rgbStatus ?? this._rgbStatus;
173
- this._indicatorLight = result.indicatorlightStatus ?? this._indicatorLight;
174
- if (result.rgbValue) {
175
- this._rgbValue = {
176
- red: result.rgbValue.red ?? 0,
177
- green: result.rgbValue.green ?? 0,
178
- blue: result.rgbValue.blue ?? 0
179
- };
180
- }
181
- }
182
- else {
183
- console.debug(`Error getting ${this.deviceName} details`);
184
- }
185
- }
186
- /**
187
- * Get dimmer switch configuration info
188
- */
189
- async getConfig() {
190
- const body = helpers_1.Helpers.reqBody(this.manager, 'devicedetail');
191
- body.method = 'configurations';
192
- body.uuid = this.uuid;
193
- const [response] = await helpers_1.Helpers.callApi('/dimmer/v1/device/configurations', 'post', body, helpers_1.Helpers.reqHeaders(this.manager));
194
- if (response?.code === 0) {
195
- this.config = helpers_1.Helpers.buildConfigDict(response);
196
- }
197
- else {
198
- console.debug(`Unable to get ${this.deviceName} config info`);
199
- }
200
- }
201
- /**
202
- * Turn off dimmer switch
203
- */
204
- async turnOff() {
205
- const body = helpers_1.Helpers.reqBody(this.manager, 'devicestatus');
206
- body.status = 'off';
207
- body.uuid = this.uuid;
208
- const [response] = await helpers_1.Helpers.callApi('/dimmer/v1/device/devicestatus', 'put', body, helpers_1.Helpers.reqHeaders(this.manager));
209
- if (response?.code === 0) {
210
- this.deviceStatus = 'off';
211
- return true;
212
- }
213
- console.debug(`Error turning ${this.deviceName} off`);
214
- return false;
215
- }
216
- /**
217
- * Turn on dimmer switch
218
- */
219
- async turnOn() {
220
- const body = helpers_1.Helpers.reqBody(this.manager, 'devicestatus');
221
- body.status = 'on';
222
- body.uuid = this.uuid;
223
- const [response] = await helpers_1.Helpers.callApi('/dimmer/v1/device/devicestatus', 'put', body, helpers_1.Helpers.reqHeaders(this.manager));
224
- if (response?.code === 0) {
225
- this.deviceStatus = 'on';
226
- return true;
227
- }
228
- console.debug(`Error turning ${this.deviceName} on`);
229
- return false;
230
- }
231
- /**
232
- * Return brightness in percent
233
- */
234
- get brightness() {
235
- return this._brightness;
236
- }
237
- /**
238
- * Return faceplate brightness light status
239
- */
240
- get indicatorLightStatus() {
241
- return this._indicatorLight;
242
- }
243
- /**
244
- * Return RGB faceplate light status
245
- */
246
- get rgbLightStatus() {
247
- return this._rgbStatus;
248
- }
249
- /**
250
- * Return RGB light values
251
- */
252
- get rgbLightValue() {
253
- return this._rgbValue;
254
- }
255
- /**
256
- * Update device details
257
- */
258
- async update() {
259
- await this.getDetails();
260
- }
261
- /**
262
- * Display device info
263
- */
264
- display() {
265
- super.display();
266
- const info = [
267
- ['Brightness:', this.brightness, '%'],
268
- ['RGB Status:', this.rgbLightStatus],
269
- ['RGB Values:', JSON.stringify(this.rgbLightValue)],
270
- ['Indicator Light:', this.indicatorLightStatus]
271
- ];
272
- for (const [key, value, unit = ''] of info) {
273
- console.log(`${key.toString().padEnd(30, '.')} ${value}${unit}`);
274
- }
275
- }
276
- /**
277
- * Return JSON details for dimmer switch
278
- */
279
- displayJSON() {
280
- const baseInfo = JSON.parse(super.displayJSON());
281
- return JSON.stringify({
282
- ...baseInfo,
283
- 'Brightness': this.brightness,
284
- 'RGB Status': this.rgbLightStatus,
285
- 'RGB Values': this.rgbLightValue,
286
- 'Indicator Light': this.indicatorLightStatus
287
- }, null, 4);
288
- }
289
- /**
290
- * Set brightness level
291
- * @param brightness - Brightness level (1-100)
292
- */
293
- async setBrightness(brightness) {
294
- const body = helpers_1.Helpers.reqBody(this.manager, 'devicestatus');
295
- body.uuid = this.uuid;
296
- body.brightness = brightness;
297
- const [response] = await helpers_1.Helpers.callApi('/dimmer/v1/device/updatebrightness', 'put', body, helpers_1.Helpers.reqHeaders(this.manager));
298
- if (response?.code === 0) {
299
- this._brightness = brightness;
300
- return true;
301
- }
302
- console.debug(`Error setting ${this.deviceName} brightness`);
303
- return false;
304
- }
305
- /**
306
- * Toggle indicator light status
307
- * @param status - Light status ('on' or 'off')
308
- */
309
- async indicatorLightToggle(status) {
310
- if (status !== 'on' && status !== 'off') {
311
- console.debug('Invalid status passed to indicator light toggle');
312
- return false;
313
- }
314
- const body = helpers_1.Helpers.reqBody(this.manager, 'devicestatus');
315
- body.uuid = this.uuid;
316
- body.status = status;
317
- const [response] = await helpers_1.Helpers.callApi('/dimmer/v1/device/indicatorlightstatus', 'put', body, helpers_1.Helpers.reqHeaders(this.manager));
318
- if (response?.code === 0) {
319
- this._indicatorLight = status;
320
- return true;
321
- }
322
- console.debug(`Error toggling ${this.deviceName} indicator light`);
323
- return false;
324
- }
325
- /**
326
- * Set RGB color values
327
- * @param red - Red value (0-255)
328
- * @param green - Green value (0-255)
329
- * @param blue - Blue value (0-255)
330
- */
331
- async rgbColorSet(red, green, blue) {
332
- const body = helpers_1.Helpers.reqBody(this.manager, 'devicestatus');
333
- body.uuid = this.uuid;
334
- body.rgbValue = { red, green, blue };
335
- body.status = 'on';
336
- const [response] = await helpers_1.Helpers.callApi('/dimmer/v1/device/devicergbstatus', 'put', body, helpers_1.Helpers.reqHeaders(this.manager));
337
- if (response?.code === 0) {
338
- this._rgbValue = { red, green, blue };
339
- this._rgbStatus = 'on';
340
- return true;
341
- }
342
- console.debug(`Error setting ${this.deviceName} RGB color`);
343
- return false;
344
- }
345
- /**
346
- * Toggle switch status
347
- * @param status - Switch status ('on' or 'off')
348
- */
349
- async switchToggle(status) {
350
- if (status !== 'on' && status !== 'off') {
351
- console.debug('Invalid status passed to switch toggle');
352
- return false;
353
- }
354
- return status === 'on' ? this.turnOn() : this.turnOff();
355
- }
356
- /**
357
- * Set faceplate RGB color status and optionally set RGB values
358
- * @param status - RGB status ('on' or 'off')
359
- * @param red - Optional red value (0-255)
360
- * @param green - Optional green value (0-255)
361
- * @param blue - Optional blue value (0-255)
362
- */
363
- async rgbColorStatus(status, red, green, blue) {
364
- if (status !== 'on' && status !== 'off') {
365
- console.debug('Invalid status passed to RGB color status');
366
- return false;
367
- }
368
- const body = helpers_1.Helpers.reqBody(this.manager, 'devicestatus');
369
- body.uuid = this.uuid;
370
- body.status = status;
371
- if (red !== undefined && green !== undefined && blue !== undefined) {
372
- body.rgbValue = { red, green, blue };
373
- this._rgbValue = { red, green, blue };
374
- }
375
- const [response] = await helpers_1.Helpers.callApi('/dimmer/v1/device/devicergbstatus', 'put', body, helpers_1.Helpers.reqHeaders(this.manager));
376
- if (response?.code === 0) {
377
- this._rgbStatus = status;
378
- return true;
379
- }
380
- console.debug(`Error setting ${this.deviceName} RGB status`);
381
- return false;
382
- }
383
- /**
384
- * Turn RGB Color Off
385
- */
386
- async rgbColorOff() {
387
- return this.rgbColorStatus('off');
388
- }
389
- /**
390
- * Turn RGB Color On
391
- */
392
- async rgbColorOn() {
393
- return this.rgbColorStatus('on');
394
- }
395
- /**
396
- * Turn indicator light on
397
- */
398
- async indicatorLightOn() {
399
- return this.indicatorLightToggle('on');
400
- }
401
- /**
402
- * Turn indicator light off
403
- */
404
- async indicatorLightOff() {
405
- return this.indicatorLightToggle('off');
406
- }
407
- }
408
- exports.VeSyncDimmerSwitch = VeSyncDimmerSwitch;
409
- // Export switch modules for device factory
410
- exports.switchModules = {
411
- 'ESWL01': VeSyncWallSwitch,
412
- 'ESWL03': VeSyncWallSwitch,
413
- 'ESWD16': VeSyncDimmerSwitch
414
- };
@@ -1,82 +0,0 @@
1
- /**
2
- * VeSync Switch Implementations
3
- */
4
- import { VeSyncSwitch } from './vesyncSwitch';
5
- import { VeSync } from './vesync';
6
- /**
7
- * Basic Wall Switch Implementation (ESWL01, ESWL03)
8
- */
9
- export declare class VeSyncWallSwitch extends VeSyncSwitch {
10
- constructor(details: Record<string, any>, manager: VeSync);
11
- /**
12
- * Get wall switch details
13
- */
14
- getDetails(): Promise<void>;
15
- /**
16
- * Get switch device configuration info
17
- */
18
- getConfig(): Promise<void>;
19
- /**
20
- * Turn off wall switch
21
- */
22
- turnOff(): Promise<boolean>;
23
- /**
24
- * Turn on wall switch
25
- */
26
- turnOn(): Promise<boolean>;
27
- }
28
- /**
29
- * Dimmer Switch Implementation (ESWD16)
30
- */
31
- export declare class VeSyncDimmerSwitch extends VeSyncSwitch {
32
- private _brightness;
33
- private _rgbValue;
34
- private _rgbStatus;
35
- private _indicatorLight;
36
- constructor(details: Record<string, any>, manager: VeSync);
37
- /**
38
- * Get dimmer switch details
39
- */
40
- getDetails(): Promise<void>;
41
- /**
42
- * Get dimmer switch configuration info
43
- */
44
- getConfig(): Promise<void>;
45
- /**
46
- * Turn off dimmer switch
47
- */
48
- turnOff(): Promise<boolean>;
49
- /**
50
- * Turn on dimmer switch
51
- */
52
- turnOn(): Promise<boolean>;
53
- /**
54
- * Set brightness level
55
- */
56
- setBrightness(brightness: number): Promise<boolean>;
57
- /**
58
- * Set RGB indicator color
59
- */
60
- rgbColorSet(red: number, green: number, blue: number): Promise<boolean>;
61
- /**
62
- * Turn on RGB indicator
63
- */
64
- rgbColorOn(): Promise<boolean>;
65
- /**
66
- * Turn off RGB indicator
67
- */
68
- rgbColorOff(): Promise<boolean>;
69
- /**
70
- * Turn on indicator light
71
- */
72
- indicatorLightOn(): Promise<boolean>;
73
- /**
74
- * Turn off indicator light
75
- */
76
- indicatorLightOff(): Promise<boolean>;
77
- get brightness(): number;
78
- get indicatorLightStatus(): string;
79
- get rgbLightStatus(): string;
80
- get rgbLightValue(): Record<string, number>;
81
- }
82
- export declare const switchModules: Record<string, any>;