@switchbot/homebridge-switchbot 1.1.1-beta.8 → 1.2.1-beta.1
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 +12 -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 +91 -39
- 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 +7 -5
- package/dist/devices/curtains.d.ts.map +1 -1
- package/dist/devices/curtains.js +82 -32
- 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 +7 -7
- package/src/devices/bots.ts +92 -40
- package/src/devices/colorbulb.ts +218 -33
- package/src/devices/contact.ts +23 -5
- package/src/devices/curtains.ts +90 -39
- 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
|
@@ -35,6 +35,10 @@ export class AirConditioner {
|
|
|
35
35
|
static MODE_COOL: number;
|
|
36
36
|
static MODE_HEAT: number;
|
|
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
|
constructor(
|
|
39
43
|
private readonly platform: SwitchBotPlatform,
|
|
40
44
|
private accessory: PlatformAccessory,
|
|
@@ -338,9 +342,15 @@ export class AirConditioner {
|
|
|
338
342
|
this.statusCode(push);
|
|
339
343
|
this.updateHomeKitCharacteristics();
|
|
340
344
|
} catch (e: any) {
|
|
341
|
-
this.platform.log.error(`Air Conditioner: ${this.accessory.displayName}
|
|
342
|
-
|
|
343
|
-
|
|
345
|
+
this.platform.log.error(`Air Conditioner: ${this.accessory.displayName} failed pushChanges`);
|
|
346
|
+
if (this.deviceDebug) {
|
|
347
|
+
this.platform.log.error(`Air Conditioner: ${this.accessory.displayName} failed pushChanges,`
|
|
348
|
+
+ ` Error Message: ${JSON.stringify(e.message)}`);
|
|
349
|
+
}
|
|
350
|
+
if (this.debugDebug) {
|
|
351
|
+
this.platform.log.error(`Air Conditioner: ${this.accessory.displayName} failed pushChanges,`
|
|
352
|
+
+ ` Error: ${JSON.stringify(e)}`);
|
|
353
|
+
}
|
|
344
354
|
this.apiError(e);
|
|
345
355
|
}
|
|
346
356
|
}
|
|
@@ -363,8 +373,8 @@ export class AirConditioner {
|
|
|
363
373
|
this.platform.log.error(`Air Conditioner: ${this.accessory.displayName} Hub Device is offline.`);
|
|
364
374
|
break;
|
|
365
375
|
case 190:
|
|
366
|
-
|
|
367
|
-
|
|
376
|
+
this.platform.log.error(`Air Conditioner: ${this.accessory.displayName} Device internal error due to device states not synchronized with server,`
|
|
377
|
+
+ ` Or command: ${JSON.stringify(push.data)} format is invalid`);
|
|
368
378
|
break;
|
|
369
379
|
case 100:
|
|
370
380
|
this.platform.debug(`Air Conditioner: ${this.accessory.displayName} Command successfully sent.`);
|
|
@@ -33,6 +33,10 @@ export class AirPurifier {
|
|
|
33
33
|
CurrentFanSpeed!: number;
|
|
34
34
|
static PURIFYING_AIR: number;
|
|
35
35
|
|
|
36
|
+
// Config
|
|
37
|
+
private readonly deviceDebug = this.platform.config.options?.debug === 'device' || this.platform.debugMode;
|
|
38
|
+
private readonly debugDebug = this.platform.config.options?.debug === 'debug' || this.platform.debugMode;
|
|
39
|
+
|
|
36
40
|
constructor(
|
|
37
41
|
private readonly platform: SwitchBotPlatform,
|
|
38
42
|
private accessory: PlatformAccessory,
|
|
@@ -207,9 +211,15 @@ export class AirPurifier {
|
|
|
207
211
|
this.statusCode(push);
|
|
208
212
|
this.updateHomeKitCharacteristics();
|
|
209
213
|
} catch (e: any) {
|
|
210
|
-
this.platform.log.error(`Air Purifier: ${this.accessory.displayName}
|
|
211
|
-
|
|
212
|
-
|
|
214
|
+
this.platform.log.error(`Air Purifier: ${this.accessory.displayName} failed pushChanges with OpenAPI Connection`);
|
|
215
|
+
if (this.deviceDebug) {
|
|
216
|
+
this.platform.log.error(`Air Purifier: ${this.accessory.displayName} failed pushChanges with OpenAPI Connection,`
|
|
217
|
+
+ ` Error Message: ${JSON.stringify(e.message)}`);
|
|
218
|
+
}
|
|
219
|
+
if (this.debugDebug) {
|
|
220
|
+
this.platform.log.error(`Air Purifier: ${this.accessory.displayName} failed pushChanges with OpenAPI Connection,`
|
|
221
|
+
+ ` Error: ${JSON.stringify(e)}`);
|
|
222
|
+
}
|
|
213
223
|
this.apiError(e);
|
|
214
224
|
}
|
|
215
225
|
}
|
|
@@ -232,8 +242,8 @@ export class AirPurifier {
|
|
|
232
242
|
this.platform.log.error(`Air Purifier: ${this.accessory.displayName} Hub Device is offline.`);
|
|
233
243
|
break;
|
|
234
244
|
case 190:
|
|
235
|
-
|
|
236
|
-
|
|
245
|
+
this.platform.log.error(`Air Purifier: ${this.accessory.displayName} Device internal error due to device states not synchronized with server,`
|
|
246
|
+
+ ` Or command: ${JSON.stringify(push.data)} format is invalid`);
|
|
237
247
|
break;
|
|
238
248
|
case 100:
|
|
239
249
|
this.platform.debug(`Air Purifier: ${this.accessory.displayName} Command successfully sent.`);
|
package/src/irdevices/cameras.ts
CHANGED
|
@@ -15,6 +15,10 @@ export class Camera {
|
|
|
15
15
|
// Characteristic Values
|
|
16
16
|
On!: CharacteristicValue;
|
|
17
17
|
|
|
18
|
+
// Config
|
|
19
|
+
private readonly deviceDebug = this.platform.config.options?.debug === 'device' || this.platform.debugMode;
|
|
20
|
+
private readonly debugDebug = this.platform.config.options?.debug === 'debug' || this.platform.debugMode;
|
|
21
|
+
|
|
18
22
|
constructor(
|
|
19
23
|
private readonly platform: SwitchBotPlatform,
|
|
20
24
|
private accessory: PlatformAccessory,
|
|
@@ -107,9 +111,15 @@ export class Camera {
|
|
|
107
111
|
this.statusCode(push);
|
|
108
112
|
this.updateHomeKitCharacteristics();
|
|
109
113
|
} catch (e: any) {
|
|
110
|
-
this.platform.log.error(`Camera: ${this.accessory.displayName}
|
|
111
|
-
|
|
112
|
-
|
|
114
|
+
this.platform.log.error(`Camera: ${this.accessory.displayName} failed pushChanges with OpenAPI Connection`);
|
|
115
|
+
if (this.deviceDebug) {
|
|
116
|
+
this.platform.log.error(`Camera: ${this.accessory.displayName} failed pushChanges with OpenAPI Connection,`
|
|
117
|
+
+ ` Error Message: ${JSON.stringify(e.message)}`);
|
|
118
|
+
}
|
|
119
|
+
if (this.debugDebug) {
|
|
120
|
+
this.platform.log.error(`Camera: ${this.accessory.displayName} failed pushChanges with OpenAPI Connection,`
|
|
121
|
+
+ ` Error: ${JSON.stringify(e)}`);
|
|
122
|
+
}
|
|
113
123
|
this.apiError(e);
|
|
114
124
|
}
|
|
115
125
|
}
|
|
@@ -132,8 +142,8 @@ export class Camera {
|
|
|
132
142
|
this.platform.log.error(`Camera: ${this.accessory.displayName} Hub Device is offline.`);
|
|
133
143
|
break;
|
|
134
144
|
case 190:
|
|
135
|
-
|
|
136
|
-
|
|
145
|
+
this.platform.log.error(`Camera: ${this.accessory.displayName} Device internal error due to device states not synchronized with server,`
|
|
146
|
+
+ ` Or command: ${JSON.stringify(push.data)} format is invalid`);
|
|
137
147
|
break;
|
|
138
148
|
case 100:
|
|
139
149
|
this.platform.debug(`Camera: ${this.accessory.displayName} Command successfully sent.`);
|
package/src/irdevices/fans.ts
CHANGED
|
@@ -26,6 +26,8 @@ export class Fan {
|
|
|
26
26
|
minStep?: number;
|
|
27
27
|
minValue?: number;
|
|
28
28
|
maxValue?: number;
|
|
29
|
+
private readonly deviceDebug = this.platform.config.options?.debug === 'device' || this.platform.debugMode;
|
|
30
|
+
private readonly debugDebug = this.platform.config.options?.debug === 'debug' || this.platform.debugMode;
|
|
29
31
|
|
|
30
32
|
constructor(
|
|
31
33
|
private readonly platform: SwitchBotPlatform,
|
|
@@ -231,9 +233,15 @@ export class Fan {
|
|
|
231
233
|
this.statusCode(push);
|
|
232
234
|
this.updateHomeKitCharacteristics();
|
|
233
235
|
} catch (e: any) {
|
|
234
|
-
this.platform.log.error(`Fan: ${this.accessory.displayName}
|
|
235
|
-
|
|
236
|
-
|
|
236
|
+
this.platform.log.error(`Fan: ${this.accessory.displayName} failed pushChanges with OpenAPI Connection`);
|
|
237
|
+
if (this.deviceDebug) {
|
|
238
|
+
this.platform.log.error(`Fan: ${this.accessory.displayName} failed pushChanges with OpenAPI Connection,`
|
|
239
|
+
+ ` Error Message: ${JSON.stringify(e.message)}`);
|
|
240
|
+
}
|
|
241
|
+
if (this.debugDebug) {
|
|
242
|
+
this.platform.log.error(`Fan: ${this.accessory.displayName} failed pushChanges with OpenAPI Connection,`
|
|
243
|
+
+ ` Error: ${JSON.stringify(e)}`);
|
|
244
|
+
}
|
|
237
245
|
this.apiError(e);
|
|
238
246
|
}
|
|
239
247
|
}
|
|
@@ -256,8 +264,8 @@ export class Fan {
|
|
|
256
264
|
this.platform.log.error(`Fan: ${this.accessory.displayName} Hub Device is offline.`);
|
|
257
265
|
break;
|
|
258
266
|
case 190:
|
|
259
|
-
|
|
260
|
-
|
|
267
|
+
this.platform.log.error(`Fan: ${this.accessory.displayName} Device internal error due to device states not synchronized with server,`
|
|
268
|
+
+ ` Or command: ${JSON.stringify(push.data)} format is invalid`);
|
|
261
269
|
break;
|
|
262
270
|
case 100:
|
|
263
271
|
this.platform.debug(`Fan: ${this.accessory.displayName} Command successfully sent.`);
|
package/src/irdevices/lights.ts
CHANGED
|
@@ -15,6 +15,10 @@ export class Light {
|
|
|
15
15
|
// Characteristic Values
|
|
16
16
|
On!: CharacteristicValue;
|
|
17
17
|
|
|
18
|
+
// Config
|
|
19
|
+
private readonly deviceDebug = this.platform.config.options?.debug === 'device' || this.platform.debugMode;
|
|
20
|
+
private readonly debugDebug = this.platform.config.options?.debug === 'debug' || this.platform.debugMode;
|
|
21
|
+
|
|
18
22
|
constructor(
|
|
19
23
|
private readonly platform: SwitchBotPlatform,
|
|
20
24
|
private accessory: PlatformAccessory,
|
|
@@ -140,9 +144,15 @@ export class Light {
|
|
|
140
144
|
this.statusCode(push);
|
|
141
145
|
this.updateHomeKitCharacteristics();
|
|
142
146
|
} catch (e: any) {
|
|
143
|
-
this.platform.log.error(`Light: ${this.accessory.displayName}
|
|
144
|
-
|
|
145
|
-
|
|
147
|
+
this.platform.log.error(`Light: ${this.accessory.displayName} failed pushChanges with OpenAPI Connection`);
|
|
148
|
+
if (this.deviceDebug) {
|
|
149
|
+
this.platform.log.error(`Light: ${this.accessory.displayName} failed pushChanges with OpenAPI Connection,`
|
|
150
|
+
+ ` Error Message: ${JSON.stringify(e.message)}`);
|
|
151
|
+
}
|
|
152
|
+
if (this.debugDebug) {
|
|
153
|
+
this.platform.log.error(`Light: ${this.accessory.displayName} failed pushChanges with OpenAPI Connection,`
|
|
154
|
+
+ ` Error: ${JSON.stringify(e)}`);
|
|
155
|
+
}
|
|
146
156
|
this.apiError(e);
|
|
147
157
|
}
|
|
148
158
|
}
|
|
@@ -166,8 +176,8 @@ export class Light {
|
|
|
166
176
|
this.platform.log.error(`Light: ${this.accessory.displayName} Hub Device is offline.`);
|
|
167
177
|
break;
|
|
168
178
|
case 190:
|
|
169
|
-
|
|
170
|
-
|
|
179
|
+
this.platform.log.error(`Light: ${this.accessory.displayName} Device internal error due to device states not synchronized with server,`
|
|
180
|
+
+ ` Or command: ${JSON.stringify(push.data)} format is invalid`);
|
|
171
181
|
break;
|
|
172
182
|
case 100:
|
|
173
183
|
this.platform.debug(`Light: ${this.accessory.displayName} Command successfully sent.`);
|
package/src/irdevices/others.ts
CHANGED
|
@@ -15,6 +15,10 @@ export class Others {
|
|
|
15
15
|
// Characteristic Values
|
|
16
16
|
Active!: CharacteristicValue;
|
|
17
17
|
|
|
18
|
+
// Config
|
|
19
|
+
private readonly deviceDebug = this.platform.config.options?.debug === 'device' || this.platform.debugMode;
|
|
20
|
+
private readonly debugDebug = this.platform.config.options?.debug === 'debug' || this.platform.debugMode;
|
|
21
|
+
|
|
18
22
|
constructor(
|
|
19
23
|
private readonly platform: SwitchBotPlatform,
|
|
20
24
|
private accessory: PlatformAccessory,
|
|
@@ -38,7 +42,7 @@ export class Others {
|
|
|
38
42
|
this.service.getCharacteristic(this.platform.Characteristic.Active).onSet(this.ActiveSet.bind(this));
|
|
39
43
|
} else {
|
|
40
44
|
accessory.removeService(this.service!);
|
|
41
|
-
this.platform.log.error(`Other: ${this.accessory.displayName} No Device Type Set`);
|
|
45
|
+
this.platform.log.error(`Other: ${this.accessory.displayName} No Device Type Set, deviceType: ${device.other?.deviceType}`);
|
|
42
46
|
}
|
|
43
47
|
}
|
|
44
48
|
|
|
@@ -84,13 +88,13 @@ export class Others {
|
|
|
84
88
|
await this.pushChanges(payload);
|
|
85
89
|
}
|
|
86
90
|
} else {
|
|
87
|
-
this.platform.log.error(`Other: ${this.accessory.displayName} On Command not set
|
|
91
|
+
this.platform.log.error(`Other: ${this.accessory.displayName} On Command not set, commandOn: ${this.device.other.commandOn}`);
|
|
88
92
|
}
|
|
89
93
|
} else {
|
|
90
|
-
this.platform.log.error(`Other: ${this.accessory.displayName} On Command not set
|
|
94
|
+
this.platform.log.error(`Other: ${this.accessory.displayName} On Command not set, other: ${this.device.other}`);
|
|
91
95
|
}
|
|
92
96
|
} else {
|
|
93
|
-
this.platform.log.error(`Other: ${this.accessory.displayName} On Command not set
|
|
97
|
+
this.platform.log.error(`Other: ${this.accessory.displayName} On Command not set`);
|
|
94
98
|
}
|
|
95
99
|
}
|
|
96
100
|
|
|
@@ -107,10 +111,10 @@ export class Others {
|
|
|
107
111
|
await this.pushChanges(payload);
|
|
108
112
|
}
|
|
109
113
|
} else {
|
|
110
|
-
this.platform.log.error(`Other: ${this.accessory.displayName} Off Command not set
|
|
114
|
+
this.platform.log.error(`Other: ${this.accessory.displayName} Off Command not set, commandOff: ${this.device.other.commandOff}`);
|
|
111
115
|
}
|
|
112
116
|
} else {
|
|
113
|
-
this.platform.log.error(`Other: ${this.accessory.displayName} Off Command not set
|
|
117
|
+
this.platform.log.error(`Other: ${this.accessory.displayName} Off Command not set, other: ${this.device.other}`);
|
|
114
118
|
}
|
|
115
119
|
} else {
|
|
116
120
|
this.platform.log.error(`Other: ${this.accessory.displayName} Off Command not set.`);
|
|
@@ -128,9 +132,15 @@ export class Others {
|
|
|
128
132
|
this.statusCode(push);
|
|
129
133
|
this.updateHomeKitCharacteristics();
|
|
130
134
|
} catch (e: any) {
|
|
131
|
-
this.platform.log.error(`Other: ${this.accessory.displayName}
|
|
132
|
-
|
|
133
|
-
|
|
135
|
+
this.platform.log.error(`Other: ${this.accessory.displayName} failed pushChanges with OpenAPI Connection`);
|
|
136
|
+
if (this.deviceDebug) {
|
|
137
|
+
this.platform.log.error(`Other: ${this.accessory.displayName} failed pushChanges with OpenAPI Connection,`
|
|
138
|
+
+ ` Error Message: ${JSON.stringify(e.message)}`);
|
|
139
|
+
}
|
|
140
|
+
if (this.debugDebug) {
|
|
141
|
+
this.platform.log.error(`Other: ${this.accessory.displayName} failed pushChanges with OpenAPI Connection,`
|
|
142
|
+
+ ` Error: ${JSON.stringify(e)}`);
|
|
143
|
+
}
|
|
134
144
|
this.apiError(e);
|
|
135
145
|
}
|
|
136
146
|
}
|
|
@@ -153,8 +163,8 @@ export class Others {
|
|
|
153
163
|
this.platform.log.error(`Other: ${this.accessory.displayName} Hub Device is offline.`);
|
|
154
164
|
break;
|
|
155
165
|
case 190:
|
|
156
|
-
|
|
157
|
-
|
|
166
|
+
this.platform.log.error(`Other: ${this.accessory.displayName} Device internal error due to device states not synchronized with server,`
|
|
167
|
+
+ ` Or command: ${JSON.stringify(push.data)} format is invalid`);
|
|
158
168
|
break;
|
|
159
169
|
case 100:
|
|
160
170
|
this.platform.debug(`Other: ${this.accessory.displayName} Command successfully sent.`);
|
package/src/irdevices/tvs.ts
CHANGED
|
@@ -20,6 +20,10 @@ export class TV {
|
|
|
20
20
|
// Others
|
|
21
21
|
deviceStatus!: deviceStatusResponse;
|
|
22
22
|
|
|
23
|
+
// Config
|
|
24
|
+
private readonly deviceDebug = this.platform.config.options?.debug === 'device' || this.platform.debugMode;
|
|
25
|
+
private readonly debugDebug = this.platform.config.options?.debug === 'debug' || this.platform.debugMode;
|
|
26
|
+
|
|
23
27
|
constructor(
|
|
24
28
|
private readonly platform: SwitchBotPlatform,
|
|
25
29
|
private accessory: PlatformAccessory,
|
|
@@ -344,9 +348,15 @@ export class TV {
|
|
|
344
348
|
this.statusCode(push);
|
|
345
349
|
this.updateHomeKitCharacteristics();
|
|
346
350
|
} catch (e: any) {
|
|
347
|
-
this.platform.log.error(`${this.device.remoteType}: ${this.accessory.displayName}
|
|
348
|
-
|
|
349
|
-
|
|
351
|
+
this.platform.log.error(`${this.device.remoteType}: ${this.accessory.displayName} failed pushChanges with OpenAPI Connection`);
|
|
352
|
+
if (this.deviceDebug) {
|
|
353
|
+
this.platform.log.error(`${this.device.remoteType}: ${this.accessory.displayName} failed pushChanges with OpenAPI Connection,`
|
|
354
|
+
+ ` Error Message: ${JSON.stringify(e.message)}`);
|
|
355
|
+
}
|
|
356
|
+
if (this.debugDebug) {
|
|
357
|
+
this.platform.log.error(`${this.device.remoteType}: ${this.accessory.displayName} failed pushChanges with OpenAPI Connection,`
|
|
358
|
+
+ ` Error: ${JSON.stringify(e)}`);
|
|
359
|
+
}
|
|
350
360
|
this.apiError(e);
|
|
351
361
|
}
|
|
352
362
|
}
|
|
@@ -371,7 +381,8 @@ export class TV {
|
|
|
371
381
|
break;
|
|
372
382
|
case 190:
|
|
373
383
|
this.platform.log.error(`${this.device.remoteType}: `
|
|
374
|
-
+ `${this.accessory.displayName} Device internal error due to device states not synchronized with server
|
|
384
|
+
+ `${this.accessory.displayName} Device internal error due to device states not synchronized with server,`
|
|
385
|
+
+ ` Or command: ${JSON.stringify(push.data)} format is invalid`);
|
|
375
386
|
break;
|
|
376
387
|
case 100:
|
|
377
388
|
this.platform.debug(`${this.device.remoteType}: ${this.accessory.displayName} Command successfully sent.`);
|
|
@@ -15,6 +15,10 @@ export class VacuumCleaner {
|
|
|
15
15
|
// Characteristic Values
|
|
16
16
|
On!: CharacteristicValue;
|
|
17
17
|
|
|
18
|
+
// Config
|
|
19
|
+
private readonly deviceDebug = this.platform.config.options?.debug === 'device' || this.platform.debugMode;
|
|
20
|
+
private readonly debugDebug = this.platform.config.options?.debug === 'debug' || this.platform.debugMode;
|
|
21
|
+
|
|
18
22
|
constructor(
|
|
19
23
|
private readonly platform: SwitchBotPlatform,
|
|
20
24
|
private accessory: PlatformAccessory,
|
|
@@ -107,9 +111,15 @@ export class VacuumCleaner {
|
|
|
107
111
|
this.statusCode(push);
|
|
108
112
|
this.updateHomeKitCharacteristics();
|
|
109
113
|
} catch (e: any) {
|
|
110
|
-
this.platform.log.error(`Vacuum Cleaner: ${this.accessory.displayName}
|
|
111
|
-
|
|
112
|
-
|
|
114
|
+
this.platform.log.error(`Vacuum Cleaner: ${this.accessory.displayName} failed pushChanges with OpenAPI Connection`);
|
|
115
|
+
if (this.deviceDebug) {
|
|
116
|
+
this.platform.log.error(`Vacuum Cleaner: ${this.accessory.displayName} failed pushChanges with OpenAPI Connection,`
|
|
117
|
+
+ ` Error Message: ${JSON.stringify(e.message)}`);
|
|
118
|
+
}
|
|
119
|
+
if (this.debugDebug) {
|
|
120
|
+
this.platform.log.error(`Vacuum Cleaner: ${this.accessory.displayName} failed pushChanges with OpenAPI Connection,`
|
|
121
|
+
+ ` Error: ${JSON.stringify(e)}`);
|
|
122
|
+
}
|
|
113
123
|
this.apiError(e);
|
|
114
124
|
}
|
|
115
125
|
}
|
|
@@ -132,8 +142,8 @@ export class VacuumCleaner {
|
|
|
132
142
|
this.platform.log.error(`Vacuum Cleaner: ${this.accessory.displayName} Hub Device is offline.`);
|
|
133
143
|
break;
|
|
134
144
|
case 190:
|
|
135
|
-
|
|
136
|
-
|
|
145
|
+
this.platform.log.error(`Vacuum Cleaner: ${this.accessory.displayName} Device internal error due to device states not synchronized`
|
|
146
|
+
+ ` with server, Or command: ${JSON.stringify(push.data)} format is invalid`);
|
|
137
147
|
break;
|
|
138
148
|
case 100:
|
|
139
149
|
this.platform.debug(`Vacuum Cleaner: ${this.accessory.displayName} Command successfully sent.`);
|
|
@@ -15,6 +15,10 @@ export class WaterHeater {
|
|
|
15
15
|
// Characteristic Values
|
|
16
16
|
Active!: CharacteristicValue;
|
|
17
17
|
|
|
18
|
+
// Config
|
|
19
|
+
private readonly deviceDebug = this.platform.config.options?.debug === 'device' || this.platform.debugMode;
|
|
20
|
+
private readonly debugDebug = this.platform.config.options?.debug === 'debug' || this.platform.debugMode;
|
|
21
|
+
|
|
18
22
|
constructor(
|
|
19
23
|
private readonly platform: SwitchBotPlatform,
|
|
20
24
|
private accessory: PlatformAccessory,
|
|
@@ -121,9 +125,15 @@ export class WaterHeater {
|
|
|
121
125
|
this.statusCode(push);
|
|
122
126
|
this.updateHomeKitCharacteristics();
|
|
123
127
|
} catch (e: any) {
|
|
124
|
-
this.platform.log.error(`Water Heater: ${this.accessory.displayName}
|
|
125
|
-
|
|
126
|
-
|
|
128
|
+
this.platform.log.error(`Water Heater: ${this.accessory.displayName} failed pushChanges with OpenAPI Connection`);
|
|
129
|
+
if (this.deviceDebug) {
|
|
130
|
+
this.platform.log.error(`Water Heater: ${this.accessory.displayName} failed pushChanges with OpenAPI Connection,`
|
|
131
|
+
+ ` Error Message: ${JSON.stringify(e.message)}`);
|
|
132
|
+
}
|
|
133
|
+
if (this.debugDebug) {
|
|
134
|
+
this.platform.log.error(`Water Heater: ${this.accessory.displayName} failed pushChanges with OpenAPI Connection,`
|
|
135
|
+
+ ` Error: ${JSON.stringify(e)}`);
|
|
136
|
+
}
|
|
127
137
|
this.apiError(e);
|
|
128
138
|
}
|
|
129
139
|
}
|
|
@@ -146,8 +156,8 @@ export class WaterHeater {
|
|
|
146
156
|
this.platform.log.error(`Water Heater: ${this.accessory.displayName} Hub Device is offline.`);
|
|
147
157
|
break;
|
|
148
158
|
case 190:
|
|
149
|
-
|
|
150
|
-
|
|
159
|
+
this.platform.log.error(`Water Heater: ${this.accessory.displayName} Device internal error due to device states not synchronized with server,`
|
|
160
|
+
+ ` Or command: ${JSON.stringify(push.data)} format is invalid`);
|
|
151
161
|
break;
|
|
152
162
|
case 100:
|
|
153
163
|
this.platform.debug(`Water Heater: ${this.accessory.displayName} Command successfully sent.`);
|
package/src/platform.ts
CHANGED
|
@@ -49,6 +49,7 @@ export class SwitchBotPlatform implements DynamicPlatformPlugin {
|
|
|
49
49
|
version = require('../package.json').version; // eslint-disable-line @typescript-eslint/no-var-requires
|
|
50
50
|
deviceStatus!: deviceResponses;
|
|
51
51
|
registeringDevice!: boolean;
|
|
52
|
+
debugMode!: boolean;
|
|
52
53
|
|
|
53
54
|
constructor(public readonly log: Logger, public readonly config: SwitchBotPlatformConfig, public readonly api: API) {
|
|
54
55
|
this.log.debug('Finished initializing platform:', this.config.name);
|
|
@@ -73,7 +74,7 @@ export class SwitchBotPlatform implements DynamicPlatformPlugin {
|
|
|
73
74
|
return;
|
|
74
75
|
}
|
|
75
76
|
|
|
76
|
-
|
|
77
|
+
this.debugMode = process.argv.includes('-D') || process.argv.includes('--debug');
|
|
77
78
|
|
|
78
79
|
// setup axios interceptor to add headers / api key to each request
|
|
79
80
|
this.axios.interceptors.request.use((request: AxiosRequestConfig) => {
|
|
@@ -120,34 +121,37 @@ export class SwitchBotPlatform implements DynamicPlatformPlugin {
|
|
|
120
121
|
this.config.options = this.config.options || {};
|
|
121
122
|
this.config.options.debug;
|
|
122
123
|
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
124
|
+
if (this.config.options) {
|
|
125
|
+
|
|
126
|
+
// Device Config
|
|
127
|
+
if (this.config.options.devices) {
|
|
128
|
+
for (const deviceConfig of this.config.options.devices) {
|
|
129
|
+
if (!deviceConfig.hide_device) {
|
|
130
|
+
if (!deviceConfig.deviceId) {
|
|
131
|
+
throw new Error('The devices config section is missing the *Device ID* in the config, Check Your Conifg.');
|
|
132
|
+
}
|
|
133
|
+
if (!deviceConfig.configDeviceType && deviceConfig.ble) {
|
|
134
|
+
throw new Error('The devices config section is missing the *Device Type* in the config, Check Your Conifg.');
|
|
135
|
+
}
|
|
136
|
+
if (deviceConfig.bot) {
|
|
137
|
+
if (!deviceConfig.bot?.mode) {
|
|
138
|
+
this.log.error('You must set your Bot to Press or Switch Mode');
|
|
139
|
+
}
|
|
136
140
|
}
|
|
137
141
|
}
|
|
138
142
|
}
|
|
139
143
|
}
|
|
140
|
-
}
|
|
141
144
|
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
145
|
+
// IR Device Config
|
|
146
|
+
if (this.config.options.irdevices) {
|
|
147
|
+
for (const irDeviceConfig of this.config.options.irdevices) {
|
|
148
|
+
if (!irDeviceConfig.hide_device) {
|
|
149
|
+
if (!irDeviceConfig.deviceId) {
|
|
150
|
+
this.log.error('The devices config section is missing the *Device ID* in the config, Check Your Conifg.');
|
|
151
|
+
}
|
|
152
|
+
if (!irDeviceConfig.deviceId && !irDeviceConfig.configRemoteType) {
|
|
153
|
+
this.log.error('The devices config section is missing the *Device Type* in the config, Check Your Conifg.');
|
|
154
|
+
}
|
|
151
155
|
}
|
|
152
156
|
}
|
|
153
157
|
}
|
|
@@ -384,12 +388,18 @@ export class SwitchBotPlatform implements DynamicPlatformPlugin {
|
|
|
384
388
|
}
|
|
385
389
|
|
|
386
390
|
private registerDevice(device: device & devicesConfig) {
|
|
387
|
-
if (!device.hide_device && device.enableCloudService) {
|
|
391
|
+
if (!device.hide_device && device.enableCloudService && device.ble) {
|
|
392
|
+
this.registeringDevice = true;
|
|
393
|
+
this.device(`Device: ${device.deviceName} Both OpenAPI and BLE Connections Enabled`);
|
|
394
|
+
} else if (!device.hide_device && device.deviceId && device.configDeviceType && device.configDeviceName && !device.enableCloudService) {
|
|
388
395
|
this.registeringDevice = true;
|
|
389
|
-
|
|
396
|
+
this.device(`Device: ${device.deviceName} BLE Connection Enabled`);
|
|
397
|
+
} else if (!device.hide_device && device.enableCloudService && !device.ble) {
|
|
390
398
|
this.registeringDevice = true;
|
|
399
|
+
this.device(`Device: ${device.deviceName} OpenAPI Connection Enabled`);
|
|
391
400
|
} else {
|
|
392
401
|
this.registeringDevice = false;
|
|
402
|
+
this.device(`Device: ${device.deviceName} Neither OpenAPI and BLE Enabled`);
|
|
393
403
|
}
|
|
394
404
|
return this.registeringDevice;
|
|
395
405
|
}
|