@switchbot/homebridge-switchbot 1.1.1-beta.7 → 1.2.1-beta.0
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/CHANGELOG.md +5 -1
- package/README.md +67 -28
- package/config.schema.json +46 -43
- package/dist/devices/bots.d.ts +2 -0
- package/dist/devices/bots.d.ts.map +1 -1
- package/dist/devices/bots.js +118 -68
- package/dist/devices/bots.js.map +1 -1
- package/dist/devices/colorbulb.d.ts +19 -3
- package/dist/devices/colorbulb.d.ts.map +1 -1
- package/dist/devices/colorbulb.js +190 -31
- package/dist/devices/colorbulb.js.map +1 -1
- package/dist/devices/contact.d.ts +2 -0
- package/dist/devices/contact.d.ts.map +1 -1
- package/dist/devices/contact.js +22 -5
- package/dist/devices/contact.js.map +1 -1
- package/dist/devices/curtains.d.ts +5 -3
- package/dist/devices/curtains.d.ts.map +1 -1
- package/dist/devices/curtains.js +76 -26
- package/dist/devices/curtains.js.map +1 -1
- package/dist/devices/humidifiers.d.ts +2 -0
- package/dist/devices/humidifiers.d.ts.map +1 -1
- package/dist/devices/humidifiers.js +84 -27
- package/dist/devices/humidifiers.js.map +1 -1
- package/dist/devices/indoorcam.d.ts +2 -0
- package/dist/devices/indoorcam.d.ts.map +1 -1
- package/dist/devices/indoorcam.js +23 -7
- package/dist/devices/indoorcam.js.map +1 -1
- package/dist/devices/meters.d.ts +2 -0
- package/dist/devices/meters.d.ts.map +1 -1
- package/dist/devices/meters.js +21 -3
- package/dist/devices/meters.js.map +1 -1
- package/dist/devices/motion.d.ts +2 -0
- package/dist/devices/motion.d.ts.map +1 -1
- package/dist/devices/motion.js +21 -3
- package/dist/devices/motion.js.map +1 -1
- package/dist/devices/plugs.d.ts +2 -0
- package/dist/devices/plugs.d.ts.map +1 -1
- package/dist/devices/plugs.js +23 -7
- package/dist/devices/plugs.js.map +1 -1
- package/dist/irdevices/airconditioners.d.ts +2 -0
- package/dist/irdevices/airconditioners.d.ts.map +1 -1
- package/dist/irdevices/airconditioners.js +14 -5
- package/dist/irdevices/airconditioners.js.map +1 -1
- package/dist/irdevices/airpurifiers.d.ts +2 -0
- package/dist/irdevices/airpurifiers.d.ts.map +1 -1
- package/dist/irdevices/airpurifiers.js +14 -5
- package/dist/irdevices/airpurifiers.js.map +1 -1
- package/dist/irdevices/cameras.d.ts +2 -0
- package/dist/irdevices/cameras.d.ts.map +1 -1
- package/dist/irdevices/cameras.js +14 -5
- package/dist/irdevices/cameras.js.map +1 -1
- package/dist/irdevices/fans.d.ts +2 -0
- package/dist/irdevices/fans.d.ts.map +1 -1
- package/dist/irdevices/fans.js +13 -5
- package/dist/irdevices/fans.js.map +1 -1
- package/dist/irdevices/lights.d.ts +2 -0
- package/dist/irdevices/lights.d.ts.map +1 -1
- package/dist/irdevices/lights.js +14 -5
- package/dist/irdevices/lights.js.map +1 -1
- package/dist/irdevices/others.d.ts +2 -0
- package/dist/irdevices/others.d.ts.map +1 -1
- package/dist/irdevices/others.js +20 -11
- package/dist/irdevices/others.js.map +1 -1
- package/dist/irdevices/tvs.d.ts +2 -0
- package/dist/irdevices/tvs.d.ts.map +1 -1
- package/dist/irdevices/tvs.js +14 -4
- package/dist/irdevices/tvs.js.map +1 -1
- package/dist/irdevices/vacuumcleaners.d.ts +2 -0
- package/dist/irdevices/vacuumcleaners.d.ts.map +1 -1
- package/dist/irdevices/vacuumcleaners.js +14 -5
- package/dist/irdevices/vacuumcleaners.js.map +1 -1
- package/dist/irdevices/waterheaters.d.ts +2 -0
- package/dist/irdevices/waterheaters.d.ts.map +1 -1
- package/dist/irdevices/waterheaters.js +14 -5
- package/dist/irdevices/waterheaters.js.map +1 -1
- package/dist/platform.d.ts +1 -0
- package/dist/platform.d.ts.map +1 -1
- package/dist/platform.js +35 -26
- package/dist/platform.js.map +1 -1
- package/dist/settings.d.ts +4 -0
- package/dist/settings.d.ts.map +1 -1
- package/dist/settings.js +557 -1
- package/dist/settings.js.map +1 -1
- package/package.json +6 -6
- package/src/devices/bots.ts +118 -69
- package/src/devices/colorbulb.ts +218 -33
- package/src/devices/contact.ts +23 -5
- package/src/devices/curtains.ts +80 -31
- package/src/devices/humidifiers.ts +85 -29
- package/src/devices/indoorcam.ts +24 -7
- package/src/devices/meters.ts +22 -3
- package/src/devices/motion.ts +22 -3
- package/src/devices/plugs.ts +24 -7
- package/src/irdevices/airconditioners.ts +15 -5
- package/src/irdevices/airpurifiers.ts +15 -5
- package/src/irdevices/cameras.ts +15 -5
- package/src/irdevices/fans.ts +13 -5
- package/src/irdevices/lights.ts +15 -5
- package/src/irdevices/others.ts +21 -11
- package/src/irdevices/tvs.ts +15 -4
- package/src/irdevices/vacuumcleaners.ts +15 -5
- package/src/irdevices/waterheaters.ts +15 -5
- package/src/platform.ts +36 -26
- package/src/settings.ts +557 -1
package/src/devices/contact.ts
CHANGED
|
@@ -34,6 +34,10 @@ export class Contact {
|
|
|
34
34
|
doorState!: serviceData['doorState'];
|
|
35
35
|
lightLevel!: serviceData['lightLevel'];
|
|
36
36
|
|
|
37
|
+
// Config
|
|
38
|
+
private readonly deviceDebug = this.platform.config.options?.debug === 'device' || this.platform.debugMode;
|
|
39
|
+
private readonly debugDebug = this.platform.config.options?.debug === 'debug' || this.platform.debugMode;
|
|
40
|
+
|
|
37
41
|
// Updates
|
|
38
42
|
contactUbpdateInProgress!: boolean;
|
|
39
43
|
doContactUpdate!: Subject<void>;
|
|
@@ -163,7 +167,7 @@ export class Contact {
|
|
|
163
167
|
this.ContactSensorState = this.platform.Characteristic.ContactSensorState.CONTACT_DETECTED;
|
|
164
168
|
break;
|
|
165
169
|
default:
|
|
166
|
-
this.platform.log.error(
|
|
170
|
+
this.platform.log.error(`Contact Sensor: ${this.accessory.displayName} timeout no closed, doorstate: ${this.doorState}`);
|
|
167
171
|
}
|
|
168
172
|
if (this.device.contact?.hide_lightsensor) {// Light Level
|
|
169
173
|
switch (this.lightLevel) {
|
|
@@ -256,7 +260,15 @@ export class Contact {
|
|
|
256
260
|
this.parseStatus();
|
|
257
261
|
this.updateHomeKitCharacteristics();
|
|
258
262
|
}).catch(async (e: any) => {
|
|
259
|
-
this.platform.log.error(`Contact Sensor: ${this.accessory.displayName}
|
|
263
|
+
this.platform.log.error(`Contact Sensor: ${this.accessory.displayName} failed refreshStatus with BLE Connection`);
|
|
264
|
+
if (this.deviceDebug) {
|
|
265
|
+
this.platform.log.error(`Contact Sensor: ${this.accessory.displayName} failed refreshStatus with BLE Connection,`
|
|
266
|
+
+ ` Error Message: ${JSON.stringify(e.message)}`);
|
|
267
|
+
}
|
|
268
|
+
if (this.debugDebug) {
|
|
269
|
+
this.platform.log.error(`Contact Sensor: ${this.accessory.displayName} failed refreshStatus with BLE Connection,`
|
|
270
|
+
+ ` Error: ${JSON.stringify(e)}`);
|
|
271
|
+
}
|
|
260
272
|
if (this.platform.config.credentials?.openToken) {
|
|
261
273
|
this.platform.log.warn(`Contact Sensor: ${this.accessory.displayName} Using OpenAPI Connection`);
|
|
262
274
|
await this.openAPIRefreshStatus();
|
|
@@ -273,9 +285,15 @@ export class Contact {
|
|
|
273
285
|
this.parseStatus();
|
|
274
286
|
this.updateHomeKitCharacteristics();
|
|
275
287
|
} catch (e: any) {
|
|
276
|
-
this.platform.log.error(`Contact Sensor: ${this.accessory.displayName} failed
|
|
277
|
-
|
|
278
|
-
|
|
288
|
+
this.platform.log.error(`Contact Sensor: ${this.accessory.displayName} failed refreshStatus with OpenAPI Connection`);
|
|
289
|
+
if (this.deviceDebug) {
|
|
290
|
+
this.platform.log.error(`Contact Sensor: ${this.accessory.displayName} failed refreshStatus with OpenAPI Connection,`
|
|
291
|
+
+ ` Error Message: ${JSON.stringify(e.message)}`);
|
|
292
|
+
}
|
|
293
|
+
if (this.debugDebug) {
|
|
294
|
+
this.platform.log.error(`Contact Sensor: ${this.accessory.displayName} failed refreshStatus with OpenAPI Connection,`
|
|
295
|
+
+ ` Error: ${JSON.stringify(e)}`);
|
|
296
|
+
}
|
|
279
297
|
this.apiError(e);
|
|
280
298
|
}
|
|
281
299
|
}
|
package/src/devices/curtains.ts
CHANGED
|
@@ -25,9 +25,6 @@ export class Curtain {
|
|
|
25
25
|
setNewTargetTimer!: NodeJS.Timeout;
|
|
26
26
|
|
|
27
27
|
// BLE Others
|
|
28
|
-
set_minLux!: number;
|
|
29
|
-
set_maxLux!: number;
|
|
30
|
-
spaceBetweenLevels!: number;
|
|
31
28
|
switchbot!: switchbot;
|
|
32
29
|
serviceData!: serviceData;
|
|
33
30
|
calibration: serviceData['calibration'];
|
|
@@ -38,6 +35,11 @@ export class Curtain {
|
|
|
38
35
|
// Config
|
|
39
36
|
set_minStep!: number;
|
|
40
37
|
refreshRate!: number;
|
|
38
|
+
set_minLux!: number;
|
|
39
|
+
set_maxLux!: number;
|
|
40
|
+
spaceBetweenLevels!: number;
|
|
41
|
+
private readonly deviceDebug = this.platform.config.options?.debug === 'device' || this.platform.debugMode;
|
|
42
|
+
private readonly debugDebug = this.platform.config.options?.debug === 'debug' || this.platform.debugMode;
|
|
41
43
|
|
|
42
44
|
// Updates
|
|
43
45
|
curtainUpdateInProgress!: boolean;
|
|
@@ -168,9 +170,15 @@ export class Curtain {
|
|
|
168
170
|
try {
|
|
169
171
|
await this.pushChanges();
|
|
170
172
|
} catch (e: any) {
|
|
171
|
-
this.platform.log.error(`Curtain: ${this.accessory.displayName} failed
|
|
172
|
-
|
|
173
|
-
|
|
173
|
+
this.platform.log.error(`Curtain: ${this.accessory.displayName} failed pushChanges`);
|
|
174
|
+
if (this.deviceDebug) {
|
|
175
|
+
this.platform.log.error(`Curtain: ${this.accessory.displayName} failed pushChanges,`
|
|
176
|
+
+ ` Error Message: ${JSON.stringify(e.message)}`);
|
|
177
|
+
}
|
|
178
|
+
if (this.debugDebug) {
|
|
179
|
+
this.platform.log.error(`Curtain: ${this.accessory.displayName} failed pushChanges,`
|
|
180
|
+
+ ` Error: ${JSON.stringify(e)}`);
|
|
181
|
+
}
|
|
174
182
|
this.apiError(e);
|
|
175
183
|
}
|
|
176
184
|
this.curtainUpdateInProgress = false;
|
|
@@ -237,6 +245,7 @@ export class Curtain {
|
|
|
237
245
|
|
|
238
246
|
private async BLEparseStatus() {
|
|
239
247
|
this.platform.debug(`Curtain: ${this.accessory.displayName} BLE parseStatus`);
|
|
248
|
+
this.setMinMax();
|
|
240
249
|
this.CurrentPosition = 100 - Number(this.position);
|
|
241
250
|
this.platform.debug(`Curtain: ${this.accessory.displayName} CurrentPosition ${this.CurrentPosition}`);
|
|
242
251
|
if (this.setNewTarget) {
|
|
@@ -332,6 +341,7 @@ export class Curtain {
|
|
|
332
341
|
if (this.platform.config.credentials?.openToken) {
|
|
333
342
|
this.platform.debug(`Curtain: ${this.accessory.displayName} OpenAPI parseStatus`);
|
|
334
343
|
// CurrentPosition
|
|
344
|
+
this.setMinMax();
|
|
335
345
|
this.CurrentPosition = 100 - this.deviceStatus.body.slidePosition!;
|
|
336
346
|
this.platform.debug(`Curtain ${this.accessory.displayName} CurrentPosition: ${this.CurrentPosition}`);
|
|
337
347
|
if (this.setNewTarget) {
|
|
@@ -412,7 +422,15 @@ export class Curtain {
|
|
|
412
422
|
this.parseStatus();
|
|
413
423
|
this.updateHomeKitCharacteristics();
|
|
414
424
|
}).catch(async (e: any) => {
|
|
415
|
-
this.platform.log.error(`Curtain: ${this.accessory.displayName}
|
|
425
|
+
this.platform.log.error(`Curtain: ${this.accessory.displayName} failed refreshStatus with BLE Connection`);
|
|
426
|
+
if (this.deviceDebug) {
|
|
427
|
+
this.platform.log.error(`Curtain: ${this.accessory.displayName} failed refreshStatus with BLE Connection,`
|
|
428
|
+
+ ` Error Message: ${JSON.stringify(e.message)}`);
|
|
429
|
+
}
|
|
430
|
+
if (this.debugDebug) {
|
|
431
|
+
this.platform.log.error(`Curtain: ${this.accessory.displayName} failed refreshStatus with BLE Connection,`
|
|
432
|
+
+ ` Error: ${JSON.stringify(e)}`);
|
|
433
|
+
}
|
|
416
434
|
if (this.platform.config.credentials?.openToken) {
|
|
417
435
|
this.platform.log.warn(`Curtain: ${this.accessory.displayName} Using OpenAPI Connection`);
|
|
418
436
|
await this.openAPIRefreshStatus();
|
|
@@ -429,8 +447,15 @@ export class Curtain {
|
|
|
429
447
|
this.parseStatus();
|
|
430
448
|
this.updateHomeKitCharacteristics();
|
|
431
449
|
} catch (e: any) {
|
|
432
|
-
this.platform.log.error(`Curtain: ${this.accessory.displayName} failed
|
|
433
|
-
|
|
450
|
+
this.platform.log.error(`Curtain: ${this.accessory.displayName} failed refreshStatus with OpenAPI Connection`);
|
|
451
|
+
if (this.deviceDebug) {
|
|
452
|
+
this.platform.log.error(`Curtain: ${this.accessory.displayName} failed refreshStatus with OpenAPI Connection,`
|
|
453
|
+
+ ` Error Message: ${JSON.stringify(e.message)}`);
|
|
454
|
+
}
|
|
455
|
+
if (this.debugDebug) {
|
|
456
|
+
this.platform.log.error(`Curtain: ${this.accessory.displayName} failed refreshStatus with OpenAPI Connection,`
|
|
457
|
+
+ ` Error: ${JSON.stringify(e)}`);
|
|
458
|
+
}
|
|
434
459
|
this.apiError(e);
|
|
435
460
|
}
|
|
436
461
|
}
|
|
@@ -454,31 +479,53 @@ export class Curtain {
|
|
|
454
479
|
}).then(() => {
|
|
455
480
|
this.platform.device(`Curtain: ${this.accessory.displayName} Done.`);
|
|
456
481
|
}).catch(async (e: any) => {
|
|
457
|
-
this.platform.log.error(`Curtain: ${this.accessory.displayName}
|
|
458
|
-
this.
|
|
459
|
-
|
|
482
|
+
this.platform.log.error(`Curtain: ${this.accessory.displayName} failed pushChanges with BLE Connection`);
|
|
483
|
+
if (this.deviceDebug) {
|
|
484
|
+
this.platform.log.error(`Curtain: ${this.accessory.displayName} failed pushChanges with BLE Connection,`
|
|
485
|
+
+ ` Error Message: ${JSON.stringify(e.message)}`);
|
|
486
|
+
}
|
|
487
|
+
if (this.debugDebug) {
|
|
488
|
+
this.platform.log.error(`Curtain: ${this.accessory.displayName} failed pushChanges with BLE Connection,`
|
|
489
|
+
+ ` Error: ${JSON.stringify(e)}`);
|
|
490
|
+
}
|
|
491
|
+
if (this.platform.config.credentials?.openToken) {
|
|
492
|
+
this.platform.log.warn(`Curtain: ${this.accessory.displayName} Using OpenAPI Connection`);
|
|
493
|
+
await this.OpenAPIpushChanges();
|
|
494
|
+
}
|
|
460
495
|
});
|
|
461
496
|
}
|
|
462
497
|
|
|
463
498
|
private async OpenAPIpushChanges() {
|
|
464
499
|
if (this.platform.config.credentials?.openToken) {
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
this.
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
500
|
+
try {
|
|
501
|
+
this.platform.debug(`Curtain: ${this.accessory.displayName} OpenAPI pushChanges`);
|
|
502
|
+
if (this.TargetPosition !== this.CurrentPosition) {
|
|
503
|
+
this.platform.debug(`Pushing ${this.TargetPosition}`);
|
|
504
|
+
const adjustedTargetPosition = 100 - Number(this.TargetPosition);
|
|
505
|
+
const payload = {
|
|
506
|
+
commandType: 'command',
|
|
507
|
+
command: 'setPosition',
|
|
508
|
+
parameter: `0,ff,${adjustedTargetPosition}`,
|
|
509
|
+
} as payload;
|
|
510
|
+
|
|
511
|
+
this.platform.log.info(`Curtain: ${this.accessory.displayName} Sending request to SwitchBot API. command: ${payload.command},`
|
|
512
|
+
+ ` parameter: ${payload.parameter}, commandType: ${payload.commandType}`);
|
|
513
|
+
|
|
514
|
+
// Make the API request
|
|
515
|
+
const push: any = (await this.platform.axios.post(`${DeviceURL}/${this.device.deviceId!}/commands`, payload));
|
|
516
|
+
this.platform.debug(`Curtain: ${this.accessory.displayName} pushchanges: ${JSON.stringify(push.data)}`);
|
|
517
|
+
this.statusCode(push);
|
|
518
|
+
}
|
|
519
|
+
} catch (e: any) {
|
|
520
|
+
this.platform.log.error(`Curtain: ${this.accessory.displayName} failed pushChanges with OpenAPI Connection`);
|
|
521
|
+
if (this.deviceDebug) {
|
|
522
|
+
this.platform.log.error(`Curtain: ${this.accessory.displayName} failed pushChanges with OpenAPI Connection,`
|
|
523
|
+
+ ` Error Message: ${JSON.stringify(e.message)}`);
|
|
524
|
+
}
|
|
525
|
+
if (this.debugDebug) {
|
|
526
|
+
this.platform.log.error(`Curtain: ${this.accessory.displayName} failed pushChanges with OpenAPI Connection,`
|
|
527
|
+
+ ` Error: ${JSON.stringify(e)}`);
|
|
528
|
+
}
|
|
482
529
|
}
|
|
483
530
|
}
|
|
484
531
|
}
|
|
@@ -558,8 +605,8 @@ export class Curtain {
|
|
|
558
605
|
this.platform.log.error(`Curtain: ${this.accessory.displayName} Hub Device is offline.`);
|
|
559
606
|
break;
|
|
560
607
|
case 190:
|
|
561
|
-
|
|
562
|
-
|
|
608
|
+
this.platform.log.error(`Curtain: ${this.accessory.displayName} Device internal error due to device states not synchronized with server,`
|
|
609
|
+
+ ` Or command: ${JSON.stringify(push.data)} format is invalid`);
|
|
563
610
|
break;
|
|
564
611
|
case 100:
|
|
565
612
|
this.platform.debug(`Curtain: ${this.accessory.displayName} Command successfully sent.`);
|
|
@@ -611,11 +658,13 @@ export class Curtain {
|
|
|
611
658
|
if (this.device.curtain?.set_min) {
|
|
612
659
|
if (this.CurrentPosition <= this.device.curtain?.set_min) {
|
|
613
660
|
this.CurrentPosition = 0;
|
|
661
|
+
this.PositionState = this.platform.Characteristic.PositionState.STOPPED;
|
|
614
662
|
}
|
|
615
663
|
}
|
|
616
664
|
if (this.device.curtain?.set_max) {
|
|
617
665
|
if (this.CurrentPosition >= this.device.curtain?.set_max) {
|
|
618
666
|
this.CurrentPosition = 100;
|
|
667
|
+
this.PositionState = this.platform.Characteristic.PositionState.STOPPED;
|
|
619
668
|
}
|
|
620
669
|
}
|
|
621
670
|
}
|
|
@@ -35,6 +35,8 @@ export class Humidifier {
|
|
|
35
35
|
|
|
36
36
|
// Config
|
|
37
37
|
set_minStep?: number;
|
|
38
|
+
private readonly deviceDebug = this.platform.config.options?.debug === 'device' || this.platform.debugMode;
|
|
39
|
+
private readonly debugDebug = this.platform.config.options?.debug === 'debug' || this.platform.debugMode;
|
|
38
40
|
|
|
39
41
|
// Updates
|
|
40
42
|
humidifierUpdateInProgress!: boolean;
|
|
@@ -171,9 +173,15 @@ export class Humidifier {
|
|
|
171
173
|
try {
|
|
172
174
|
await this.pushChanges();
|
|
173
175
|
} catch (e: any) {
|
|
174
|
-
this.platform.log.error(`Humidifier: ${this.accessory.displayName} failed
|
|
175
|
-
|
|
176
|
-
|
|
176
|
+
this.platform.log.error(`Humidifier: ${this.accessory.displayName} failed pushChanges`);
|
|
177
|
+
if (this.deviceDebug) {
|
|
178
|
+
this.platform.log.error(`Humidifier: ${this.accessory.displayName} failed pushChanges,`
|
|
179
|
+
+ ` Error Message: ${JSON.stringify(e.message)}`);
|
|
180
|
+
}
|
|
181
|
+
if (this.debugDebug) {
|
|
182
|
+
this.platform.log.error(`Humidifier: ${this.accessory.displayName} failed pushChanges,`
|
|
183
|
+
+ ` Error: ${JSON.stringify(e)}`);
|
|
184
|
+
}
|
|
177
185
|
this.apiError(e);
|
|
178
186
|
}
|
|
179
187
|
this.humidifierUpdateInProgress = false;
|
|
@@ -319,7 +327,15 @@ export class Humidifier {
|
|
|
319
327
|
this.parseStatus();
|
|
320
328
|
this.updateHomeKitCharacteristics();
|
|
321
329
|
}).catch(async (e: any) => {
|
|
322
|
-
this.platform.log.error(`Humidifier: ${this.accessory.displayName}
|
|
330
|
+
this.platform.log.error(`Humidifier: ${this.accessory.displayName} failed refreshStatus with BLE Connection`);
|
|
331
|
+
if (this.deviceDebug) {
|
|
332
|
+
this.platform.log.error(`Humidifier: ${this.accessory.displayName} failed refreshStatus with BLE Connection,`
|
|
333
|
+
+ ` Error Message: ${JSON.stringify(e.message)}`);
|
|
334
|
+
}
|
|
335
|
+
if (this.debugDebug) {
|
|
336
|
+
this.platform.log.error(`Humidifier: ${this.accessory.displayName} failed refreshStatus with BLE Connection,`
|
|
337
|
+
+ ` Error: ${JSON.stringify(e)}`);
|
|
338
|
+
}
|
|
323
339
|
if (this.platform.config.credentials?.openToken) {
|
|
324
340
|
this.platform.log.warn(`Humidifier: ${this.accessory.displayName} Using OpenAPI Connection`);
|
|
325
341
|
await this.openAPIRefreshStatus();
|
|
@@ -340,8 +356,15 @@ export class Humidifier {
|
|
|
340
356
|
this.platform.debug(this.deviceStatus);
|
|
341
357
|
}
|
|
342
358
|
} catch (e: any) {
|
|
343
|
-
this.platform.log.error(`Humidifier: ${this.accessory.displayName}
|
|
344
|
-
|
|
359
|
+
this.platform.log.error(`Humidifier: ${this.accessory.displayName} failed refreshStatus with OpenAPI Connection`);
|
|
360
|
+
if (this.deviceDebug) {
|
|
361
|
+
this.platform.log.error(`Humidifier: ${this.accessory.displayName} failed refreshStatus with OpenAPI Connection,`
|
|
362
|
+
+ ` Error Message: ${JSON.stringify(e.message)}`);
|
|
363
|
+
}
|
|
364
|
+
if (this.debugDebug) {
|
|
365
|
+
this.platform.log.error(`Humidifier: ${this.accessory.displayName} failed refreshStatus with OpenAPI Connection,`
|
|
366
|
+
+ ` Error: ${JSON.stringify(e)}`);
|
|
367
|
+
}
|
|
345
368
|
this.apiError(e);
|
|
346
369
|
}
|
|
347
370
|
}
|
|
@@ -368,7 +391,15 @@ export class Humidifier {
|
|
|
368
391
|
}).then(() => {
|
|
369
392
|
this.platform.device(`Humidifier: ${this.accessory.displayName} Done.`);
|
|
370
393
|
}).catch(async (e: any) => {
|
|
371
|
-
this.platform.log.error(`Humidifier: ${this.accessory.displayName}
|
|
394
|
+
this.platform.log.error(`Humidifier: ${this.accessory.displayName} failed pushChanges with BLE Connection`);
|
|
395
|
+
if (this.deviceDebug) {
|
|
396
|
+
this.platform.log.error(`Humidifier: ${this.accessory.displayName} failed pushChanges with BLE Connection,`
|
|
397
|
+
+ ` Error Message: ${JSON.stringify(e.message)}`);
|
|
398
|
+
}
|
|
399
|
+
if (this.debugDebug) {
|
|
400
|
+
this.platform.log.error(`Humidifier: ${this.accessory.displayName} failed pushChanges with BLE Connection,`
|
|
401
|
+
+ ` Error: ${JSON.stringify(e)}`);
|
|
402
|
+
}
|
|
372
403
|
if (this.platform.config.credentials?.openToken) {
|
|
373
404
|
this.platform.log.warn(`Humidifier: ${this.accessory.displayName} Using OpenAPI Connection`);
|
|
374
405
|
await this.OpenAPIpushChanges();
|
|
@@ -384,20 +415,33 @@ export class Humidifier {
|
|
|
384
415
|
this.platform.Characteristic.TargetHumidifierDehumidifierState.HUMIDIFIER &&
|
|
385
416
|
this.Active === this.platform.Characteristic.Active.ACTIVE
|
|
386
417
|
) {
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
418
|
+
try {
|
|
419
|
+
this.platform.debug(`Pushing Manual: ${this.RelativeHumidityHumidifierThreshold}!`);
|
|
420
|
+
const payload = {
|
|
421
|
+
commandType: 'command',
|
|
422
|
+
command: 'setMode',
|
|
423
|
+
parameter: `${this.RelativeHumidityHumidifierThreshold}`,
|
|
424
|
+
} as payload;
|
|
425
|
+
|
|
426
|
+
this.platform.log.info(`Humidifier: ${this.accessory.displayName} Sending request to SwitchBot API. command: ${payload.command},`
|
|
427
|
+
+ ` parameter: ${payload.parameter}, commandType: ${payload.commandType}`);
|
|
428
|
+
|
|
429
|
+
// Make the API request
|
|
430
|
+
const push: any = (await this.platform.axios.post(`${DeviceURL}/${this.device.deviceId}/commands`, payload));
|
|
431
|
+
this.platform.debug(`Humidifier: ${this.accessory.displayName} pushChanges: ${JSON.stringify(push.data)}`);
|
|
432
|
+
this.statusCode(push);
|
|
433
|
+
} catch (e: any) {
|
|
434
|
+
this.platform.log.error(`Humidifier: ${this.accessory.displayName} failed pushChanges with OpenAPI Connection`);
|
|
435
|
+
if (this.deviceDebug) {
|
|
436
|
+
this.platform.log.error(`Humidifier: ${this.accessory.displayName} failed pushChanges with OpenAPI Connection,`
|
|
437
|
+
+ ` Error Message: ${JSON.stringify(e.message)}`);
|
|
438
|
+
}
|
|
439
|
+
if (this.debugDebug) {
|
|
440
|
+
this.platform.log.error(`Humidifier: ${this.accessory.displayName} failed pushChanges with OpenAPI Connection,`
|
|
441
|
+
+ ` Error: ${JSON.stringify(e)}`);
|
|
442
|
+
}
|
|
443
|
+
this.apiError(e);
|
|
444
|
+
}
|
|
401
445
|
} else if (
|
|
402
446
|
this.TargetHumidifierDehumidifierState ===
|
|
403
447
|
this.platform.Characteristic.TargetHumidifierDehumidifierState.HUMIDIFIER_OR_DEHUMIDIFIER &&
|
|
@@ -436,9 +480,15 @@ export class Humidifier {
|
|
|
436
480
|
this.statusCode(push);
|
|
437
481
|
}
|
|
438
482
|
} catch (e: any) {
|
|
439
|
-
this.platform.log.error(`Humidifier: ${this.accessory.displayName} failed
|
|
440
|
-
|
|
441
|
-
|
|
483
|
+
this.platform.log.error(`Humidifier: ${this.accessory.displayName} failed pushAutoChanges with OpenAPI Connection`);
|
|
484
|
+
if (this.deviceDebug) {
|
|
485
|
+
this.platform.log.error(`Humidifier: ${this.accessory.displayName} failed pushAutoChanges with OpenAPI Connection,`
|
|
486
|
+
+ ` Error Message: ${JSON.stringify(e.message)}`);
|
|
487
|
+
}
|
|
488
|
+
if (this.debugDebug) {
|
|
489
|
+
this.platform.log.error(`Humidifier: ${this.accessory.displayName} failed pushAutoChanges with OpenAPI Connection,`
|
|
490
|
+
+ ` Error: ${JSON.stringify(e)}`);
|
|
491
|
+
}
|
|
442
492
|
this.apiError(e);
|
|
443
493
|
}
|
|
444
494
|
}
|
|
@@ -465,9 +515,15 @@ export class Humidifier {
|
|
|
465
515
|
this.statusCode(push);
|
|
466
516
|
}
|
|
467
517
|
} catch (e: any) {
|
|
468
|
-
this.platform.log.error(`Humidifier: ${this.accessory.displayName} failed
|
|
469
|
-
|
|
470
|
-
|
|
518
|
+
this.platform.log.error(`Humidifier: ${this.accessory.displayName} failed pushActiveChanges with OpenAPI Connection`);
|
|
519
|
+
if (this.deviceDebug) {
|
|
520
|
+
this.platform.log.error(`Humidifier: ${this.accessory.displayName} failed pushActiveChanges with OpenAPI Connection,`
|
|
521
|
+
+ ` Error Message: ${JSON.stringify(e.message)}`);
|
|
522
|
+
}
|
|
523
|
+
if (this.debugDebug) {
|
|
524
|
+
this.platform.log.error(`Humidifier: ${this.accessory.displayName} failed pushActiveChanges with OpenAPI Connection,`
|
|
525
|
+
+ ` Error: ${JSON.stringify(e)}`);
|
|
526
|
+
}
|
|
471
527
|
this.apiError(e);
|
|
472
528
|
}
|
|
473
529
|
}
|
|
@@ -561,8 +617,8 @@ export class Humidifier {
|
|
|
561
617
|
this.platform.log.error(`Humidifier: ${this.accessory.displayName} Hub Device is offline.`);
|
|
562
618
|
break;
|
|
563
619
|
case 190:
|
|
564
|
-
|
|
565
|
-
|
|
620
|
+
this.platform.log.error(`Humidifier: ${this.accessory.displayName} Device internal error due to device states not synchronized with server,`
|
|
621
|
+
+ ` Or command: ${JSON.stringify(push.data)} format is invalid`);
|
|
566
622
|
break;
|
|
567
623
|
case 100:
|
|
568
624
|
this.platform.debug(`Humidifier: ${this.accessory.displayName} Command successfully sent.`);
|
package/src/devices/indoorcam.ts
CHANGED
|
@@ -16,6 +16,10 @@ export class IndoorCam {
|
|
|
16
16
|
// OpenAPI Others
|
|
17
17
|
deviceStatus!: deviceStatusResponse;
|
|
18
18
|
|
|
19
|
+
// Config
|
|
20
|
+
private readonly deviceDebug = this.platform.config.options?.debug === 'device' || this.platform.debugMode;
|
|
21
|
+
private readonly debugDebug = this.platform.config.options?.debug === 'debug' || this.platform.debugMode;
|
|
22
|
+
|
|
19
23
|
// Updates
|
|
20
24
|
cameraUpdateInProgress!: boolean;
|
|
21
25
|
doCameraUpdate!: Subject<void>;
|
|
@@ -88,9 +92,15 @@ export class IndoorCam {
|
|
|
88
92
|
try {
|
|
89
93
|
await this.pushChanges();
|
|
90
94
|
} catch (e: any) {
|
|
91
|
-
this.platform.log.error(`Indoor Cam: ${this.accessory.displayName} failed
|
|
92
|
-
|
|
93
|
-
|
|
95
|
+
this.platform.log.error(`Indoor Cam: ${this.accessory.displayName} failed pushChanges`);
|
|
96
|
+
if (this.deviceDebug) {
|
|
97
|
+
this.platform.log.error(`Indoor Cam: ${this.accessory.displayName} failed pushChanges,`
|
|
98
|
+
+ ` Error Message: ${JSON.stringify(e.message)}`);
|
|
99
|
+
}
|
|
100
|
+
if (this.debugDebug) {
|
|
101
|
+
this.platform.log.error(`Indoor Cam: ${this.accessory.displayName} failed pushChanges,`
|
|
102
|
+
+ ` Error: ${JSON.stringify(e)}`);
|
|
103
|
+
}
|
|
94
104
|
this.apiError(e);
|
|
95
105
|
}
|
|
96
106
|
this.cameraUpdateInProgress = false;
|
|
@@ -116,8 +126,15 @@ export class IndoorCam {
|
|
|
116
126
|
this.parseStatus();
|
|
117
127
|
this.updateHomeKitCharacteristics();
|
|
118
128
|
} catch (e: any) {
|
|
119
|
-
this.platform.log.error(`Indoor Cam: ${this.accessory.displayName} failed
|
|
120
|
-
|
|
129
|
+
this.platform.log.error(`Indoor Cam: ${this.accessory.displayName} failed refreshStatus with BLE Connection`);
|
|
130
|
+
if (this.deviceDebug) {
|
|
131
|
+
this.platform.log.error(`Indoor Cam: ${this.accessory.displayName} failed refreshStatus with BLE Connection,`
|
|
132
|
+
+ ` Error Message: ${JSON.stringify(e.message)}`);
|
|
133
|
+
}
|
|
134
|
+
if (this.debugDebug) {
|
|
135
|
+
this.platform.log.error(`Indoor Cam: ${this.accessory.displayName} failed refreshStatus with BLE Connection,`
|
|
136
|
+
+ ` Error: ${JSON.stringify(e)}`);
|
|
137
|
+
}
|
|
121
138
|
this.apiError(e);
|
|
122
139
|
}
|
|
123
140
|
}
|
|
@@ -188,8 +205,8 @@ export class IndoorCam {
|
|
|
188
205
|
this.platform.log.error(`Indoor Cam: ${this.accessory.displayName} Hub Device is offline.`);
|
|
189
206
|
break;
|
|
190
207
|
case 190:
|
|
191
|
-
|
|
192
|
-
|
|
208
|
+
this.platform.log.error(`Indoor Cam: ${this.accessory.displayName} Device internal error due to device states not synchronized with server,`
|
|
209
|
+
+ ` Or command: ${JSON.stringify(push.data)} format is invalid`);
|
|
193
210
|
break;
|
|
194
211
|
case 100:
|
|
195
212
|
this.platform.debug(`Indoor Cam: ${this.accessory.displayName} Command successfully sent.`);
|
package/src/devices/meters.ts
CHANGED
|
@@ -35,6 +35,10 @@ export class Meter {
|
|
|
35
35
|
fahrenheit!: serviceData['fahrenheit'];
|
|
36
36
|
temperature!: serviceData['temperature'];
|
|
37
37
|
|
|
38
|
+
// Config
|
|
39
|
+
private readonly deviceDebug = this.platform.config.options?.debug === 'device' || this.platform.debugMode;
|
|
40
|
+
private readonly debugDebug = this.platform.config.options?.debug === 'debug' || this.platform.debugMode;
|
|
41
|
+
|
|
38
42
|
// Updates
|
|
39
43
|
meterUpdateInProgress!: boolean;
|
|
40
44
|
doMeterUpdate: Subject<void>;
|
|
@@ -274,7 +278,15 @@ export class Meter {
|
|
|
274
278
|
this.parseStatus();
|
|
275
279
|
this.updateHomeKitCharacteristics();
|
|
276
280
|
}).catch(async (e: any) => {
|
|
277
|
-
this.platform.log.error(`Meter: ${this.accessory.displayName}
|
|
281
|
+
this.platform.log.error(`Meter: ${this.accessory.displayName} failed refreshStatus with BLE Connection`);
|
|
282
|
+
if (this.deviceDebug) {
|
|
283
|
+
this.platform.log.error(`Meter: ${this.accessory.displayName} failed refreshStatus with BLE Connection,`
|
|
284
|
+
+ ` Error Message: ${JSON.stringify(e.message)}`);
|
|
285
|
+
}
|
|
286
|
+
if (this.debugDebug) {
|
|
287
|
+
this.platform.log.error(`Meter: ${this.accessory.displayName} failed refreshStatus with BLE Connection,`
|
|
288
|
+
+ ` Error: ${JSON.stringify(e)}`);
|
|
289
|
+
}
|
|
278
290
|
if (this.platform.config.credentials?.openToken) {
|
|
279
291
|
this.platform.log.warn(`Meter: ${this.accessory.displayName} Using OpenAPI Connection`);
|
|
280
292
|
await this.openAPIRefreshStatus();
|
|
@@ -291,8 +303,15 @@ export class Meter {
|
|
|
291
303
|
this.parseStatus();
|
|
292
304
|
this.updateHomeKitCharacteristics();
|
|
293
305
|
} catch (e: any) {
|
|
294
|
-
this.platform.log.error(`Meter: ${this.accessory.displayName} failed
|
|
295
|
-
|
|
306
|
+
this.platform.log.error(`Meter: ${this.accessory.displayName} failed refreshStatus with OpenAPI Connection`);
|
|
307
|
+
if (this.deviceDebug) {
|
|
308
|
+
this.platform.log.error(`Meter: ${this.accessory.displayName} failed refreshStatus with OpenAPI Connection,`
|
|
309
|
+
+ ` Error Message: ${JSON.stringify(e.message)}`);
|
|
310
|
+
}
|
|
311
|
+
if (this.debugDebug) {
|
|
312
|
+
this.platform.log.error(`Meter: ${this.accessory.displayName} failed refreshStatus with OpenAPI Connection,`
|
|
313
|
+
+ ` Error: ${JSON.stringify(e)}`);
|
|
314
|
+
}
|
|
296
315
|
this.apiError(e);
|
|
297
316
|
}
|
|
298
317
|
}
|
package/src/devices/motion.ts
CHANGED
|
@@ -31,6 +31,10 @@ export class Motion {
|
|
|
31
31
|
movement!: serviceData['movement'];
|
|
32
32
|
lightLevel!: serviceData['lightLevel'];
|
|
33
33
|
|
|
34
|
+
// Config
|
|
35
|
+
private readonly deviceDebug = this.platform.config.options?.debug === 'device' || this.platform.debugMode;
|
|
36
|
+
private readonly debugDebug = this.platform.config.options?.debug === 'debug' || this.platform.debugMode;
|
|
37
|
+
|
|
34
38
|
// Updates
|
|
35
39
|
motionUbpdateInProgress!: boolean;
|
|
36
40
|
doMotionUpdate!: Subject<void>;
|
|
@@ -193,7 +197,15 @@ export class Motion {
|
|
|
193
197
|
this.parseStatus();
|
|
194
198
|
this.updateHomeKitCharacteristics();
|
|
195
199
|
}).catch(async (e: any) => {
|
|
196
|
-
this.platform.log.error(`Motion Sensor: ${this.accessory.displayName} BLE Connection
|
|
200
|
+
this.platform.log.error(`Motion Sensor: ${this.accessory.displayName} failed refreshStatus with BLE Connection`);
|
|
201
|
+
if (this.deviceDebug) {
|
|
202
|
+
this.platform.log.error(`Motion Sensor: ${this.accessory.displayName} failed refreshStatus with BLE Connection,`
|
|
203
|
+
+ ` Error Message: ${JSON.stringify(e.message)}`);
|
|
204
|
+
}
|
|
205
|
+
if (this.debugDebug) {
|
|
206
|
+
this.platform.log.error(`Motion Sensor: ${this.accessory.displayName} failed refreshStatus with BLE Connection,`
|
|
207
|
+
+ ` Error: ${JSON.stringify(e)}`);
|
|
208
|
+
}
|
|
197
209
|
if (this.platform.config.credentials?.openToken) {
|
|
198
210
|
this.platform.log.warn(`Motion Sensor: ${this.accessory.displayName} Using OpenAPI Connection`);
|
|
199
211
|
await this.openAPIRefreshStatus();
|
|
@@ -210,8 +222,15 @@ export class Motion {
|
|
|
210
222
|
this.parseStatus();
|
|
211
223
|
this.updateHomeKitCharacteristics();
|
|
212
224
|
} catch (e: any) {
|
|
213
|
-
this.platform.log.error(`Motion Sensor: ${this.accessory.displayName} failed
|
|
214
|
-
|
|
225
|
+
this.platform.log.error(`Motion Sensor: ${this.accessory.displayName} failed refreshStatus with OpenAPI Connection`);
|
|
226
|
+
if (this.deviceDebug) {
|
|
227
|
+
this.platform.log.error(`Motion Sensor: ${this.accessory.displayName} failed refreshStatus with OpenAPI Connection,`
|
|
228
|
+
+ ` Error Message: ${JSON.stringify(e.message)}`);
|
|
229
|
+
}
|
|
230
|
+
if (this.debugDebug) {
|
|
231
|
+
this.platform.log.error(`Motion Sensor: ${this.accessory.displayName} failed refreshStatus with OpenAPI Connection,`
|
|
232
|
+
+ ` Error: ${JSON.stringify(e)}`);
|
|
233
|
+
}
|
|
215
234
|
this.apiError(e);
|
|
216
235
|
}
|
|
217
236
|
}
|
package/src/devices/plugs.ts
CHANGED
|
@@ -16,6 +16,10 @@ export class Plug {
|
|
|
16
16
|
// OpenAPI Others
|
|
17
17
|
deviceStatus!: deviceStatusResponse;
|
|
18
18
|
|
|
19
|
+
// Config
|
|
20
|
+
private readonly deviceDebug = this.platform.config.options?.debug === 'device' || this.platform.debugMode;
|
|
21
|
+
private readonly debugDebug = this.platform.config.options?.debug === 'debug' || this.platform.debugMode;
|
|
22
|
+
|
|
19
23
|
// Updates
|
|
20
24
|
plugUpdateInProgress!: boolean;
|
|
21
25
|
doPlugUpdate!: Subject<void>;
|
|
@@ -88,9 +92,15 @@ export class Plug {
|
|
|
88
92
|
try {
|
|
89
93
|
await this.pushChanges();
|
|
90
94
|
} catch (e: any) {
|
|
91
|
-
this.platform.log.error(`Plug: ${this.accessory.displayName} failed
|
|
92
|
-
|
|
93
|
-
|
|
95
|
+
this.platform.log.error(`Plug: ${this.accessory.displayName} failed pushChanges`);
|
|
96
|
+
if (this.deviceDebug) {
|
|
97
|
+
this.platform.log.error(`Plug: ${this.accessory.displayName} failed pushChanges,`
|
|
98
|
+
+ ` Error Message: ${JSON.stringify(e.message)}`);
|
|
99
|
+
}
|
|
100
|
+
if (this.debugDebug) {
|
|
101
|
+
this.platform.log.error(`Plug: ${this.accessory.displayName} failed pushChanges,`
|
|
102
|
+
+ ` Error: ${JSON.stringify(e)}`);
|
|
103
|
+
}
|
|
94
104
|
this.apiError(e);
|
|
95
105
|
}
|
|
96
106
|
this.plugUpdateInProgress = false;
|
|
@@ -115,8 +125,15 @@ export class Plug {
|
|
|
115
125
|
this.parseStatus();
|
|
116
126
|
this.updateHomeKitCharacteristics();
|
|
117
127
|
} catch (e: any) {
|
|
118
|
-
this.platform.log.error(`Plug: ${this.accessory.displayName} failed
|
|
119
|
-
|
|
128
|
+
this.platform.log.error(`Plug: ${this.accessory.displayName} failed refreshStatus with OpenAPI Connection`);
|
|
129
|
+
if (this.deviceDebug) {
|
|
130
|
+
this.platform.log.error(`Plug: ${this.accessory.displayName} failed refreshStatus with OpenAPI Connection,`
|
|
131
|
+
+ ` Error Message: ${JSON.stringify(e.message)}`);
|
|
132
|
+
}
|
|
133
|
+
if (this.debugDebug) {
|
|
134
|
+
this.platform.log.error(`Plug: ${this.accessory.displayName} failed refreshStatus with OpenAPI Connection,`
|
|
135
|
+
+ ` Error: ${JSON.stringify(e)}`);
|
|
136
|
+
}
|
|
120
137
|
this.apiError(e);
|
|
121
138
|
}
|
|
122
139
|
}
|
|
@@ -186,8 +203,8 @@ export class Plug {
|
|
|
186
203
|
this.platform.log.error(`Plug: ${this.accessory.displayName} Hub Device is offline.`);
|
|
187
204
|
break;
|
|
188
205
|
case 190:
|
|
189
|
-
|
|
190
|
-
|
|
206
|
+
this.platform.log.error(`Plug: ${this.accessory.displayName} Device internal error due to device states not synchronized with server,`
|
|
207
|
+
+ ` Or command: ${JSON.stringify(push.data)} format is invalid`);
|
|
191
208
|
break;
|
|
192
209
|
case 100:
|
|
193
210
|
this.platform.debug(`Plug: ${this.accessory.displayName} Command successfully sent.`);
|