tsvesync 1.0.14 → 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.
@@ -46,8 +46,27 @@ class VeSyncOutlet extends vesyncBaseDevice_1.VeSyncBaseDevice {
46
46
  */
47
47
  async getDetails() {
48
48
  logger_1.logger.debug(`[${this.deviceName}] Getting outlet details`);
49
- const url = `/v1/${this.deviceType}/${this.deviceType}-${this.cid}/detail`;
50
- const [response] = await helpers_1.Helpers.callApi(url, 'get', null, helpers_1.Helpers.reqHeaders(this.manager));
49
+ const body = {
50
+ ...helpers_1.Helpers.reqBody(this.manager, 'devicedetail'),
51
+ uuid: this.uuid
52
+ };
53
+ let url;
54
+ if (this.deviceType === 'wifi-switch-1.3') {
55
+ url = `/v1/device/${this.deviceType}-${this.cid}/detail`;
56
+ }
57
+ else if (this.deviceType.startsWith('ESO15')) {
58
+ url = '/outdoorsocket15a/v1/device/devicedetail';
59
+ }
60
+ else if (this.deviceType.startsWith('ESW15')) {
61
+ url = '/15a/v1/device/devicedetail';
62
+ }
63
+ else if (this.deviceType.startsWith('ESW03') || this.deviceType.startsWith('ESW01')) {
64
+ url = '/10a/v1/device/devicedetail';
65
+ }
66
+ else {
67
+ url = '/v1/device/devicedetail';
68
+ }
69
+ const [response] = await helpers_1.Helpers.callApi(url, this.deviceType === 'wifi-switch-1.3' ? 'get' : 'post', this.deviceType === 'wifi-switch-1.3' ? null : body, helpers_1.Helpers.reqHeaders(this.manager));
51
70
  if ((response === null || response === void 0 ? void 0 : response.code) === 0) {
52
71
  this.details = response.result;
53
72
  this.deviceStatus = response.result.deviceStatus;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "tsvesync",
3
- "version": "1.0.14",
3
+ "version": "1.0.15",
4
4
  "description": "A TypeScript library for interacting with VeSync smart home devices",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
@@ -58,11 +58,29 @@ export abstract class VeSyncOutlet extends VeSyncBaseDevice {
58
58
  */
59
59
  async getDetails(): Promise<void> {
60
60
  logger.debug(`[${this.deviceName}] Getting outlet details`);
61
- const url = `/v1/${this.deviceType}/${this.deviceType}-${this.cid}/detail`;
61
+
62
+ const body = {
63
+ ...Helpers.reqBody(this.manager, 'devicedetail'),
64
+ uuid: this.uuid
65
+ };
66
+
67
+ let url: string;
68
+ if (this.deviceType === 'wifi-switch-1.3') {
69
+ url = `/v1/device/${this.deviceType}-${this.cid}/detail`;
70
+ } else if (this.deviceType.startsWith('ESO15')) {
71
+ url = '/outdoorsocket15a/v1/device/devicedetail';
72
+ } else if (this.deviceType.startsWith('ESW15')) {
73
+ url = '/15a/v1/device/devicedetail';
74
+ } else if (this.deviceType.startsWith('ESW03') || this.deviceType.startsWith('ESW01')) {
75
+ url = '/10a/v1/device/devicedetail';
76
+ } else {
77
+ url = '/v1/device/devicedetail';
78
+ }
79
+
62
80
  const [response] = await Helpers.callApi(
63
81
  url,
64
- 'get',
65
- null,
82
+ this.deviceType === 'wifi-switch-1.3' ? 'get' : 'post',
83
+ this.deviceType === 'wifi-switch-1.3' ? null : body,
66
84
  Helpers.reqHeaders(this.manager)
67
85
  );
68
86