@switchbot/homebridge-switchbot 1.3.0 → 1.3.1-beta.3
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/config.schema.json +3 -3
- package/dist/devices/bots.d.ts.map +1 -1
- package/dist/devices/bots.js +24 -15
- package/dist/devices/bots.js.map +1 -1
- package/dist/devices/colorbulb.js +1 -1
- package/dist/devices/colorbulb.js.map +1 -1
- package/dist/devices/curtains.js +2 -2
- package/dist/devices/curtains.js.map +1 -1
- package/dist/devices/humidifiers.js +2 -2
- package/dist/devices/humidifiers.js.map +1 -1
- package/dist/devices/indoorcam.d.ts +32 -3
- package/dist/devices/indoorcam.d.ts.map +1 -1
- package/dist/devices/indoorcam.js +92 -45
- package/dist/devices/indoorcam.js.map +1 -1
- package/dist/devices/plugs.js +1 -1
- package/dist/devices/plugs.js.map +1 -1
- package/dist/irdevices/airconditioners.js +1 -1
- package/dist/irdevices/airconditioners.js.map +1 -1
- package/dist/irdevices/airpurifiers.js +1 -1
- package/dist/irdevices/airpurifiers.js.map +1 -1
- package/dist/irdevices/cameras.js +1 -1
- package/dist/irdevices/cameras.js.map +1 -1
- package/dist/irdevices/fans.js +1 -1
- package/dist/irdevices/fans.js.map +1 -1
- package/dist/irdevices/lights.js +1 -1
- package/dist/irdevices/lights.js.map +1 -1
- package/dist/irdevices/others.js +1 -1
- package/dist/irdevices/others.js.map +1 -1
- package/dist/irdevices/tvs.js +1 -1
- package/dist/irdevices/tvs.js.map +1 -1
- package/dist/irdevices/vacuumcleaners.js +1 -1
- package/dist/irdevices/vacuumcleaners.js.map +1 -1
- package/dist/irdevices/waterheaters.js +1 -1
- package/dist/irdevices/waterheaters.js.map +1 -1
- package/dist/platform.d.ts +2 -0
- package/dist/platform.d.ts.map +1 -1
- package/dist/platform.js +63 -21
- package/dist/platform.js.map +1 -1
- package/homebridge-ui/public/index.html +5 -1
- package/package.json +66 -66
- package/src/devices/bots.ts +34 -27
- package/src/devices/colorbulb.ts +1 -1
- package/src/devices/curtains.ts +2 -2
- package/src/devices/humidifiers.ts +2 -2
- package/src/devices/indoorcam.ts +117 -49
- package/src/devices/plugs.ts +1 -1
- package/src/irdevices/airconditioners.ts +1 -1
- package/src/irdevices/airpurifiers.ts +1 -1
- package/src/irdevices/cameras.ts +1 -1
- package/src/irdevices/fans.ts +1 -1
- package/src/irdevices/lights.ts +1 -1
- package/src/irdevices/others.ts +1 -1
- package/src/irdevices/tvs.ts +1 -1
- package/src/irdevices/vacuumcleaners.ts +1 -1
- package/src/irdevices/waterheaters.ts +1 -1
- package/src/platform.ts +72 -21
|
@@ -64,7 +64,10 @@
|
|
|
64
64
|
<th scope="row">Firmware Version</th>
|
|
65
65
|
<td id="firmwareRevision"></td>
|
|
66
66
|
</tr>
|
|
67
|
-
|
|
67
|
+
<tr>
|
|
68
|
+
<th scope="row">Device Type</th>
|
|
69
|
+
<td id="deviceType"></td>
|
|
70
|
+
</tr>
|
|
68
71
|
<tr>
|
|
69
72
|
<th scope="row">Connection Type</th>
|
|
70
73
|
<td id="connectionType"></td>
|
|
@@ -173,6 +176,7 @@
|
|
|
173
176
|
document.getElementById('deviceID').innerHTML = context.deviceID
|
|
174
177
|
document.getElementById('model').innerHTML = context.model
|
|
175
178
|
document.getElementById('firmwareRevision').innerHTML = context.firmwareRevision || 'N/A'
|
|
179
|
+
document.getElementById('deviceType').innerHTML = context.deviceType
|
|
176
180
|
document.getElementById('connectionType').innerHTML = context.connectionType
|
|
177
181
|
document.getElementById('deviceTable').style.display = 'inline-table'
|
|
178
182
|
homebridge.hideSpinner()
|
package/package.json
CHANGED
|
@@ -1,68 +1,68 @@
|
|
|
1
1
|
{
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
2
|
+
"displayName": "Homebridge SwitchBot",
|
|
3
|
+
"name": "@switchbot/homebridge-switchbot",
|
|
4
|
+
"version": "1.3.1-beta.3",
|
|
5
|
+
"description": "The [Homebridge](https://homebridge.io) SwitchBot plugin allows you to access your [SwitchBot](https://www.switch-bot.com) device(s) from HomeKit.",
|
|
6
|
+
"author": "SwitchBot <support@wondertechlabs.com> (https://github.com/SwitchBot)",
|
|
7
|
+
"license": "ISC",
|
|
8
|
+
"repository": {
|
|
9
|
+
"type": "git",
|
|
10
|
+
"url": "git://github.com/OpenWonderLabs/homebridge-switchbot.git"
|
|
11
|
+
},
|
|
12
|
+
"bugs": {
|
|
13
|
+
"url": "https://github.com/OpenWonderLabs/homebridge-switchbot/issues"
|
|
14
|
+
},
|
|
15
|
+
"engines": {
|
|
16
|
+
"homebridge": "^1.3.8",
|
|
17
|
+
"node": "^14.18.2 || ^16.13.1"
|
|
18
|
+
},
|
|
19
|
+
"main": "dist/index.js",
|
|
20
|
+
"scripts": {
|
|
21
|
+
"check": "npm install && npm outdated",
|
|
22
|
+
"update": "ncu -u && npm update && npm install",
|
|
23
|
+
"lint": "eslint src/**.ts",
|
|
24
|
+
"watch": "npm run build && npm link && nodemon",
|
|
25
|
+
"build": "rimraf ./dist && tsc",
|
|
26
|
+
"prepublishOnly": "npm run lint && npm run build"
|
|
27
|
+
},
|
|
28
|
+
"funding": [
|
|
29
|
+
{
|
|
30
|
+
"type": "Paypal",
|
|
31
|
+
"url": "https://www.paypal.me/donavanbecker"
|
|
32
|
+
}
|
|
33
|
+
],
|
|
34
|
+
"publishConfig": {
|
|
35
|
+
"access": "public"
|
|
36
|
+
},
|
|
37
|
+
"keywords": [
|
|
38
|
+
"homebridge-plugin",
|
|
39
|
+
"switchbot",
|
|
40
|
+
"humidifier",
|
|
41
|
+
"humidity",
|
|
42
|
+
"temperature",
|
|
43
|
+
"bot",
|
|
44
|
+
"curtains",
|
|
45
|
+
"windows",
|
|
46
|
+
"ble",
|
|
47
|
+
"ir"
|
|
48
|
+
],
|
|
49
|
+
"dependencies": {
|
|
50
|
+
"@homebridge/plugin-ui-utils": "^0.0.19",
|
|
51
|
+
"axios": "^0.24.0",
|
|
52
|
+
"node-switchbot": "^1.1.2",
|
|
53
|
+
"rxjs": "^7.4.0"
|
|
54
|
+
},
|
|
55
|
+
"devDependencies": {
|
|
56
|
+
"@types/node": "^16.11.11",
|
|
57
|
+
"@typescript-eslint/eslint-plugin": "^5.5.0",
|
|
58
|
+
"@typescript-eslint/parser": "^5.5.0",
|
|
59
|
+
"eslint": "^8.4.0",
|
|
60
|
+
"homebridge": "^1.3.8",
|
|
61
|
+
"nodemon": "^2.0.15",
|
|
62
|
+
"npm-check-updates": "^12.0.2",
|
|
63
|
+
"rimraf": "^3.0.2",
|
|
64
|
+
"ts-node": "^10.4.0",
|
|
65
|
+
"typescript": "^4.5.2",
|
|
66
|
+
"typescript-axios-wb": "^1.0.3"
|
|
32
67
|
}
|
|
33
|
-
|
|
34
|
-
"publishConfig": {
|
|
35
|
-
"access": "public"
|
|
36
|
-
},
|
|
37
|
-
"keywords": [
|
|
38
|
-
"homebridge-plugin",
|
|
39
|
-
"switchbot",
|
|
40
|
-
"humidifier",
|
|
41
|
-
"humidity",
|
|
42
|
-
"temperature",
|
|
43
|
-
"bot",
|
|
44
|
-
"curtains",
|
|
45
|
-
"windows",
|
|
46
|
-
"ble",
|
|
47
|
-
"ir"
|
|
48
|
-
],
|
|
49
|
-
"dependencies": {
|
|
50
|
-
"@homebridge/plugin-ui-utils": "^0.0.19",
|
|
51
|
-
"axios": "^0.24.0",
|
|
52
|
-
"node-switchbot": "^1.1.2",
|
|
53
|
-
"rxjs": "^7.4.0"
|
|
54
|
-
},
|
|
55
|
-
"devDependencies": {
|
|
56
|
-
"@types/node": "^16.11.11",
|
|
57
|
-
"@typescript-eslint/eslint-plugin": "^5.5.0",
|
|
58
|
-
"@typescript-eslint/parser": "^5.5.0",
|
|
59
|
-
"eslint": "^8.3.0",
|
|
60
|
-
"homebridge": "^1.3.8",
|
|
61
|
-
"nodemon": "^2.0.15",
|
|
62
|
-
"npm-check-updates": "^12.0.2",
|
|
63
|
-
"rimraf": "^3.0.2",
|
|
64
|
-
"ts-node": "^10.4.0",
|
|
65
|
-
"typescript": "^4.5.2",
|
|
66
|
-
"typescript-axios-wb": "^1.0.3"
|
|
67
|
-
}
|
|
68
|
-
}
|
|
68
|
+
}
|
package/src/devices/bots.ts
CHANGED
|
@@ -61,7 +61,6 @@ export class Bot {
|
|
|
61
61
|
this.botUpdateInProgress = false;
|
|
62
62
|
|
|
63
63
|
// Retrieve initial values and updateHomekit
|
|
64
|
-
this.parseStatus();
|
|
65
64
|
|
|
66
65
|
// set accessory information
|
|
67
66
|
accessory
|
|
@@ -123,7 +122,6 @@ export class Bot {
|
|
|
123
122
|
|
|
124
123
|
// Retrieve initial values and updateHomekit
|
|
125
124
|
this.refreshStatus();
|
|
126
|
-
this.updateHomeKitCharacteristics();
|
|
127
125
|
|
|
128
126
|
// Start an update interval
|
|
129
127
|
interval(this.platform.config.options!.refreshRate! * 1000)
|
|
@@ -197,6 +195,12 @@ export class Bot {
|
|
|
197
195
|
this.platform.debug(`Bot: ${this.accessory.displayName} OpenAPI parseStatus`);
|
|
198
196
|
if (this.device.bot?.mode === 'press') {
|
|
199
197
|
this.On = false;
|
|
198
|
+
} else {
|
|
199
|
+
if (this.deviceStatus.body.power === 'on') {
|
|
200
|
+
this.On = true;
|
|
201
|
+
} else {
|
|
202
|
+
this.On = false;
|
|
203
|
+
}
|
|
200
204
|
}
|
|
201
205
|
this.platform.debug(`Bot ${this.accessory.displayName} On: ${this.On}`);
|
|
202
206
|
}
|
|
@@ -284,7 +288,9 @@ export class Bot {
|
|
|
284
288
|
if (this.platform.config.credentials?.openToken) {
|
|
285
289
|
this.platform.debug(`Bot: ${this.accessory.displayName} OpenAPI refreshStatus`);
|
|
286
290
|
try {
|
|
287
|
-
this.deviceStatus = {
|
|
291
|
+
this.deviceStatus = (await this.platform.axios.get(`${DeviceURL}/${this.device.deviceId}/status`)).data;
|
|
292
|
+
this.platform.device(`Bot: ${this.accessory.displayName} refreshStatus: ${JSON.stringify(this.deviceStatus)}`);
|
|
293
|
+
/*this.deviceStatus = {
|
|
288
294
|
statusCode: 100,
|
|
289
295
|
body: {
|
|
290
296
|
deviceId: this.device.deviceId!,
|
|
@@ -293,7 +299,7 @@ export class Bot {
|
|
|
293
299
|
power: 'on',
|
|
294
300
|
},
|
|
295
301
|
message: 'success',
|
|
296
|
-
}
|
|
302
|
+
};*/
|
|
297
303
|
this.parseStatus();
|
|
298
304
|
this.updateHomeKitCharacteristics();
|
|
299
305
|
} catch (e: any) {
|
|
@@ -324,7 +330,7 @@ export class Bot {
|
|
|
324
330
|
} else {
|
|
325
331
|
await this.openAPIpushChanges();
|
|
326
332
|
}
|
|
327
|
-
this.refreshStatus
|
|
333
|
+
setTimeout(this.refreshStatus, 5000);
|
|
328
334
|
}
|
|
329
335
|
|
|
330
336
|
private async BLEpushChanges() {
|
|
@@ -332,27 +338,28 @@ export class Bot {
|
|
|
332
338
|
const switchbot = this.connectBLE();
|
|
333
339
|
if (this.device.bot?.mode === 'press') {
|
|
334
340
|
this.platform.device(`Bot: ${this.accessory.displayName} Press Mode: ${this.device.bot?.mode}`);
|
|
335
|
-
switchbot.discover({ model: 'H', quick: true, id: this.device.bleMac })
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
this.
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
this.
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
this.platform.
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
341
|
+
switchbot.discover({ model: 'H', quick: true, id: this.device.bleMac })
|
|
342
|
+
.then((device_list: { press: (arg0: { id: string | undefined; }) => any; }[]) => {
|
|
343
|
+
this.platform.log.info(`Bot: ${this.accessory.displayName}, On: ${this.On}`);
|
|
344
|
+
return device_list[0].press({ id: this.device.bleMac });
|
|
345
|
+
}).then(() => {
|
|
346
|
+
this.platform.device(`Bot: ${this.accessory.displayName} Done.`);
|
|
347
|
+
}).catch(async (e: any) => {
|
|
348
|
+
this.platform.log.error(`Bot: ${this.accessory.displayName} failed pushChanges with BLE Connection`);
|
|
349
|
+
if (this.deviceDebug) {
|
|
350
|
+
this.platform.log.error(`Bot: ${this.accessory.displayName} failed pushChanges with BLE Connection,`
|
|
351
|
+
+ ` Error Message: ${JSON.stringify(e.message)}`);
|
|
352
|
+
}
|
|
353
|
+
if (this.debugDebug) {
|
|
354
|
+
this.platform.log.error(`Bot: ${this.accessory.displayName} failed pushChanges with BLE Connection,`
|
|
355
|
+
+ ` Error: ${JSON.stringify(e)}`);
|
|
356
|
+
}
|
|
357
|
+
if (this.platform.config.credentials?.openToken) {
|
|
358
|
+
this.platform.log.warn(`Bot: ${this.accessory.displayName} Using OpenAPI Connection`);
|
|
359
|
+
await this.openAPIpushChanges();
|
|
360
|
+
}
|
|
361
|
+
this.apiError(e);
|
|
362
|
+
});
|
|
356
363
|
} else if (this.device.bot?.mode === 'switch') {
|
|
357
364
|
this.platform.device(`Bot: ${this.accessory.displayName} Press Mode: ${this.device.bot?.mode}`);
|
|
358
365
|
switchbot.discover({ model: 'H', quick: true, id: this.device.bleMac }).then((device_list: any) => {
|
|
@@ -493,7 +500,7 @@ export class Bot {
|
|
|
493
500
|
this.platform.log.error(`Bot: ${this.accessory.displayName} Device is offline.`);
|
|
494
501
|
break;
|
|
495
502
|
case 171:
|
|
496
|
-
this.platform.log.error(`Bot: ${this.accessory.displayName} Hub Device is offline
|
|
503
|
+
this.platform.log.error(`Bot: ${this.accessory.displayName} Hub Device is offline. Hub: ${this.device.hubDeviceId}`);
|
|
497
504
|
break;
|
|
498
505
|
case 190:
|
|
499
506
|
this.platform.log.error(`Bot: ${this.accessory.displayName} Device internal error due to device states not synchronized with server,`
|
package/src/devices/colorbulb.ts
CHANGED
|
@@ -500,7 +500,7 @@ export class ColorBulb {
|
|
|
500
500
|
this.platform.log.error(`Color Bulb: ${this.accessory.displayName} Device is offline.`);
|
|
501
501
|
break;
|
|
502
502
|
case 171:
|
|
503
|
-
this.platform.log.error(`Color Bulb: ${this.accessory.displayName} Hub Device is offline
|
|
503
|
+
this.platform.log.error(`Color Bulb: ${this.accessory.displayName} Hub Device is offline. Hub: ${this.device.hubDeviceId}`);
|
|
504
504
|
break;
|
|
505
505
|
case 190:
|
|
506
506
|
this.platform.log.error(`Color Bulb: ${this.accessory.displayName} Device internal error due to device states not synchronized with server,`
|
package/src/devices/curtains.ts
CHANGED
|
@@ -487,7 +487,7 @@ export class Curtain {
|
|
|
487
487
|
} else {
|
|
488
488
|
await this.OpenAPIpushChanges();
|
|
489
489
|
}
|
|
490
|
-
this.refreshStatus
|
|
490
|
+
setTimeout(this.refreshStatus, 5000);
|
|
491
491
|
}
|
|
492
492
|
|
|
493
493
|
private async BLEpushChanges() {
|
|
@@ -632,7 +632,7 @@ export class Curtain {
|
|
|
632
632
|
this.platform.log.error(`Curtain: ${this.accessory.displayName} Device is offline.`);
|
|
633
633
|
break;
|
|
634
634
|
case 171:
|
|
635
|
-
this.platform.log.error(`Curtain: ${this.accessory.displayName} Hub Device is offline
|
|
635
|
+
this.platform.log.error(`Curtain: ${this.accessory.displayName} Hub Device is offline. Hub: ${this.device.hubDeviceId}`);
|
|
636
636
|
break;
|
|
637
637
|
case 190:
|
|
638
638
|
this.platform.log.error(`Curtain: ${this.accessory.displayName} Device internal error due to device states not synchronized with server,`
|
|
@@ -394,7 +394,7 @@ export class Humidifier {
|
|
|
394
394
|
//} else {
|
|
395
395
|
await this.OpenAPIpushChanges();
|
|
396
396
|
//}
|
|
397
|
-
this.refreshStatus
|
|
397
|
+
setTimeout(this.refreshStatus, 5000);
|
|
398
398
|
}
|
|
399
399
|
|
|
400
400
|
private async BLEpushChanges() {
|
|
@@ -630,7 +630,7 @@ export class Humidifier {
|
|
|
630
630
|
this.platform.log.error(`Humidifier: ${this.accessory.displayName} Device is offline.`);
|
|
631
631
|
break;
|
|
632
632
|
case 171:
|
|
633
|
-
this.platform.log.error(`Humidifier: ${this.accessory.displayName} Hub Device is offline
|
|
633
|
+
this.platform.log.error(`Humidifier: ${this.accessory.displayName} Hub Device is offline. Hub: ${this.device.hubDeviceId}`);
|
|
634
634
|
break;
|
|
635
635
|
case 190:
|
|
636
636
|
this.platform.log.error(`Humidifier: ${this.accessory.displayName} Device internal error due to device states not synchronized with server,`
|
package/src/devices/indoorcam.ts
CHANGED
|
@@ -10,8 +10,13 @@ export class IndoorCam {
|
|
|
10
10
|
private service: Service;
|
|
11
11
|
|
|
12
12
|
// Characteristic Values
|
|
13
|
-
|
|
14
|
-
|
|
13
|
+
Active!: CharacteristicValue;
|
|
14
|
+
SetupEndpoints!: CharacteristicValue;
|
|
15
|
+
StreamingStatus!: CharacteristicValue;
|
|
16
|
+
SupportedRTPConfiguration!: CharacteristicValue;
|
|
17
|
+
SelectedRTPStreamConfiguration!: CharacteristicValue;
|
|
18
|
+
SupportedVideoStreamConfiguration!: CharacteristicValue;
|
|
19
|
+
SupportedAudioStreamConfiguration!: CharacteristicValue;
|
|
15
20
|
|
|
16
21
|
// OpenAPI Others
|
|
17
22
|
deviceStatus!: deviceStatusResponse;
|
|
@@ -29,9 +34,12 @@ export class IndoorCam {
|
|
|
29
34
|
private accessory: PlatformAccessory,
|
|
30
35
|
public device: device & devicesConfig,
|
|
31
36
|
) {
|
|
37
|
+
// Indoor Cam Config
|
|
38
|
+
this.platform.device(`Indoor Cam: ${this.accessory.displayName} Config: (hide_device: ${device.hide_device})`);
|
|
39
|
+
|
|
40
|
+
this.platform.log.error(`Indoor Cam: ${this.accessory.displayName} was added but will not work as OpenAPI doesn't support it yet.`);
|
|
32
41
|
// default placeholders
|
|
33
|
-
this.
|
|
34
|
-
this.OutletInUse = true;
|
|
42
|
+
this.SelectedRTPStreamConfiguration;
|
|
35
43
|
|
|
36
44
|
// this is subject we use to track when we need to POST changes to the SwitchBot API
|
|
37
45
|
this.doCameraUpdate = new Subject();
|
|
@@ -50,8 +58,8 @@ export class IndoorCam {
|
|
|
50
58
|
// get the WindowCovering service if it exists, otherwise create a new WindowCovering service
|
|
51
59
|
// you can create multiple services for each accessory
|
|
52
60
|
(this.service =
|
|
53
|
-
accessory.getService(this.platform.Service.
|
|
54
|
-
accessory.addService(this.platform.Service.
|
|
61
|
+
accessory.getService(this.platform.Service.CameraRTPStreamManagement) ||
|
|
62
|
+
accessory.addService(this.platform.Service.CameraRTPStreamManagement)), `${accessory.displayName} Indoor Camera`;
|
|
55
63
|
|
|
56
64
|
// To avoid "Cannot add a Service with the same UUID another Service without also defining a unique 'subtype' property." error,
|
|
57
65
|
// when creating multiple services of the same type, you need to use the following syntax to specify a name and subtype id:
|
|
@@ -65,9 +73,26 @@ export class IndoorCam {
|
|
|
65
73
|
// see https://developers.homebridge.io/#/service/WindowCovering
|
|
66
74
|
|
|
67
75
|
// create handlers for required characteristics
|
|
68
|
-
this.service.getCharacteristic(this.platform.Characteristic.
|
|
76
|
+
this.service.getCharacteristic(this.platform.Characteristic.Active)
|
|
77
|
+
.onSet(this.ActiveSet.bind(this));
|
|
78
|
+
|
|
79
|
+
this.service.getCharacteristic(this.platform.Characteristic.SelectedRTPStreamConfiguration)
|
|
80
|
+
.onSet(this.SelectedRTPStreamConfigurationSet.bind(this));
|
|
81
|
+
|
|
82
|
+
this.service.getCharacteristic(this.platform.Characteristic.SetupEndpoints)
|
|
83
|
+
.onSet(this.SetupEndpointsSet.bind(this));
|
|
84
|
+
|
|
85
|
+
this.service.getCharacteristic(this.platform.Characteristic.StreamingStatus)
|
|
86
|
+
.onSet(this.StreamingStatusSet.bind(this));
|
|
69
87
|
|
|
70
|
-
this.service.
|
|
88
|
+
this.service.getCharacteristic(this.platform.Characteristic.SupportedAudioStreamConfiguration)
|
|
89
|
+
.onSet(this.SupportedAudioStreamConfigurationSet.bind(this));
|
|
90
|
+
|
|
91
|
+
this.service.getCharacteristic(this.platform.Characteristic.SupportedRTPConfiguration)
|
|
92
|
+
.onSet(this.SupportedRTPConfigurationSet.bind(this));
|
|
93
|
+
|
|
94
|
+
this.service.getCharacteristic(this.platform.Characteristic.SupportedVideoStreamConfiguration)
|
|
95
|
+
.onSet(this.SupportedVideoStreamConfigurationSet.bind(this));
|
|
71
96
|
|
|
72
97
|
// Update Homekit
|
|
73
98
|
this.updateHomeKitCharacteristics();
|
|
@@ -108,14 +133,7 @@ export class IndoorCam {
|
|
|
108
133
|
}
|
|
109
134
|
|
|
110
135
|
parseStatus() {
|
|
111
|
-
|
|
112
|
-
case 'on':
|
|
113
|
-
this.On = true;
|
|
114
|
-
break;
|
|
115
|
-
default:
|
|
116
|
-
this.On = false;
|
|
117
|
-
}
|
|
118
|
-
this.platform.debug(`Indoor Cam ${this.accessory.displayName} On: ${this.On}`);
|
|
136
|
+
this.platform.debug(`Indoor Cam ${this.accessory.displayName} SelectedRTPStreamConfiguration: ${this.SelectedRTPStreamConfiguration}`);
|
|
119
137
|
}
|
|
120
138
|
|
|
121
139
|
|
|
@@ -146,45 +164,37 @@ export class IndoorCam {
|
|
|
146
164
|
* Camera - "command" "turnOn" "default" = set to ON state
|
|
147
165
|
*/
|
|
148
166
|
async pushChanges() {
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
167
|
+
if (!this.Active) {
|
|
168
|
+
const payload = {
|
|
169
|
+
commandType: 'command',
|
|
170
|
+
parameter: 'default',
|
|
171
|
+
command: 'turnOn',
|
|
172
|
+
} as payload;
|
|
173
|
+
|
|
174
|
+
this.platform.log.info(`Indoor Cam: ${this.accessory.displayName} Sending request to SwitchBot API. command: ${payload.command},`
|
|
175
|
+
+ ` parameter: ${payload.parameter}, commandType: ${payload.commandType}`);
|
|
176
|
+
|
|
177
|
+
// Make the API request
|
|
178
|
+
const push: any = await this.platform.axios.post(`${DeviceURL}/${this.device.deviceId}/commands`, payload);
|
|
179
|
+
this.platform.debug(`Indoor Cam: ${this.accessory.displayName} pushChanges: ${JSON.stringify(push.data)}`);
|
|
180
|
+
this.statusCode(push);
|
|
181
|
+
setTimeout(this.refreshStatus, 5000);
|
|
156
182
|
} else {
|
|
157
|
-
|
|
183
|
+
this.platform.device(`Indoor Cam: ${this.accessory.displayName} No pushChanges. Active: ${this.Active}`);
|
|
158
184
|
}
|
|
159
|
-
|
|
160
|
-
this.platform.log.info(`Indoor Cam: ${this.accessory.displayName} Sending request to SwitchBot API. command: ${payload.command},`
|
|
161
|
-
+ ` parameter: ${payload.parameter}, commandType: ${payload.commandType}`);
|
|
162
|
-
|
|
163
|
-
// Make the API request
|
|
164
|
-
const push: any = await this.platform.axios.post(`${DeviceURL}/${this.device.deviceId}/commands`, payload);
|
|
165
|
-
this.platform.debug(`Indoor Cam: ${this.accessory.displayName} pushChanges: ${JSON.stringify(push.data)}`);
|
|
166
|
-
this.statusCode(push);
|
|
167
|
-
this.refreshStatus();
|
|
168
185
|
}
|
|
169
186
|
|
|
170
187
|
updateHomeKitCharacteristics() {
|
|
171
|
-
if (this.
|
|
172
|
-
this.platform.debug(`Indoor Cam: ${this.accessory.displayName} On: ${this.
|
|
188
|
+
if (this.SelectedRTPStreamConfiguration === undefined) {
|
|
189
|
+
this.platform.debug(`Indoor Cam: ${this.accessory.displayName} On: ${this.SelectedRTPStreamConfiguration}`);
|
|
173
190
|
} else {
|
|
174
|
-
this.service.updateCharacteristic(this.platform.Characteristic.
|
|
175
|
-
this.platform.device(`Indoor Cam: ${this.accessory.displayName} updateCharacteristic On: ${this.
|
|
176
|
-
}
|
|
177
|
-
if (this.OutletInUse === undefined) {
|
|
178
|
-
this.platform.debug(`Indoor Cam: ${this.accessory.displayName} OutletInUse: ${this.OutletInUse}`);
|
|
179
|
-
} else {
|
|
180
|
-
this.service.updateCharacteristic(this.platform.Characteristic.OutletInUse, this.OutletInUse);
|
|
181
|
-
this.platform.device(`Indoor Cam: ${this.accessory.displayName} updateCharacteristic OutletInUse: ${this.OutletInUse}`);
|
|
191
|
+
this.service.updateCharacteristic(this.platform.Characteristic.SelectedRTPStreamConfiguration, this.SelectedRTPStreamConfiguration);
|
|
192
|
+
this.platform.device(`Indoor Cam: ${this.accessory.displayName} updateCharacteristic On: ${this.SelectedRTPStreamConfiguration}`);
|
|
182
193
|
}
|
|
183
194
|
}
|
|
184
195
|
|
|
185
196
|
public apiError(e: any) {
|
|
186
|
-
this.service.updateCharacteristic(this.platform.Characteristic.
|
|
187
|
-
this.service.updateCharacteristic(this.platform.Characteristic.OutletInUse, e);
|
|
197
|
+
this.service.updateCharacteristic(this.platform.Characteristic.SelectedRTPStreamConfiguration, e);
|
|
188
198
|
}
|
|
189
199
|
|
|
190
200
|
private statusCode(push: AxiosResponse<{ statusCode: number; }>) {
|
|
@@ -202,7 +212,7 @@ export class IndoorCam {
|
|
|
202
212
|
this.platform.log.error(`Indoor Cam: ${this.accessory.displayName} Device is offline.`);
|
|
203
213
|
break;
|
|
204
214
|
case 171:
|
|
205
|
-
this.platform.log.error(`Indoor Cam: ${this.accessory.displayName} Hub Device is offline
|
|
215
|
+
this.platform.log.error(`Indoor Cam: ${this.accessory.displayName} Hub Device is offline. Hub: ${this.device.hubDeviceId}`);
|
|
206
216
|
break;
|
|
207
217
|
case 190:
|
|
208
218
|
this.platform.log.error(`Indoor Cam: ${this.accessory.displayName} Device internal error due to device states not synchronized with server,`
|
|
@@ -216,15 +226,73 @@ export class IndoorCam {
|
|
|
216
226
|
}
|
|
217
227
|
}
|
|
218
228
|
|
|
229
|
+
/**
|
|
230
|
+
* Handle requests to set the value of the "Active" characteristic
|
|
231
|
+
*/
|
|
232
|
+
ActiveSet(value: CharacteristicValue) {
|
|
233
|
+
this.platform.debug(`Indoor Cam: ${this.accessory.displayName} Active: ${value}`);
|
|
234
|
+
|
|
235
|
+
this.Active = value;
|
|
236
|
+
this.doCameraUpdate.next();
|
|
237
|
+
}
|
|
238
|
+
|
|
239
|
+
/**
|
|
240
|
+
* Handle requests to set the value of the "SelectedRTPStreamConfiguration" characteristic
|
|
241
|
+
*/
|
|
242
|
+
SelectedRTPStreamConfigurationSet(value: CharacteristicValue) {
|
|
243
|
+
this.platform.debug(`Indoor Cam: ${this.accessory.displayName} SelectedRTPStreamConfiguration: ${value}`);
|
|
244
|
+
|
|
245
|
+
this.SelectedRTPStreamConfiguration = value;
|
|
246
|
+
this.doCameraUpdate.next();
|
|
247
|
+
}
|
|
248
|
+
|
|
219
249
|
/**
|
|
220
250
|
* Handle requests to set the value of the "On" characteristic
|
|
221
251
|
*/
|
|
222
|
-
|
|
223
|
-
this.platform.debug(`Indoor Cam: ${this.accessory.displayName}
|
|
252
|
+
SetupEndpointsSet(value: CharacteristicValue) {
|
|
253
|
+
this.platform.debug(`Indoor Cam: ${this.accessory.displayName} SetupEndpoints: ${value}`);
|
|
224
254
|
|
|
225
|
-
this.
|
|
255
|
+
this.SetupEndpoints = value;
|
|
226
256
|
this.doCameraUpdate.next();
|
|
227
257
|
}
|
|
228
258
|
|
|
259
|
+
/**
|
|
260
|
+
* Handle requests to set the value of the "On" characteristic
|
|
261
|
+
*/
|
|
262
|
+
SupportedAudioStreamConfigurationSet(value: CharacteristicValue) {
|
|
263
|
+
this.platform.debug(`Indoor Cam: ${this.accessory.displayName} SupportedAudioStreamConfiguration: ${value}`);
|
|
264
|
+
|
|
265
|
+
this.SupportedAudioStreamConfiguration = value;
|
|
266
|
+
this.doCameraUpdate.next();
|
|
267
|
+
}
|
|
268
|
+
|
|
269
|
+
/**
|
|
270
|
+
* Handle requests to set the value of the "On" characteristic
|
|
271
|
+
*/
|
|
272
|
+
SupportedRTPConfigurationSet(value: CharacteristicValue) {
|
|
273
|
+
this.platform.debug(`Indoor Cam: ${this.accessory.displayName} SupportedRTPConfiguration: ${value}`);
|
|
274
|
+
|
|
275
|
+
this.SupportedRTPConfiguration = value;
|
|
276
|
+
this.doCameraUpdate.next();
|
|
277
|
+
}
|
|
229
278
|
|
|
279
|
+
/**
|
|
280
|
+
* Handle requests to set the value of the "On" characteristic
|
|
281
|
+
*/
|
|
282
|
+
StreamingStatusSet(value: CharacteristicValue) {
|
|
283
|
+
this.platform.debug(`Indoor Cam: ${this.accessory.displayName} StreamingStatus: ${value}`);
|
|
284
|
+
|
|
285
|
+
this.StreamingStatus = value;
|
|
286
|
+
this.doCameraUpdate.next();
|
|
287
|
+
}
|
|
288
|
+
|
|
289
|
+
/**
|
|
290
|
+
* Handle requests to set the value of the "On" characteristic
|
|
291
|
+
*/
|
|
292
|
+
SupportedVideoStreamConfigurationSet(value: CharacteristicValue) {
|
|
293
|
+
this.platform.debug(`Indoor Cam: ${this.accessory.displayName} SupportedVideoStreamConfiguration: ${value}`);
|
|
294
|
+
|
|
295
|
+
this.SupportedVideoStreamConfiguration = value;
|
|
296
|
+
this.doCameraUpdate.next();
|
|
297
|
+
}
|
|
230
298
|
}
|
package/src/devices/plugs.ts
CHANGED
|
@@ -190,7 +190,7 @@ export class Plug {
|
|
|
190
190
|
this.platform.log.error(`Plug: ${this.accessory.displayName} Device is offline.`);
|
|
191
191
|
break;
|
|
192
192
|
case 171:
|
|
193
|
-
this.platform.log.error(`Plug: ${this.accessory.displayName} Hub Device is offline
|
|
193
|
+
this.platform.log.error(`Plug: ${this.accessory.displayName} Hub Device is offline. Hub: ${this.device.hubDeviceId}`);
|
|
194
194
|
break;
|
|
195
195
|
case 190:
|
|
196
196
|
this.platform.log.error(`Plug: ${this.accessory.displayName} Device internal error due to device states not synchronized with server,`
|
|
@@ -379,7 +379,7 @@ export class AirConditioner {
|
|
|
379
379
|
this.platform.log.error(`Air Conditioner: ${this.accessory.displayName} Device is offline.`);
|
|
380
380
|
break;
|
|
381
381
|
case 171:
|
|
382
|
-
this.platform.log.error(`Air Conditioner: ${this.accessory.displayName} Hub Device is offline
|
|
382
|
+
this.platform.log.error(`Air Conditioner: ${this.accessory.displayName} Hub Device is offline. Hub: ${this.device.hubDeviceId}`);
|
|
383
383
|
break;
|
|
384
384
|
case 190:
|
|
385
385
|
this.platform.log.error(`Air Conditioner: ${this.accessory.displayName} Device internal error due to device states not synchronized`
|
|
@@ -239,7 +239,7 @@ export class AirPurifier {
|
|
|
239
239
|
this.platform.log.error(`Air Purifier: ${this.accessory.displayName} Device is offline.`);
|
|
240
240
|
break;
|
|
241
241
|
case 171:
|
|
242
|
-
this.platform.log.error(`Air Purifier: ${this.accessory.displayName} Hub Device is offline
|
|
242
|
+
this.platform.log.error(`Air Purifier: ${this.accessory.displayName} Hub Device is offline. Hub: ${this.device.hubDeviceId}`);
|
|
243
243
|
break;
|
|
244
244
|
case 190:
|
|
245
245
|
this.platform.log.error(`Air Purifier: ${this.accessory.displayName} Device internal error due to device states not synchronized`
|
package/src/irdevices/cameras.ts
CHANGED
|
@@ -139,7 +139,7 @@ export class Camera {
|
|
|
139
139
|
this.platform.log.error(`Camera: ${this.accessory.displayName} Device is offline.`);
|
|
140
140
|
break;
|
|
141
141
|
case 171:
|
|
142
|
-
this.platform.log.error(`Camera: ${this.accessory.displayName} Hub Device is offline
|
|
142
|
+
this.platform.log.error(`Camera: ${this.accessory.displayName} Hub Device is offline. Hub: ${this.device.hubDeviceId}`);
|
|
143
143
|
break;
|
|
144
144
|
case 190:
|
|
145
145
|
this.platform.log.error(`Camera: ${this.accessory.displayName} Device internal error due to device states not synchronized`
|
package/src/irdevices/fans.ts
CHANGED
|
@@ -261,7 +261,7 @@ export class Fan {
|
|
|
261
261
|
this.platform.log.error(`Fan: ${this.accessory.displayName} Device is offline.`);
|
|
262
262
|
break;
|
|
263
263
|
case 171:
|
|
264
|
-
this.platform.log.error(`Fan: ${this.accessory.displayName} Hub Device is offline
|
|
264
|
+
this.platform.log.error(`Fan: ${this.accessory.displayName} Hub Device is offline. Hub: ${this.device.hubDeviceId}`);
|
|
265
265
|
break;
|
|
266
266
|
case 190:
|
|
267
267
|
this.platform.log.error(`Fan: ${this.accessory.displayName} Device internal error due to device states not synchronized`
|
package/src/irdevices/lights.ts
CHANGED
|
@@ -173,7 +173,7 @@ export class Light {
|
|
|
173
173
|
this.platform.log.error(`Light: ${this.accessory.displayName} Device is offline.`);
|
|
174
174
|
break;
|
|
175
175
|
case 171:
|
|
176
|
-
this.platform.log.error(`Light: ${this.accessory.displayName} Hub Device is offline
|
|
176
|
+
this.platform.log.error(`Light: ${this.accessory.displayName} Hub Device is offline. Hub: ${this.device.hubDeviceId}`);
|
|
177
177
|
break;
|
|
178
178
|
case 190:
|
|
179
179
|
this.platform.log.error(`Light: ${this.accessory.displayName} Device internal error due to device states not synchronized`
|
package/src/irdevices/others.ts
CHANGED
|
@@ -160,7 +160,7 @@ export class Others {
|
|
|
160
160
|
this.platform.log.error(`Other: ${this.accessory.displayName} Device is offline.`);
|
|
161
161
|
break;
|
|
162
162
|
case 171:
|
|
163
|
-
this.platform.log.error(`Other: ${this.accessory.displayName} Hub Device is offline
|
|
163
|
+
this.platform.log.error(`Other: ${this.accessory.displayName} Hub Device is offline. Hub: ${this.device.hubDeviceId}`);
|
|
164
164
|
break;
|
|
165
165
|
case 190:
|
|
166
166
|
this.platform.log.error(`Other: ${this.accessory.displayName} Device internal error due to device states not synchronized`
|
package/src/irdevices/tvs.ts
CHANGED
|
@@ -377,7 +377,7 @@ export class TV {
|
|
|
377
377
|
this.platform.log.error(`${this.device.remoteType}: ${this.accessory.displayName} Device is offline.`);
|
|
378
378
|
break;
|
|
379
379
|
case 171:
|
|
380
|
-
this.platform.log.error(`${this.device.remoteType}: ${this.accessory.displayName} Hub Device is offline
|
|
380
|
+
this.platform.log.error(`${this.device.remoteType}: ${this.accessory.displayName} Hub Device is offline. Hub: ${this.device.hubDeviceId}`);
|
|
381
381
|
break;
|
|
382
382
|
case 190:
|
|
383
383
|
this.platform.log.error(`${this.device.remoteType}: `
|
|
@@ -139,7 +139,7 @@ export class VacuumCleaner {
|
|
|
139
139
|
this.platform.log.error(`Vacuum Cleaner: ${this.accessory.displayName} Device is offline.`);
|
|
140
140
|
break;
|
|
141
141
|
case 171:
|
|
142
|
-
this.platform.log.error(`Vacuum Cleaner: ${this.accessory.displayName} Hub Device is offline
|
|
142
|
+
this.platform.log.error(`Vacuum Cleaner: ${this.accessory.displayName} Hub Device is offline. Hub: ${this.device.hubDeviceId}`);
|
|
143
143
|
break;
|
|
144
144
|
case 190:
|
|
145
145
|
this.platform.log.error(`Vacuum Cleaner: ${this.accessory.displayName} Device internal error due to device states not synchronized`
|