@switchbot/homebridge-switchbot 2.0.0-beta.13 → 2.0.0-beta.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 (84) hide show
  1. package/dist/device/bot.d.ts.map +1 -1
  2. package/dist/device/bot.js +19 -18
  3. package/dist/device/bot.js.map +1 -1
  4. package/dist/device/colorbulb.js +25 -25
  5. package/dist/device/colorbulb.js.map +1 -1
  6. package/dist/device/contact.d.ts.map +1 -1
  7. package/dist/device/contact.js +7 -6
  8. package/dist/device/contact.js.map +1 -1
  9. package/dist/device/curtain.d.ts.map +1 -1
  10. package/dist/device/curtain.js +14 -13
  11. package/dist/device/curtain.js.map +1 -1
  12. package/dist/device/humidifier.d.ts.map +1 -1
  13. package/dist/device/humidifier.js +18 -17
  14. package/dist/device/humidifier.js.map +1 -1
  15. package/dist/device/lock.d.ts.map +1 -1
  16. package/dist/device/lock.js +8 -7
  17. package/dist/device/lock.js.map +1 -1
  18. package/dist/device/meter.d.ts.map +1 -1
  19. package/dist/device/meter.js +9 -8
  20. package/dist/device/meter.js.map +1 -1
  21. package/dist/device/meterplus.d.ts.map +1 -1
  22. package/dist/device/meterplus.js +8 -7
  23. package/dist/device/meterplus.js.map +1 -1
  24. package/dist/device/motion.d.ts.map +1 -1
  25. package/dist/device/motion.js +7 -6
  26. package/dist/device/motion.js.map +1 -1
  27. package/dist/device/plug.d.ts.map +1 -1
  28. package/dist/device/plug.js +13 -12
  29. package/dist/device/plug.js.map +1 -1
  30. package/dist/device/striplight.d.ts.map +1 -1
  31. package/dist/device/striplight.js +27 -26
  32. package/dist/device/striplight.js.map +1 -1
  33. package/dist/irdevice/airconditioner.d.ts.map +1 -1
  34. package/dist/irdevice/airconditioner.js +10 -9
  35. package/dist/irdevice/airconditioner.js.map +1 -1
  36. package/dist/irdevice/airpurifier.d.ts.map +1 -1
  37. package/dist/irdevice/airpurifier.js +8 -7
  38. package/dist/irdevice/airpurifier.js.map +1 -1
  39. package/dist/irdevice/camera.d.ts.map +1 -1
  40. package/dist/irdevice/camera.js +7 -6
  41. package/dist/irdevice/camera.js.map +1 -1
  42. package/dist/irdevice/fan.d.ts.map +1 -1
  43. package/dist/irdevice/fan.js +10 -9
  44. package/dist/irdevice/fan.js.map +1 -1
  45. package/dist/irdevice/light.d.ts.map +1 -1
  46. package/dist/irdevice/light.js +9 -8
  47. package/dist/irdevice/light.js.map +1 -1
  48. package/dist/irdevice/other.d.ts.map +1 -1
  49. package/dist/irdevice/other.js +7 -6
  50. package/dist/irdevice/other.js.map +1 -1
  51. package/dist/irdevice/tv.d.ts.map +1 -1
  52. package/dist/irdevice/tv.js +16 -15
  53. package/dist/irdevice/tv.js.map +1 -1
  54. package/dist/irdevice/vacuumcleaner.d.ts.map +1 -1
  55. package/dist/irdevice/vacuumcleaner.js +7 -6
  56. package/dist/irdevice/vacuumcleaner.js.map +1 -1
  57. package/dist/irdevice/waterheater.d.ts.map +1 -1
  58. package/dist/irdevice/waterheater.js +7 -6
  59. package/dist/irdevice/waterheater.js.map +1 -1
  60. package/dist/platform.d.ts.map +1 -1
  61. package/dist/platform.js +24 -23
  62. package/dist/platform.js.map +1 -1
  63. package/package.json +1 -1
  64. package/src/device/bot.ts +19 -18
  65. package/src/device/colorbulb.ts +25 -25
  66. package/src/device/contact.ts +7 -6
  67. package/src/device/curtain.ts +14 -13
  68. package/src/device/humidifier.ts +18 -17
  69. package/src/device/lock.ts +8 -7
  70. package/src/device/meter.ts +9 -8
  71. package/src/device/meterplus.ts +8 -7
  72. package/src/device/motion.ts +7 -6
  73. package/src/device/plug.ts +13 -12
  74. package/src/device/striplight.ts +27 -26
  75. package/src/irdevice/airconditioner.ts +10 -9
  76. package/src/irdevice/airpurifier.ts +8 -7
  77. package/src/irdevice/camera.ts +7 -6
  78. package/src/irdevice/fan.ts +10 -9
  79. package/src/irdevice/light.ts +9 -8
  80. package/src/irdevice/other.ts +7 -6
  81. package/src/irdevice/tv.ts +16 -15
  82. package/src/irdevice/vacuumcleaner.ts +7 -6
  83. package/src/irdevice/waterheater.ts +7 -6
  84. package/src/platform.ts +24 -23
@@ -1,6 +1,7 @@
1
1
  import https from 'https';
2
2
  import crypto from 'crypto';
3
3
  import { IncomingMessage } from 'http';
4
+ import superStringify from 'super-stringify';
4
5
  import { SwitchBotPlatform } from '../platform';
5
6
  import { irDevicesConfig, irdevice, HostDomain, DevicePath } from '../settings';
6
7
  import { CharacteristicValue, PlatformAccessory, Service } from 'homebridge';
@@ -158,7 +159,7 @@ export class AirPurifier {
158
159
  */
159
160
  async pushAirPurifierOnChanges(): Promise<void> {
160
161
  if (this.Active !== 1) {
161
- const body = JSON.stringify({
162
+ const body = superStringify({
162
163
  'command': 'turnOn',
163
164
  'parameter': 'default',
164
165
  'commandType': 'command',
@@ -169,7 +170,7 @@ export class AirPurifier {
169
170
 
170
171
  async pushAirPurifierOffChanges(): Promise<void> {
171
172
  if (this.Active !== 0) {
172
- const body = JSON.stringify({
173
+ const body = superStringify({
173
174
  'command': 'turnOff',
174
175
  'parameter': 'default',
175
176
  'commandType': 'command',
@@ -195,7 +196,7 @@ export class AirPurifier {
195
196
  this.CurrentAPFanSpeed = this.CurrentFanSpeed || 1;
196
197
  this.APActive = this.Active === 1 ? 'on' : 'off';
197
198
  const parameter = `${this.CurrentAPTemp},${this.CurrentAPMode},${this.CurrentAPFanSpeed},${this.APActive}`;
198
- const body = JSON.stringify({
199
+ const body = superStringify({
199
200
  'command': 'setAll',
200
201
  'parameter': `${parameter}`,
201
202
  'commandType': 'command',
@@ -250,7 +251,7 @@ export class AirPurifier {
250
251
  });
251
252
  req.write(body);
252
253
  req.end();
253
- this.debugLog(`Air Purifier: ${this.accessory.displayName} pushchanges: ${JSON.stringify(req)}`);
254
+ this.debugLog(`Air Purifier: ${this.accessory.displayName} pushchanges: ${superStringify(req)}`);
254
255
  this.updateHomeKitCharacteristics();
255
256
  this.CurrentTemperatureCached = this.CurrentTemperature;
256
257
  this.accessory.context.CurrentTemperature = this.CurrentTemperatureCached;
@@ -258,7 +259,7 @@ export class AirPurifier {
258
259
  this.errorLog(`Air Purifier: ${this.accessory.displayName} failed pushChanges with OpenAPI Connection`);
259
260
  if (this.deviceLogging.includes('debug')) {
260
261
  this.errorLog(
261
- `Air Purifier: ${this.accessory.displayName} failed pushChanges with OpenAPI Connection,` + ` Error Message: ${JSON.stringify(e.message)}`,
262
+ `Air Purifier: ${this.accessory.displayName} failed pushChanges with OpenAPI Connection,` + ` Error Message: ${superStringify(e.message)}`,
262
263
  );
263
264
  }
264
265
  this.apiError(e);
@@ -285,7 +286,7 @@ export class AirPurifier {
285
286
  case 190:
286
287
  this.errorLog(
287
288
  `Air Purifier: ${this.accessory.displayName} Device internal error due to device states not synchronized` +
288
- ` with server, Or command: ${JSON.stringify(res)} format is invalid`,
289
+ ` with server, Or command: ${superStringify(res)} format is invalid`,
289
290
  );
290
291
  break;
291
292
  case 100:
@@ -313,7 +314,7 @@ export class AirPurifier {
313
314
  config['logging'] = device.logging;
314
315
  }
315
316
  if (Object.entries(config).length !== 0) {
316
- this.infoLog(`Air Purifier: ${this.accessory.displayName} Config: ${JSON.stringify(config)}`);
317
+ this.infoLog(`Air Purifier: ${this.accessory.displayName} Config: ${superStringify(config)}`);
317
318
  }
318
319
  }
319
320
 
@@ -1,6 +1,7 @@
1
1
  import https from 'https';
2
2
  import crypto from 'crypto';
3
3
  import { IncomingMessage } from 'http';
4
+ import superStringify from 'super-stringify';
4
5
  import { SwitchBotPlatform } from '../platform';
5
6
  import { irDevicesConfig, irdevice, HostDomain, DevicePath } from '../settings';
6
7
  import { CharacteristicValue, PlatformAccessory, Service } from 'homebridge';
@@ -86,7 +87,7 @@ export class Camera {
86
87
  */
87
88
  async pushOnChanges(): Promise<void> {
88
89
  if (this.On) {
89
- const body = JSON.stringify({
90
+ const body = superStringify({
90
91
  'command': 'turnOn',
91
92
  'parameter': 'default',
92
93
  'commandType': 'command',
@@ -97,7 +98,7 @@ export class Camera {
97
98
 
98
99
  async pushOffChanges(): Promise<void> {
99
100
  if (!this.On) {
100
- const body = JSON.stringify({
101
+ const body = superStringify({
101
102
  'command': 'turnOff',
102
103
  'parameter': 'default',
103
104
  'commandType': 'command',
@@ -144,7 +145,7 @@ export class Camera {
144
145
  });
145
146
  req.write(body);
146
147
  req.end();
147
- this.debugLog(`Camera: ${this.accessory.displayName} pushchanges: ${JSON.stringify(req)}`);
148
+ this.debugLog(`Camera: ${this.accessory.displayName} pushchanges: ${superStringify(req)}`);
148
149
  this.updateHomeKitCharacteristics();
149
150
  this.OnCached = this.On;
150
151
  this.accessory.context.On = this.OnCached;
@@ -152,7 +153,7 @@ export class Camera {
152
153
  this.errorLog(`Camera: ${this.accessory.displayName} failed pushChanges with OpenAPI Connection`);
153
154
  if (this.deviceLogging.includes('debug')) {
154
155
  this.errorLog(
155
- `Camera: ${this.accessory.displayName} failed pushChanges with OpenAPI Connection,` + ` Error Message: ${JSON.stringify(e.message)}`,
156
+ `Camera: ${this.accessory.displayName} failed pushChanges with OpenAPI Connection,` + ` Error Message: ${superStringify(e.message)}`,
156
157
  );
157
158
  }
158
159
  this.apiError(e);
@@ -179,7 +180,7 @@ export class Camera {
179
180
  case 190:
180
181
  this.errorLog(
181
182
  `Camera: ${this.accessory.displayName} Device internal error due to device states not synchronized` +
182
- ` with server, Or command: ${JSON.stringify(res)} format is invalid`,
183
+ ` with server, Or command: ${superStringify(res)} format is invalid`,
183
184
  );
184
185
  break;
185
186
  case 100:
@@ -204,7 +205,7 @@ export class Camera {
204
205
  config['logging'] = device.logging;
205
206
  }
206
207
  if (Object.entries(config).length !== 0) {
207
- this.infoLog(`Camera: ${this.accessory.displayName} Config: ${JSON.stringify(config)}`);
208
+ this.infoLog(`Camera: ${this.accessory.displayName} Config: ${superStringify(config)}`);
208
209
  }
209
210
  }
210
211
 
@@ -1,6 +1,7 @@
1
1
  import https from 'https';
2
2
  import crypto from 'crypto';
3
3
  import { IncomingMessage } from 'http';
4
+ import superStringify from 'super-stringify';
4
5
  import { SwitchBotPlatform } from '../platform';
5
6
  import { CharacteristicValue, PlatformAccessory, Service } from 'homebridge';
6
7
  import { irdevice, irDevicesConfig, HostDomain, DevicePath } from '../settings';
@@ -188,7 +189,7 @@ export class Fan {
188
189
  */
189
190
  async pushFanOnChanges(): Promise<void> {
190
191
  if (this.Active !== 1) {
191
- const body = JSON.stringify({
192
+ const body = superStringify({
192
193
  'command': 'turnOn',
193
194
  'parameter': 'default',
194
195
  'commandType': 'command',
@@ -198,7 +199,7 @@ export class Fan {
198
199
  }
199
200
 
200
201
  async pushFanOffChanges(): Promise<void> {
201
- const body = JSON.stringify({
202
+ const body = superStringify({
202
203
  'command': 'turnOff',
203
204
  'parameter': 'default',
204
205
  'commandType': 'command',
@@ -207,7 +208,7 @@ export class Fan {
207
208
  }
208
209
 
209
210
  async pushFanSpeedUpChanges(): Promise<void> {
210
- const body = JSON.stringify({
211
+ const body = superStringify({
211
212
  'command': 'highSpeed',
212
213
  'parameter': 'default',
213
214
  'commandType': 'command',
@@ -216,7 +217,7 @@ export class Fan {
216
217
  }
217
218
 
218
219
  async pushFanSpeedDownChanges(): Promise<void> {
219
- const body = JSON.stringify({
220
+ const body = superStringify({
220
221
  'command': 'lowSpeed',
221
222
  'parameter': 'default',
222
223
  'commandType': 'command',
@@ -225,7 +226,7 @@ export class Fan {
225
226
  }
226
227
 
227
228
  async pushFanSwingChanges(): Promise<void> {
228
- const body = JSON.stringify({
229
+ const body = superStringify({
229
230
  'command': 'swing',
230
231
  'parameter': 'default',
231
232
  'commandType': 'command',
@@ -271,13 +272,13 @@ export class Fan {
271
272
  });
272
273
  req.write(body);
273
274
  req.end();
274
- this.debugLog(`Fan: ${this.accessory.displayName} pushchanges: ${JSON.stringify(req)}`);
275
+ this.debugLog(`Fan: ${this.accessory.displayName} pushchanges: ${superStringify(req)}`);
275
276
  this.updateHomeKitCharacteristics();
276
277
  } catch (e: any) {
277
278
  this.errorLog(`Fan: ${this.accessory.displayName} failed pushChanges with OpenAPI Connection`);
278
279
  if (this.deviceLogging.includes('debug')) {
279
280
  this.errorLog(
280
- `Fan: ${this.accessory.displayName} failed pushChanges with OpenAPI Connection,` + ` Error Message: ${JSON.stringify(e.message)}`,
281
+ `Fan: ${this.accessory.displayName} failed pushChanges with OpenAPI Connection,` + ` Error Message: ${superStringify(e.message)}`,
281
282
  );
282
283
  }
283
284
  this.apiError(e);
@@ -304,7 +305,7 @@ export class Fan {
304
305
  case 190:
305
306
  this.errorLog(
306
307
  `Fan: ${this.accessory.displayName} Device internal error due to device states not synchronized` +
307
- ` with server, Or command: ${JSON.stringify(res)} format is invalid`,
308
+ ` with server, Or command: ${superStringify(res)} format is invalid`,
308
309
  );
309
310
  break;
310
311
  case 100:
@@ -331,7 +332,7 @@ export class Fan {
331
332
  config['logging'] = device.logging;
332
333
  }
333
334
  if (Object.entries(config).length !== 0) {
334
- this.infoLog(`Fan: ${this.accessory.displayName} Config: ${JSON.stringify(config)}`);
335
+ this.infoLog(`Fan: ${this.accessory.displayName} Config: ${superStringify(config)}`);
335
336
  }
336
337
  }
337
338
 
@@ -1,6 +1,7 @@
1
1
  import https from 'https';
2
2
  import crypto from 'crypto';
3
3
  import { IncomingMessage } from 'http';
4
+ import superStringify from 'super-stringify';
4
5
  import { SwitchBotPlatform } from '../platform';
5
6
  import { irDevicesConfig, irdevice, HostDomain, DevicePath } from '../settings';
6
7
  import { CharacteristicValue, PlatformAccessory, Service } from 'homebridge';
@@ -101,7 +102,7 @@ export class Light {
101
102
  */
102
103
  async pushLightOnChanges(): Promise<void> {
103
104
  if (this.On) {
104
- const body = JSON.stringify({
105
+ const body = superStringify({
105
106
  'command': 'turnOn',
106
107
  'parameter': 'default',
107
108
  'commandType': 'command',
@@ -112,7 +113,7 @@ export class Light {
112
113
 
113
114
  async pushLightOffChanges(): Promise<void> {
114
115
  if (!this.On) {
115
- const body = JSON.stringify({
116
+ const body = superStringify({
116
117
  'command': 'turnOff',
117
118
  'parameter': 'default',
118
119
  'commandType': 'command',
@@ -122,7 +123,7 @@ export class Light {
122
123
  }
123
124
 
124
125
  async pushLightBrightnessUpChanges(): Promise<void> {
125
- const body = JSON.stringify({
126
+ const body = superStringify({
126
127
  'command': 'brightnessUp',
127
128
  'parameter': 'default',
128
129
  'commandType': 'command',
@@ -131,7 +132,7 @@ export class Light {
131
132
  }
132
133
 
133
134
  async pushLightBrightnessDownChanges(): Promise<void> {
134
- const body = JSON.stringify({
135
+ const body = superStringify({
135
136
  'command': 'brightnessDown',
136
137
  'parameter': 'default',
137
138
  'commandType': 'command',
@@ -177,7 +178,7 @@ export class Light {
177
178
  });
178
179
  req.write(body);
179
180
  req.end();
180
- this.debugLog(`Light: ${this.accessory.displayName} pushchanges: ${JSON.stringify(req)}`);
181
+ this.debugLog(`Light: ${this.accessory.displayName} pushchanges: ${superStringify(req)}`);
181
182
  this.OnCached = this.On;
182
183
  this.accessory.context.On = this.OnCached;
183
184
  this.updateHomeKitCharacteristics();
@@ -185,7 +186,7 @@ export class Light {
185
186
  this.errorLog(`Light: ${this.accessory.displayName} failed pushChanges with OpenAPI Connection`);
186
187
  if (this.deviceLogging.includes('debug')) {
187
188
  this.errorLog(
188
- `Light: ${this.accessory.displayName} failed pushChanges with OpenAPI Connection,` + ` Error Message: ${JSON.stringify(e.message)}`,
189
+ `Light: ${this.accessory.displayName} failed pushChanges with OpenAPI Connection,` + ` Error Message: ${superStringify(e.message)}`,
189
190
  );
190
191
  }
191
192
  this.apiError(e);
@@ -212,7 +213,7 @@ export class Light {
212
213
  case 190:
213
214
  this.errorLog(
214
215
  `Light: ${this.accessory.displayName} Device internal error due to device states not synchronized` +
215
- ` with server, Or command: ${JSON.stringify(res)} format is invalid`,
216
+ ` with server, Or command: ${superStringify(res)} format is invalid`,
216
217
  );
217
218
  break;
218
219
  case 100:
@@ -237,7 +238,7 @@ export class Light {
237
238
  config['logging'] = device.logging;
238
239
  }
239
240
  if (Object.entries(config).length !== 0) {
240
- this.infoLog(`Light: ${this.accessory.displayName} Config: ${JSON.stringify(config)}`);
241
+ this.infoLog(`Light: ${this.accessory.displayName} Config: ${superStringify(config)}`);
241
242
  }
242
243
  }
243
244
 
@@ -1,6 +1,7 @@
1
1
  import https from 'https';
2
2
  import crypto from 'crypto';
3
3
  import { IncomingMessage } from 'http';
4
+ import superStringify from 'super-stringify';
4
5
  import { SwitchBotPlatform } from '../platform';
5
6
  import { irDevicesConfig, irdevice, HostDomain, DevicePath } from '../settings';
6
7
  import { CharacteristicValue, PlatformAccessory, Service } from 'homebridge';
@@ -99,7 +100,7 @@ export class Others {
99
100
  if (this.device.other) {
100
101
  if (this.device.other.commandOn) {
101
102
  if (!this.Active) {
102
- const body = JSON.stringify({
103
+ const body = superStringify({
103
104
  'command': `${this.device.other.commandOn}`,
104
105
  'parameter': 'default',
105
106
  'commandType': 'customize',
@@ -122,7 +123,7 @@ export class Others {
122
123
  if (this.device.other) {
123
124
  if (this.device.other.commandOff) {
124
125
  if (this.Active) {
125
- const body = JSON.stringify({
126
+ const body = superStringify({
126
127
  'command': `${this.device.other.commandOff}`,
127
128
  'parameter': 'default',
128
129
  'commandType': 'customize',
@@ -178,13 +179,13 @@ export class Others {
178
179
  });
179
180
  req.write(body);
180
181
  req.end();
181
- this.debugLog(`Other: ${this.accessory.displayName} pushchanges: ${JSON.stringify(req)}`);
182
+ this.debugLog(`Other: ${this.accessory.displayName} pushchanges: ${superStringify(req)}`);
182
183
  this.updateHomeKitCharacteristics();
183
184
  } catch (e: any) {
184
185
  this.errorLog(`Other: ${this.accessory.displayName} failed pushChanges with OpenAPI Connection`);
185
186
  if (this.deviceLogging.includes('debug')) {
186
187
  this.errorLog(
187
- `Other: ${this.accessory.displayName} failed pushChanges with OpenAPI Connection,` + ` Error Message: ${JSON.stringify(e.message)}`,
188
+ `Other: ${this.accessory.displayName} failed pushChanges with OpenAPI Connection,` + ` Error Message: ${superStringify(e.message)}`,
188
189
  );
189
190
  }
190
191
  this.apiError(e);
@@ -211,7 +212,7 @@ export class Others {
211
212
  case 190:
212
213
  this.errorLog(
213
214
  `Other: ${this.accessory.displayName} Device internal error due to device states not synchronized` +
214
- ` with server, Or command: ${JSON.stringify(res)} format is invalid`,
215
+ ` with server, Or command: ${superStringify(res)} format is invalid`,
215
216
  );
216
217
  break;
217
218
  case 100:
@@ -247,7 +248,7 @@ export class Others {
247
248
  config['logging'] = device.logging;
248
249
  }
249
250
  if (Object.entries(config).length !== 0) {
250
- this.infoLog(`Other: ${this.accessory.displayName} Config: ${JSON.stringify(config)}`);
251
+ this.infoLog(`Other: ${this.accessory.displayName} Config: ${superStringify(config)}`);
251
252
  }
252
253
  }
253
254
 
@@ -1,6 +1,7 @@
1
1
  import https from 'https';
2
2
  import crypto from 'crypto';
3
3
  import { IncomingMessage } from 'http';
4
+ import superStringify from 'super-stringify';
4
5
  import { SwitchBotPlatform } from '../platform';
5
6
  import { CharacteristicValue, PlatformAccessory, Service } from 'homebridge';
6
7
  import { irdevice, irDevicesConfig, HostDomain, DevicePath } from '../settings';
@@ -237,7 +238,7 @@ export class TV {
237
238
  */
238
239
  async pushTvOnChanges(): Promise<void> {
239
240
  if (this.Active !== 1) {
240
- const body = JSON.stringify({
241
+ const body = superStringify({
241
242
  'command': 'turnOn',
242
243
  'parameter': 'default',
243
244
  'commandType': 'command',
@@ -247,7 +248,7 @@ export class TV {
247
248
  }
248
249
 
249
250
  async pushTvOffChanges(): Promise<void> {
250
- const body = JSON.stringify({
251
+ const body = superStringify({
251
252
  'command': 'turnOff',
252
253
  'parameter': 'default',
253
254
  'commandType': 'command',
@@ -256,7 +257,7 @@ export class TV {
256
257
  }
257
258
 
258
259
  async pushOkChanges(): Promise<void> {
259
- const body = JSON.stringify({
260
+ const body = superStringify({
260
261
  'command': 'Ok',
261
262
  'parameter': 'default',
262
263
  'commandType': 'command',
@@ -265,7 +266,7 @@ export class TV {
265
266
  }
266
267
 
267
268
  async pushBackChanges(): Promise<void> {
268
- const body = JSON.stringify({
269
+ const body = superStringify({
269
270
  'command': 'Back',
270
271
  'parameter': 'default',
271
272
  'commandType': 'command',
@@ -274,7 +275,7 @@ export class TV {
274
275
  }
275
276
 
276
277
  async pushMenuChanges(): Promise<void> {
277
- const body = JSON.stringify({
278
+ const body = superStringify({
278
279
  'command': 'Menu',
279
280
  'parameter': 'default',
280
281
  'commandType': 'command',
@@ -283,7 +284,7 @@ export class TV {
283
284
  }
284
285
 
285
286
  async pushUpChanges(): Promise<void> {
286
- const body = JSON.stringify({
287
+ const body = superStringify({
287
288
  'command': 'Up',
288
289
  'parameter': 'default',
289
290
  'commandType': 'command',
@@ -292,7 +293,7 @@ export class TV {
292
293
  }
293
294
 
294
295
  async pushDownChanges(): Promise<void> {
295
- const body = JSON.stringify({
296
+ const body = superStringify({
296
297
  'command': 'Down',
297
298
  'parameter': 'default',
298
299
  'commandType': 'command',
@@ -301,7 +302,7 @@ export class TV {
301
302
  }
302
303
 
303
304
  async pushRightChanges(): Promise<void> {
304
- const body = JSON.stringify({
305
+ const body = superStringify({
305
306
  'command': 'Right',
306
307
  'parameter': 'default',
307
308
  'commandType': 'command',
@@ -310,7 +311,7 @@ export class TV {
310
311
  }
311
312
 
312
313
  async pushLeftChanges(): Promise<void> {
313
- const body = JSON.stringify({
314
+ const body = superStringify({
314
315
  'command': 'Left',
315
316
  'parameter': 'default',
316
317
  'commandType': 'command',
@@ -319,7 +320,7 @@ export class TV {
319
320
  }
320
321
 
321
322
  async pushVolumeUpChanges(): Promise<void> {
322
- const body = JSON.stringify({
323
+ const body = superStringify({
323
324
  'command': 'volumeAdd',
324
325
  'parameter': 'default',
325
326
  'commandType': 'command',
@@ -328,7 +329,7 @@ export class TV {
328
329
  }
329
330
 
330
331
  async pushVolumeDownChanges(): Promise<void> {
331
- const body = JSON.stringify({
332
+ const body = superStringify({
332
333
  'command': 'volumeSub',
333
334
  'parameter': 'default',
334
335
  'commandType': 'command',
@@ -374,14 +375,14 @@ export class TV {
374
375
  });
375
376
  req.write(body);
376
377
  req.end();
377
- this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} pushchanges: ${JSON.stringify(req)}`);
378
+ this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} pushchanges: ${superStringify(req)}`);
378
379
  this.updateHomeKitCharacteristics();
379
380
  } catch (e: any) {
380
381
  this.errorLog(`${this.device.remoteType}: ${this.accessory.displayName} failed pushChanges with OpenAPI Connection`);
381
382
  if (this.deviceLogging.includes('debug')) {
382
383
  this.errorLog(
383
384
  `${this.device.remoteType}: ${this.accessory.displayName} failed pushChanges with OpenAPI Connection,` +
384
- ` Error Message: ${JSON.stringify(e.message)}`,
385
+ ` Error Message: ${superStringify(e.message)}`,
385
386
  );
386
387
  }
387
388
  this.apiError(e);
@@ -409,7 +410,7 @@ export class TV {
409
410
  this.errorLog(
410
411
  `${this.device.remoteType}: ` +
411
412
  `${this.accessory.displayName} Device internal error due to device states not synchronized with server,` +
412
- ` Or command: ${JSON.stringify(res)} format is invalid`,
413
+ ` Or command: ${superStringify(res)} format is invalid`,
413
414
  );
414
415
  break;
415
416
  case 100:
@@ -435,7 +436,7 @@ export class TV {
435
436
  config['logging'] = device.logging;
436
437
  }
437
438
  if (Object.entries(config).length !== 0) {
438
- this.infoLog(`${this.device.remoteType}: ${this.accessory.displayName} Config: ${JSON.stringify(config)}`);
439
+ this.infoLog(`${this.device.remoteType}: ${this.accessory.displayName} Config: ${superStringify(config)}`);
439
440
  }
440
441
  }
441
442
 
@@ -1,6 +1,7 @@
1
1
  import https from 'https';
2
2
  import crypto from 'crypto';
3
3
  import { IncomingMessage } from 'http';
4
+ import superStringify from 'super-stringify';
4
5
  import { SwitchBotPlatform } from '../platform';
5
6
  import { irDevicesConfig, irdevice, HostDomain, DevicePath } from '../settings';
6
7
  import { CharacteristicValue, PlatformAccessory, Service } from 'homebridge';
@@ -86,7 +87,7 @@ export class VacuumCleaner {
86
87
  */
87
88
  async pushOnChanges(): Promise<void> {
88
89
  if (this.On) {
89
- const body = JSON.stringify({
90
+ const body = superStringify({
90
91
  'command': 'turnOn',
91
92
  'parameter': 'default',
92
93
  'commandType': 'command',
@@ -97,7 +98,7 @@ export class VacuumCleaner {
97
98
 
98
99
  async pushOffChanges(): Promise<void> {
99
100
  if (!this.On) {
100
- const body = JSON.stringify({
101
+ const body = superStringify({
101
102
  'command': 'turnOff',
102
103
  'parameter': 'default',
103
104
  'commandType': 'command',
@@ -144,7 +145,7 @@ export class VacuumCleaner {
144
145
  });
145
146
  req.write(body);
146
147
  req.end();
147
- this.debugLog(`Vacuum Cleaner: ${this.accessory.displayName} pushchanges: ${JSON.stringify(req)}`);
148
+ this.debugLog(`Vacuum Cleaner: ${this.accessory.displayName} pushchanges: ${superStringify(req)}`);
148
149
  this.OnCached = this.On;
149
150
  this.accessory.context.On = this.OnCached;
150
151
  this.updateHomeKitCharacteristics();
@@ -153,7 +154,7 @@ export class VacuumCleaner {
153
154
  if (this.deviceLogging.includes('debug')) {
154
155
  this.errorLog(
155
156
  `Vacuum Cleaner: ${this.accessory.displayName} failed pushChanges with OpenAPI Connection,` +
156
- ` Error Message: ${JSON.stringify(e.message)}`,
157
+ ` Error Message: ${superStringify(e.message)}`,
157
158
  );
158
159
  }
159
160
  this.apiError(e);
@@ -180,7 +181,7 @@ export class VacuumCleaner {
180
181
  case 190:
181
182
  this.errorLog(
182
183
  `Vacuum Cleaner: ${this.accessory.displayName} Device internal error due to device states not synchronized` +
183
- ` with server, Or command: ${JSON.stringify(res)} format is invalid`,
184
+ ` with server, Or command: ${superStringify(res)} format is invalid`,
184
185
  );
185
186
  break;
186
187
  case 100:
@@ -205,7 +206,7 @@ export class VacuumCleaner {
205
206
  config['logging'] = device.logging;
206
207
  }
207
208
  if (Object.entries(config).length !== 0) {
208
- this.infoLog(`Vacuum Cleaner: ${this.accessory.displayName} Config: ${JSON.stringify(config)}`);
209
+ this.infoLog(`Vacuum Cleaner: ${this.accessory.displayName} Config: ${superStringify(config)}`);
209
210
  }
210
211
  }
211
212
 
@@ -1,6 +1,7 @@
1
1
  import https from 'https';
2
2
  import crypto from 'crypto';
3
3
  import { IncomingMessage } from 'http';
4
+ import superStringify from 'super-stringify';
4
5
  import { SwitchBotPlatform } from '../platform';
5
6
  import { irDevicesConfig, irdevice, HostDomain, DevicePath } from '../settings';
6
7
  import { CharacteristicValue, PlatformAccessory, Service } from 'homebridge';
@@ -93,7 +94,7 @@ export class WaterHeater {
93
94
  */
94
95
  async pushWaterHeaterOnChanges(): Promise<void> {
95
96
  if (this.Active !== 1) {
96
- const body = JSON.stringify({
97
+ const body = superStringify({
97
98
  'command': 'turnOn',
98
99
  'parameter': 'default',
99
100
  'commandType': 'command',
@@ -104,7 +105,7 @@ export class WaterHeater {
104
105
 
105
106
  async pushWaterHeaterOffChanges(): Promise<void> {
106
107
  if (this.Active !== 0) {
107
- const body = JSON.stringify({
108
+ const body = superStringify({
108
109
  'command': 'turnOff',
109
110
  'parameter': 'default',
110
111
  'commandType': 'command',
@@ -151,13 +152,13 @@ export class WaterHeater {
151
152
  });
152
153
  req.write(body);
153
154
  req.end();
154
- this.debugLog(`Water Heater: ${this.accessory.displayName} pushchanges: ${JSON.stringify(req)}`);
155
+ this.debugLog(`Water Heater: ${this.accessory.displayName} pushchanges: ${superStringify(req)}`);
155
156
  this.updateHomeKitCharacteristics();
156
157
  } catch (e: any) {
157
158
  this.errorLog(`Water Heater: ${this.accessory.displayName} failed pushChanges with OpenAPI Connection`);
158
159
  if (this.deviceLogging.includes('debug')) {
159
160
  this.errorLog(
160
- `Water Heater: ${this.accessory.displayName} failed pushChanges with OpenAPI Connection,` + ` Error Message: ${JSON.stringify(e.message)}`,
161
+ `Water Heater: ${this.accessory.displayName} failed pushChanges with OpenAPI Connection,` + ` Error Message: ${superStringify(e.message)}`,
161
162
  );
162
163
  }
163
164
  this.apiError(e);
@@ -184,7 +185,7 @@ export class WaterHeater {
184
185
  case 190:
185
186
  this.errorLog(
186
187
  `Water Heater: ${this.accessory.displayName} Device internal error due to device states not synchronized` +
187
- ` with server, Or command: ${JSON.stringify(res)} format is invalid`,
188
+ ` with server, Or command: ${superStringify(res)} format is invalid`,
188
189
  );
189
190
  break;
190
191
  case 100:
@@ -209,7 +210,7 @@ export class WaterHeater {
209
210
  config['logging'] = device.logging;
210
211
  }
211
212
  if (Object.entries(config).length !== 0) {
212
- this.infoLog(`Water Heater: ${this.accessory.displayName} Config: ${JSON.stringify(config)}`);
213
+ this.infoLog(`Water Heater: ${this.accessory.displayName} Config: ${superStringify(config)}`);
213
214
  }
214
215
  }
215
216