@switchbot/homebridge-switchbot 1.4.0 → 1.4.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/CHANGELOG.md +18 -0
- package/config.schema.json +83 -11
- package/dist/devices/bots.d.ts +13 -3
- package/dist/devices/bots.d.ts.map +1 -1
- package/dist/devices/bots.js +162 -105
- package/dist/devices/bots.js.map +1 -1
- package/dist/devices/colorbulb.d.ts +13 -3
- package/dist/devices/colorbulb.d.ts.map +1 -1
- package/dist/devices/colorbulb.js +161 -96
- package/dist/devices/colorbulb.js.map +1 -1
- package/dist/devices/contact.d.ts +13 -3
- package/dist/devices/contact.d.ts.map +1 -1
- package/dist/devices/contact.js +117 -63
- package/dist/devices/contact.js.map +1 -1
- package/dist/devices/curtains.d.ts +14 -5
- package/dist/devices/curtains.d.ts.map +1 -1
- package/dist/devices/curtains.js +198 -140
- package/dist/devices/curtains.js.map +1 -1
- package/dist/devices/humidifiers.d.ts +13 -3
- package/dist/devices/humidifiers.d.ts.map +1 -1
- package/dist/devices/humidifiers.js +180 -127
- package/dist/devices/humidifiers.js.map +1 -1
- package/dist/devices/meters.d.ts +13 -3
- package/dist/devices/meters.d.ts.map +1 -1
- package/dist/devices/meters.js +121 -63
- package/dist/devices/meters.js.map +1 -1
- package/dist/devices/motion.d.ts +13 -3
- package/dist/devices/motion.d.ts.map +1 -1
- package/dist/devices/motion.js +104 -45
- package/dist/devices/motion.js.map +1 -1
- package/dist/devices/plugs.d.ts +13 -3
- package/dist/devices/plugs.d.ts.map +1 -1
- package/dist/devices/plugs.js +99 -35
- package/dist/devices/plugs.js.map +1 -1
- package/dist/irdevices/airconditioners.d.ts +11 -3
- package/dist/irdevices/airconditioners.d.ts.map +1 -1
- package/dist/irdevices/airconditioners.js +80 -45
- package/dist/irdevices/airconditioners.js.map +1 -1
- package/dist/irdevices/airpurifiers.d.ts +11 -3
- package/dist/irdevices/airpurifiers.d.ts.map +1 -1
- package/dist/irdevices/airpurifiers.js +68 -31
- package/dist/irdevices/airpurifiers.js.map +1 -1
- package/dist/irdevices/cameras.d.ts +11 -3
- package/dist/irdevices/cameras.d.ts.map +1 -1
- package/dist/irdevices/cameras.js +64 -24
- package/dist/irdevices/cameras.js.map +1 -1
- package/dist/irdevices/fans.d.ts +11 -3
- package/dist/irdevices/fans.d.ts.map +1 -1
- package/dist/irdevices/fans.js +74 -35
- package/dist/irdevices/fans.js.map +1 -1
- package/dist/irdevices/lights.d.ts +11 -3
- package/dist/irdevices/lights.d.ts.map +1 -1
- package/dist/irdevices/lights.js +65 -25
- package/dist/irdevices/lights.js.map +1 -1
- package/dist/irdevices/others.d.ts +11 -3
- package/dist/irdevices/others.d.ts.map +1 -1
- package/dist/irdevices/others.js +71 -31
- package/dist/irdevices/others.js.map +1 -1
- package/dist/irdevices/tvs.d.ts +11 -3
- package/dist/irdevices/tvs.d.ts.map +1 -1
- package/dist/irdevices/tvs.js +81 -42
- package/dist/irdevices/tvs.js.map +1 -1
- package/dist/irdevices/vacuumcleaners.d.ts +11 -3
- package/dist/irdevices/vacuumcleaners.d.ts.map +1 -1
- package/dist/irdevices/vacuumcleaners.js +64 -24
- package/dist/irdevices/vacuumcleaners.js.map +1 -1
- package/dist/irdevices/waterheaters.d.ts +11 -3
- package/dist/irdevices/waterheaters.d.ts.map +1 -1
- package/dist/irdevices/waterheaters.js +64 -24
- package/dist/irdevices/waterheaters.js.map +1 -1
- package/dist/platform.d.ts +10 -10
- package/dist/platform.d.ts.map +1 -1
- package/dist/platform.js +290 -307
- package/dist/platform.js.map +1 -1
- package/dist/settings.d.ts +4 -1
- package/dist/settings.d.ts.map +1 -1
- package/dist/settings.js.map +1 -1
- package/nodemon.json +1 -1
- package/package.json +70 -66
- package/src/devices/bots.ts +169 -105
- package/src/devices/colorbulb.ts +170 -99
- package/src/devices/contact.ts +124 -64
- package/src/devices/curtains.ts +207 -145
- package/src/devices/humidifiers.ts +187 -129
- package/src/devices/meters.ts +128 -64
- package/src/devices/motion.ts +110 -45
- package/src/devices/plugs.ts +104 -36
- package/src/irdevices/airconditioners.ts +85 -45
- package/src/irdevices/airpurifiers.ts +73 -31
- package/src/irdevices/cameras.ts +69 -24
- package/src/irdevices/fans.ts +79 -36
- package/src/irdevices/lights.ts +70 -25
- package/src/irdevices/others.ts +76 -31
- package/src/irdevices/tvs.ts +86 -42
- package/src/irdevices/vacuumcleaners.ts +69 -24
- package/src/irdevices/waterheaters.ts +69 -24
- package/src/platform.ts +285 -302
- package/src/settings.ts +4 -1
- package/dist/devices/indoorcam.d.ts +0 -64
- package/dist/devices/indoorcam.d.ts.map +0 -1
- package/dist/devices/indoorcam.js +0 -249
- package/dist/devices/indoorcam.js.map +0 -1
- package/src/devices/indoorcam.ts +0 -309
package/src/settings.ts
CHANGED
|
@@ -32,7 +32,7 @@ export type credentials = {
|
|
|
32
32
|
export type options = {
|
|
33
33
|
refreshRate?: number;
|
|
34
34
|
pushRate?: number;
|
|
35
|
-
|
|
35
|
+
logging?: string;
|
|
36
36
|
devices?: Array<devicesConfig>;
|
|
37
37
|
irdevices?: Array<irDevicesConfig>;
|
|
38
38
|
};
|
|
@@ -41,6 +41,8 @@ export interface devicesConfig extends device {
|
|
|
41
41
|
configDeviceType: string;
|
|
42
42
|
configDeviceName?: string;
|
|
43
43
|
deviceId: string;
|
|
44
|
+
logging?: string;
|
|
45
|
+
refreshRate?: number;
|
|
44
46
|
bot?: bot;
|
|
45
47
|
meter?: meter;
|
|
46
48
|
humidifier?: humidifier;
|
|
@@ -91,6 +93,7 @@ export type colorbulb = {
|
|
|
91
93
|
export interface irDevicesConfig extends irdevice {
|
|
92
94
|
configRemoteType?: string;
|
|
93
95
|
deviceId: string;
|
|
96
|
+
logging?: string;
|
|
94
97
|
irfan?: irfan;
|
|
95
98
|
irair?: irair;
|
|
96
99
|
irtv?: irtv;
|
|
@@ -1,64 +0,0 @@
|
|
|
1
|
-
import { Subject } from 'rxjs';
|
|
2
|
-
import { SwitchBotPlatform } from '../platform';
|
|
3
|
-
import { PlatformAccessory, CharacteristicValue } from 'homebridge';
|
|
4
|
-
import { device, devicesConfig, deviceStatusResponse } from '../settings';
|
|
5
|
-
export declare class IndoorCam {
|
|
6
|
-
private readonly platform;
|
|
7
|
-
private accessory;
|
|
8
|
-
device: device & devicesConfig;
|
|
9
|
-
private service;
|
|
10
|
-
Active: CharacteristicValue;
|
|
11
|
-
SetupEndpoints: CharacteristicValue;
|
|
12
|
-
StreamingStatus: CharacteristicValue;
|
|
13
|
-
SupportedRTPConfiguration: CharacteristicValue;
|
|
14
|
-
SelectedRTPStreamConfiguration: CharacteristicValue;
|
|
15
|
-
SupportedVideoStreamConfiguration: CharacteristicValue;
|
|
16
|
-
SupportedAudioStreamConfiguration: CharacteristicValue;
|
|
17
|
-
deviceStatus: deviceStatusResponse;
|
|
18
|
-
private readonly deviceDebug;
|
|
19
|
-
private readonly debugDebug;
|
|
20
|
-
cameraUpdateInProgress: boolean;
|
|
21
|
-
doCameraUpdate: Subject<void>;
|
|
22
|
-
constructor(platform: SwitchBotPlatform, accessory: PlatformAccessory, device: device & devicesConfig);
|
|
23
|
-
parseStatus(): void;
|
|
24
|
-
private refreshStatus;
|
|
25
|
-
/**
|
|
26
|
-
* Pushes the requested changes to the SwitchBot API
|
|
27
|
-
* deviceType commandType Command command parameter Description
|
|
28
|
-
* Camera - "command" "turnOff" "default" = set to OFF state
|
|
29
|
-
* Camera - "command" "turnOn" "default" = set to ON state
|
|
30
|
-
*/
|
|
31
|
-
pushChanges(): Promise<void>;
|
|
32
|
-
updateHomeKitCharacteristics(): void;
|
|
33
|
-
apiError(e: any): void;
|
|
34
|
-
private statusCode;
|
|
35
|
-
/**
|
|
36
|
-
* Handle requests to set the value of the "Active" characteristic
|
|
37
|
-
*/
|
|
38
|
-
ActiveSet(value: CharacteristicValue): void;
|
|
39
|
-
/**
|
|
40
|
-
* Handle requests to set the value of the "SelectedRTPStreamConfiguration" characteristic
|
|
41
|
-
*/
|
|
42
|
-
SelectedRTPStreamConfigurationSet(value: CharacteristicValue): void;
|
|
43
|
-
/**
|
|
44
|
-
* Handle requests to set the value of the "On" characteristic
|
|
45
|
-
*/
|
|
46
|
-
SetupEndpointsSet(value: CharacteristicValue): void;
|
|
47
|
-
/**
|
|
48
|
-
* Handle requests to set the value of the "On" characteristic
|
|
49
|
-
*/
|
|
50
|
-
SupportedAudioStreamConfigurationSet(value: CharacteristicValue): void;
|
|
51
|
-
/**
|
|
52
|
-
* Handle requests to set the value of the "On" characteristic
|
|
53
|
-
*/
|
|
54
|
-
SupportedRTPConfigurationSet(value: CharacteristicValue): void;
|
|
55
|
-
/**
|
|
56
|
-
* Handle requests to set the value of the "On" characteristic
|
|
57
|
-
*/
|
|
58
|
-
StreamingStatusSet(value: CharacteristicValue): void;
|
|
59
|
-
/**
|
|
60
|
-
* Handle requests to set the value of the "On" characteristic
|
|
61
|
-
*/
|
|
62
|
-
SupportedVideoStreamConfigurationSet(value: CharacteristicValue): void;
|
|
63
|
-
}
|
|
64
|
-
//# sourceMappingURL=indoorcam.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"indoorcam.d.ts","sourceRoot":"","sources":["../../src/devices/indoorcam.ts"],"names":[],"mappings":"AACA,OAAO,EAAY,OAAO,EAAE,MAAM,MAAM,CAAC;AACzC,OAAO,EAAE,iBAAiB,EAAE,MAAM,aAAa,CAAC;AAEhD,OAAO,EAAW,iBAAiB,EAAE,mBAAmB,EAAE,MAAM,YAAY,CAAC;AAC7E,OAAO,EAAa,MAAM,EAAE,aAAa,EAAE,oBAAoB,EAAW,MAAM,aAAa,CAAC;AAE9F,qBAAa,SAAS;IAyBlB,OAAO,CAAC,QAAQ,CAAC,QAAQ;IACzB,OAAO,CAAC,SAAS;IACV,MAAM,EAAE,MAAM,GAAG,aAAa;IAzBvC,OAAO,CAAC,OAAO,CAAU;IAGzB,MAAM,EAAG,mBAAmB,CAAC;IAC7B,cAAc,EAAG,mBAAmB,CAAC;IACrC,eAAe,EAAG,mBAAmB,CAAC;IACtC,yBAAyB,EAAG,mBAAmB,CAAC;IAChD,8BAA8B,EAAG,mBAAmB,CAAC;IACrD,iCAAiC,EAAG,mBAAmB,CAAC;IACxD,iCAAiC,EAAG,mBAAmB,CAAC;IAGxD,YAAY,EAAG,oBAAoB,CAAC;IAGpC,OAAO,CAAC,QAAQ,CAAC,WAAW,CAA+E;IAC3G,OAAO,CAAC,QAAQ,CAAC,UAAU,CAA8E;IAGzG,sBAAsB,EAAG,OAAO,CAAC;IACjC,cAAc,EAAG,OAAO,CAAC,IAAI,CAAC,CAAC;gBAGZ,QAAQ,EAAE,iBAAiB,EACpC,SAAS,EAAE,iBAAiB,EAC7B,MAAM,EAAE,MAAM,GAAG,aAAa;IAoGvC,WAAW;YAKG,aAAa;IAoB3B;;;;;KAKC;IACK,WAAW;IA0BjB,4BAA4B;IASrB,QAAQ,CAAC,CAAC,EAAE,GAAG;IAItB,OAAO,CAAC,UAAU;IAmClB;;OAEG;IACH,SAAS,CAAC,KAAK,EAAE,mBAAmB;IAOpC;;OAEG;IACH,iCAAiC,CAAC,KAAK,EAAE,mBAAmB;IAO5D;;OAEG;IACH,iBAAiB,CAAC,KAAK,EAAE,mBAAmB;IAO5C;;OAEG;IACH,oCAAoC,CAAC,KAAK,EAAE,mBAAmB;IAO/D;;OAEG;IACH,4BAA4B,CAAC,KAAK,EAAE,mBAAmB;IAOvD;;OAEG;IACH,kBAAkB,CAAC,KAAK,EAAE,mBAAmB;IAO7C;;OAEG;IACH,oCAAoC,CAAC,KAAK,EAAE,mBAAmB;CAMhE"}
|
|
@@ -1,249 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.IndoorCam = void 0;
|
|
4
|
-
const rxjs_1 = require("rxjs");
|
|
5
|
-
const operators_1 = require("rxjs/operators");
|
|
6
|
-
const settings_1 = require("../settings");
|
|
7
|
-
class IndoorCam {
|
|
8
|
-
constructor(platform, accessory, device) {
|
|
9
|
-
this.platform = platform;
|
|
10
|
-
this.accessory = accessory;
|
|
11
|
-
this.device = device;
|
|
12
|
-
// Config
|
|
13
|
-
this.deviceDebug = this.platform.config.options?.debug === 'device' || this.platform.debugMode;
|
|
14
|
-
this.debugDebug = this.platform.config.options?.debug === 'debug' || this.platform.debugMode;
|
|
15
|
-
// Indoor Cam Config
|
|
16
|
-
this.platform.device(`Indoor Cam: ${this.accessory.displayName} Config: (hide_device: ${device.hide_device})`);
|
|
17
|
-
this.platform.log.error(`Indoor Cam: ${this.accessory.displayName} was added but will not work as OpenAPI doesn't support it yet.`);
|
|
18
|
-
// default placeholders
|
|
19
|
-
this.SelectedRTPStreamConfiguration;
|
|
20
|
-
// this is subject we use to track when we need to POST changes to the SwitchBot API
|
|
21
|
-
this.doCameraUpdate = new rxjs_1.Subject();
|
|
22
|
-
this.cameraUpdateInProgress = false;
|
|
23
|
-
// Retrieve initial values and updateHomekit
|
|
24
|
-
this.refreshStatus();
|
|
25
|
-
// set accessory information
|
|
26
|
-
accessory
|
|
27
|
-
.getService(this.platform.Service.AccessoryInformation)
|
|
28
|
-
.setCharacteristic(this.platform.Characteristic.Manufacturer, 'SwitchBot')
|
|
29
|
-
.setCharacteristic(this.platform.Characteristic.Model, 'SWITCHBOT-CAMERA-')
|
|
30
|
-
.setCharacteristic(this.platform.Characteristic.SerialNumber, device.deviceId);
|
|
31
|
-
// get the WindowCovering service if it exists, otherwise create a new WindowCovering service
|
|
32
|
-
// you can create multiple services for each accessory
|
|
33
|
-
(this.service =
|
|
34
|
-
accessory.getService(this.platform.Service.CameraRTPStreamManagement) ||
|
|
35
|
-
accessory.addService(this.platform.Service.CameraRTPStreamManagement)), `${accessory.displayName} Indoor Camera`;
|
|
36
|
-
// To avoid "Cannot add a Service with the same UUID another Service without also defining a unique 'subtype' property." error,
|
|
37
|
-
// when creating multiple services of the same type, you need to use the following syntax to specify a name and subtype id:
|
|
38
|
-
// accessory.getService('NAME') ?? accessory.addService(this.platform.Service.Lightbulb, 'NAME', 'USER_DEFINED_SUBTYPE');
|
|
39
|
-
// set the service name, this is what is displayed as the default name on the Home app
|
|
40
|
-
// in this example we are using the name we stored in the `accessory.context` in the `discoverDevices` method.
|
|
41
|
-
this.service.setCharacteristic(this.platform.Characteristic.Name, accessory.displayName);
|
|
42
|
-
// each service must implement at-minimum the "required characteristics" for the given service type
|
|
43
|
-
// see https://developers.homebridge.io/#/service/WindowCovering
|
|
44
|
-
// create handlers for required characteristics
|
|
45
|
-
this.service.getCharacteristic(this.platform.Characteristic.Active)
|
|
46
|
-
.onSet(this.ActiveSet.bind(this));
|
|
47
|
-
this.service.getCharacteristic(this.platform.Characteristic.SelectedRTPStreamConfiguration)
|
|
48
|
-
.onSet(this.SelectedRTPStreamConfigurationSet.bind(this));
|
|
49
|
-
this.service.getCharacteristic(this.platform.Characteristic.SetupEndpoints)
|
|
50
|
-
.onSet(this.SetupEndpointsSet.bind(this));
|
|
51
|
-
this.service.getCharacteristic(this.platform.Characteristic.StreamingStatus)
|
|
52
|
-
.onSet(this.StreamingStatusSet.bind(this));
|
|
53
|
-
this.service.getCharacteristic(this.platform.Characteristic.SupportedAudioStreamConfiguration)
|
|
54
|
-
.onSet(this.SupportedAudioStreamConfigurationSet.bind(this));
|
|
55
|
-
this.service.getCharacteristic(this.platform.Characteristic.SupportedRTPConfiguration)
|
|
56
|
-
.onSet(this.SupportedRTPConfigurationSet.bind(this));
|
|
57
|
-
this.service.getCharacteristic(this.platform.Characteristic.SupportedVideoStreamConfiguration)
|
|
58
|
-
.onSet(this.SupportedVideoStreamConfigurationSet.bind(this));
|
|
59
|
-
// Update Homekit
|
|
60
|
-
this.updateHomeKitCharacteristics();
|
|
61
|
-
// Start an update interval
|
|
62
|
-
(0, rxjs_1.interval)(this.platform.config.options.refreshRate * 1000)
|
|
63
|
-
.pipe((0, operators_1.skipWhile)(() => this.cameraUpdateInProgress))
|
|
64
|
-
.subscribe(() => {
|
|
65
|
-
this.refreshStatus();
|
|
66
|
-
});
|
|
67
|
-
// Watch for Camera change events
|
|
68
|
-
// We put in a debounce of 100ms so we don't make duplicate calls
|
|
69
|
-
this.doCameraUpdate
|
|
70
|
-
.pipe((0, operators_1.tap)(() => {
|
|
71
|
-
this.cameraUpdateInProgress = true;
|
|
72
|
-
}), (0, operators_1.debounceTime)(this.platform.config.options.pushRate * 1000))
|
|
73
|
-
.subscribe(async () => {
|
|
74
|
-
try {
|
|
75
|
-
await this.pushChanges();
|
|
76
|
-
}
|
|
77
|
-
catch (e) {
|
|
78
|
-
this.platform.log.error(`Indoor Cam: ${this.accessory.displayName} failed pushChanges`);
|
|
79
|
-
if (this.deviceDebug) {
|
|
80
|
-
this.platform.log.error(`Indoor Cam: ${this.accessory.displayName} failed pushChanges,`
|
|
81
|
-
+ ` Error Message: ${JSON.stringify(e.message)}`);
|
|
82
|
-
}
|
|
83
|
-
if (this.debugDebug) {
|
|
84
|
-
this.platform.log.error(`Indoor Cam: ${this.accessory.displayName} failed pushChanges,`
|
|
85
|
-
+ ` Error: ${JSON.stringify(e)}`);
|
|
86
|
-
}
|
|
87
|
-
this.apiError(e);
|
|
88
|
-
}
|
|
89
|
-
this.cameraUpdateInProgress = false;
|
|
90
|
-
});
|
|
91
|
-
}
|
|
92
|
-
parseStatus() {
|
|
93
|
-
this.platform.debug(`Indoor Cam ${this.accessory.displayName} SelectedRTPStreamConfiguration: ${this.SelectedRTPStreamConfiguration}`);
|
|
94
|
-
}
|
|
95
|
-
async refreshStatus() {
|
|
96
|
-
try {
|
|
97
|
-
this.deviceStatus = (await this.platform.axios.get(`${settings_1.DeviceURL}/${this.device.deviceId}/status`)).data;
|
|
98
|
-
this.platform.device(`Indoor Cam: ${this.accessory.displayName} refreshStatus: ${JSON.stringify(this.deviceStatus)}`);
|
|
99
|
-
this.parseStatus();
|
|
100
|
-
this.updateHomeKitCharacteristics();
|
|
101
|
-
}
|
|
102
|
-
catch (e) {
|
|
103
|
-
this.platform.log.error(`Indoor Cam: ${this.accessory.displayName} failed refreshStatus with BLE Connection`);
|
|
104
|
-
if (this.deviceDebug) {
|
|
105
|
-
this.platform.log.error(`Indoor Cam: ${this.accessory.displayName} failed refreshStatus with BLE Connection,`
|
|
106
|
-
+ ` Error Message: ${JSON.stringify(e.message)}`);
|
|
107
|
-
}
|
|
108
|
-
if (this.debugDebug) {
|
|
109
|
-
this.platform.log.error(`Indoor Cam: ${this.accessory.displayName} failed refreshStatus with BLE Connection,`
|
|
110
|
-
+ ` Error: ${JSON.stringify(e)}`);
|
|
111
|
-
}
|
|
112
|
-
this.apiError(e);
|
|
113
|
-
}
|
|
114
|
-
}
|
|
115
|
-
/**
|
|
116
|
-
* Pushes the requested changes to the SwitchBot API
|
|
117
|
-
* deviceType commandType Command command parameter Description
|
|
118
|
-
* Camera - "command" "turnOff" "default" = set to OFF state
|
|
119
|
-
* Camera - "command" "turnOn" "default" = set to ON state
|
|
120
|
-
*/
|
|
121
|
-
async pushChanges() {
|
|
122
|
-
if (!this.Active) {
|
|
123
|
-
const payload = {
|
|
124
|
-
commandType: 'command',
|
|
125
|
-
parameter: 'default',
|
|
126
|
-
command: 'turnOn',
|
|
127
|
-
};
|
|
128
|
-
this.platform.log.info(`Indoor Cam: ${this.accessory.displayName} Sending request to SwitchBot API. command: ${payload.command},`
|
|
129
|
-
+ ` parameter: ${payload.parameter}, commandType: ${payload.commandType}`);
|
|
130
|
-
// Make the API request
|
|
131
|
-
const push = await this.platform.axios.post(`${settings_1.DeviceURL}/${this.device.deviceId}/commands`, payload);
|
|
132
|
-
this.platform.debug(`Indoor Cam: ${this.accessory.displayName} pushChanges: ${JSON.stringify(push.data)}`);
|
|
133
|
-
this.statusCode(push);
|
|
134
|
-
(0, rxjs_1.interval)(5000)
|
|
135
|
-
.pipe((0, operators_1.skipWhile)(() => this.cameraUpdateInProgress))
|
|
136
|
-
.pipe((0, operators_1.take)(1))
|
|
137
|
-
.subscribe(() => {
|
|
138
|
-
this.refreshStatus();
|
|
139
|
-
});
|
|
140
|
-
}
|
|
141
|
-
else {
|
|
142
|
-
this.platform.device(`Indoor Cam: ${this.accessory.displayName} No pushChanges. Active: ${this.Active}`);
|
|
143
|
-
}
|
|
144
|
-
}
|
|
145
|
-
updateHomeKitCharacteristics() {
|
|
146
|
-
if (this.SelectedRTPStreamConfiguration === undefined) {
|
|
147
|
-
this.platform.debug(`Indoor Cam: ${this.accessory.displayName} On: ${this.SelectedRTPStreamConfiguration}`);
|
|
148
|
-
}
|
|
149
|
-
else {
|
|
150
|
-
this.service.updateCharacteristic(this.platform.Characteristic.SelectedRTPStreamConfiguration, this.SelectedRTPStreamConfiguration);
|
|
151
|
-
this.platform.device(`Indoor Cam: ${this.accessory.displayName} updateCharacteristic On: ${this.SelectedRTPStreamConfiguration}`);
|
|
152
|
-
}
|
|
153
|
-
}
|
|
154
|
-
apiError(e) {
|
|
155
|
-
this.service.updateCharacteristic(this.platform.Characteristic.SelectedRTPStreamConfiguration, e);
|
|
156
|
-
}
|
|
157
|
-
statusCode(push) {
|
|
158
|
-
switch (push.data.statusCode) {
|
|
159
|
-
case 151:
|
|
160
|
-
this.platform.log.error(`Indoor Cam: ${this.accessory.displayName} Command not supported by this device type.`);
|
|
161
|
-
break;
|
|
162
|
-
case 152:
|
|
163
|
-
this.platform.log.error(`Indoor Cam: ${this.accessory.displayName} Device not found.`);
|
|
164
|
-
break;
|
|
165
|
-
case 160:
|
|
166
|
-
this.platform.log.error(`Indoor Cam: ${this.accessory.displayName} Command is not supported.`);
|
|
167
|
-
break;
|
|
168
|
-
case 161:
|
|
169
|
-
this.platform.log.error(`Indoor Cam: ${this.accessory.displayName} Device is offline.`);
|
|
170
|
-
if (this.device.offline) {
|
|
171
|
-
this.Active = false;
|
|
172
|
-
}
|
|
173
|
-
break;
|
|
174
|
-
case 171:
|
|
175
|
-
this.platform.log.error(`Indoor Cam: ${this.accessory.displayName} Hub Device is offline. Hub: ${this.device.hubDeviceId}`);
|
|
176
|
-
if (this.device.offline) {
|
|
177
|
-
this.Active = false;
|
|
178
|
-
}
|
|
179
|
-
break;
|
|
180
|
-
case 190:
|
|
181
|
-
this.platform.log.error(`Indoor Cam: ${this.accessory.displayName} Device internal error due to device states not synchronized with server,`
|
|
182
|
-
+ ` Or command: ${JSON.stringify(push.data)} format is invalid`);
|
|
183
|
-
break;
|
|
184
|
-
case 100:
|
|
185
|
-
this.platform.debug(`Indoor Cam: ${this.accessory.displayName} Command successfully sent.`);
|
|
186
|
-
break;
|
|
187
|
-
default:
|
|
188
|
-
this.platform.debug(`Indoor Cam: ${this.accessory.displayName} Unknown statusCode.`);
|
|
189
|
-
}
|
|
190
|
-
}
|
|
191
|
-
/**
|
|
192
|
-
* Handle requests to set the value of the "Active" characteristic
|
|
193
|
-
*/
|
|
194
|
-
ActiveSet(value) {
|
|
195
|
-
this.platform.debug(`Indoor Cam: ${this.accessory.displayName} Active: ${value}`);
|
|
196
|
-
this.Active = value;
|
|
197
|
-
this.doCameraUpdate.next();
|
|
198
|
-
}
|
|
199
|
-
/**
|
|
200
|
-
* Handle requests to set the value of the "SelectedRTPStreamConfiguration" characteristic
|
|
201
|
-
*/
|
|
202
|
-
SelectedRTPStreamConfigurationSet(value) {
|
|
203
|
-
this.platform.debug(`Indoor Cam: ${this.accessory.displayName} SelectedRTPStreamConfiguration: ${value}`);
|
|
204
|
-
this.SelectedRTPStreamConfiguration = value;
|
|
205
|
-
this.doCameraUpdate.next();
|
|
206
|
-
}
|
|
207
|
-
/**
|
|
208
|
-
* Handle requests to set the value of the "On" characteristic
|
|
209
|
-
*/
|
|
210
|
-
SetupEndpointsSet(value) {
|
|
211
|
-
this.platform.debug(`Indoor Cam: ${this.accessory.displayName} SetupEndpoints: ${value}`);
|
|
212
|
-
this.SetupEndpoints = value;
|
|
213
|
-
this.doCameraUpdate.next();
|
|
214
|
-
}
|
|
215
|
-
/**
|
|
216
|
-
* Handle requests to set the value of the "On" characteristic
|
|
217
|
-
*/
|
|
218
|
-
SupportedAudioStreamConfigurationSet(value) {
|
|
219
|
-
this.platform.debug(`Indoor Cam: ${this.accessory.displayName} SupportedAudioStreamConfiguration: ${value}`);
|
|
220
|
-
this.SupportedAudioStreamConfiguration = value;
|
|
221
|
-
this.doCameraUpdate.next();
|
|
222
|
-
}
|
|
223
|
-
/**
|
|
224
|
-
* Handle requests to set the value of the "On" characteristic
|
|
225
|
-
*/
|
|
226
|
-
SupportedRTPConfigurationSet(value) {
|
|
227
|
-
this.platform.debug(`Indoor Cam: ${this.accessory.displayName} SupportedRTPConfiguration: ${value}`);
|
|
228
|
-
this.SupportedRTPConfiguration = value;
|
|
229
|
-
this.doCameraUpdate.next();
|
|
230
|
-
}
|
|
231
|
-
/**
|
|
232
|
-
* Handle requests to set the value of the "On" characteristic
|
|
233
|
-
*/
|
|
234
|
-
StreamingStatusSet(value) {
|
|
235
|
-
this.platform.debug(`Indoor Cam: ${this.accessory.displayName} StreamingStatus: ${value}`);
|
|
236
|
-
this.StreamingStatus = value;
|
|
237
|
-
this.doCameraUpdate.next();
|
|
238
|
-
}
|
|
239
|
-
/**
|
|
240
|
-
* Handle requests to set the value of the "On" characteristic
|
|
241
|
-
*/
|
|
242
|
-
SupportedVideoStreamConfigurationSet(value) {
|
|
243
|
-
this.platform.debug(`Indoor Cam: ${this.accessory.displayName} SupportedVideoStreamConfiguration: ${value}`);
|
|
244
|
-
this.SupportedVideoStreamConfiguration = value;
|
|
245
|
-
this.doCameraUpdate.next();
|
|
246
|
-
}
|
|
247
|
-
}
|
|
248
|
-
exports.IndoorCam = IndoorCam;
|
|
249
|
-
//# sourceMappingURL=indoorcam.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"indoorcam.js","sourceRoot":"","sources":["../../src/devices/indoorcam.ts"],"names":[],"mappings":";;;AACA,+BAAyC;AAEzC,8CAAoE;AAEpE,0CAA8F;AAE9F,MAAa,SAAS;IAwBpB,YACmB,QAA2B,EACpC,SAA4B,EAC7B,MAA8B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AI,CAAC,iCAAiC,GAAG,KAAK,CAAC;QAC/C,IAAI,CAAC,cAAc,CAAC,IAAI,EAAE,CAAC;IAC7B,CAAC;IAED;;OAEG;IACH,4BAA4B,CAAC,KAA0B;QACrD,IAAI,CAAC,QAAQ,CAAC,KAAK,CAAC,eAAe,IAAI,CAAC,SAAS,CAAC,WAAW,+BAA+B,KAAK,EAAE,CAAC,CAAC;QAErG,IAAI,CAAC,yBAAyB,GAAG,KAAK,CAAC;QACvC,IAAI,CAAC,cAAc,CAAC,IAAI,EAAE,CAAC;IAC7B,CAAC;IAED;;OAEG;IACH,kBAAkB,CAAC,KAA0B;QAC3C,IAAI,CAAC,QAAQ,CAAC,KAAK,CAAC,eAAe,IAAI,CAAC,SAAS,CAAC,WAAW,qBAAqB,KAAK,EAAE,CAAC,CAAC;QAE3F,IAAI,CAAC,eAAe,GAAG,KAAK,CAAC;QAC7B,IAAI,CAAC,cAAc,CAAC,IAAI,EAAE,CAAC;IAC7B,CAAC;IAED;;OAEG;IACH,oCAAoC,CAAC,KAA0B;QAC7D,IAAI,CAAC,QAAQ,CAAC,KAAK,CAAC,eAAe,IAAI,CAAC,SAAS,CAAC,WAAW,uCAAuC,KAAK,EAAE,CAAC,CAAC;QAE7G,IAAI,CAAC,iCAAiC,GAAG,KAAK,CAAC;QAC/C,IAAI,CAAC,cAAc,CAAC,IAAI,EAAE,CAAC;IAC7B,CAAC;CACF;AA7SD,8BA6SC"}
|
package/src/devices/indoorcam.ts
DELETED
|
@@ -1,309 +0,0 @@
|
|
|
1
|
-
import { AxiosResponse } from 'axios';
|
|
2
|
-
import { interval, Subject } from 'rxjs';
|
|
3
|
-
import { SwitchBotPlatform } from '../platform';
|
|
4
|
-
import { debounceTime, skipWhile, take, tap } from 'rxjs/operators';
|
|
5
|
-
import { Service, PlatformAccessory, CharacteristicValue } from 'homebridge';
|
|
6
|
-
import { DeviceURL, device, devicesConfig, deviceStatusResponse, payload } from '../settings';
|
|
7
|
-
|
|
8
|
-
export class IndoorCam {
|
|
9
|
-
// Services
|
|
10
|
-
private service: Service;
|
|
11
|
-
|
|
12
|
-
// Characteristic Values
|
|
13
|
-
Active!: CharacteristicValue;
|
|
14
|
-
SetupEndpoints!: CharacteristicValue;
|
|
15
|
-
StreamingStatus!: CharacteristicValue;
|
|
16
|
-
SupportedRTPConfiguration!: CharacteristicValue;
|
|
17
|
-
SelectedRTPStreamConfiguration!: CharacteristicValue;
|
|
18
|
-
SupportedVideoStreamConfiguration!: CharacteristicValue;
|
|
19
|
-
SupportedAudioStreamConfiguration!: CharacteristicValue;
|
|
20
|
-
|
|
21
|
-
// OpenAPI Others
|
|
22
|
-
deviceStatus!: deviceStatusResponse;
|
|
23
|
-
|
|
24
|
-
// Config
|
|
25
|
-
private readonly deviceDebug = this.platform.config.options?.debug === 'device' || this.platform.debugMode;
|
|
26
|
-
private readonly debugDebug = this.platform.config.options?.debug === 'debug' || this.platform.debugMode;
|
|
27
|
-
|
|
28
|
-
// Updates
|
|
29
|
-
cameraUpdateInProgress!: boolean;
|
|
30
|
-
doCameraUpdate!: Subject<void>;
|
|
31
|
-
|
|
32
|
-
constructor(
|
|
33
|
-
private readonly platform: SwitchBotPlatform,
|
|
34
|
-
private accessory: PlatformAccessory,
|
|
35
|
-
public device: device & devicesConfig,
|
|
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.`);
|
|
41
|
-
// default placeholders
|
|
42
|
-
this.SelectedRTPStreamConfiguration;
|
|
43
|
-
|
|
44
|
-
// this is subject we use to track when we need to POST changes to the SwitchBot API
|
|
45
|
-
this.doCameraUpdate = new Subject();
|
|
46
|
-
this.cameraUpdateInProgress = false;
|
|
47
|
-
|
|
48
|
-
// Retrieve initial values and updateHomekit
|
|
49
|
-
this.refreshStatus();
|
|
50
|
-
|
|
51
|
-
// set accessory information
|
|
52
|
-
accessory
|
|
53
|
-
.getService(this.platform.Service.AccessoryInformation)!
|
|
54
|
-
.setCharacteristic(this.platform.Characteristic.Manufacturer, 'SwitchBot')
|
|
55
|
-
.setCharacteristic(this.platform.Characteristic.Model, 'SWITCHBOT-CAMERA-')
|
|
56
|
-
.setCharacteristic(this.platform.Characteristic.SerialNumber, device.deviceId!);
|
|
57
|
-
|
|
58
|
-
// get the WindowCovering service if it exists, otherwise create a new WindowCovering service
|
|
59
|
-
// you can create multiple services for each accessory
|
|
60
|
-
(this.service =
|
|
61
|
-
accessory.getService(this.platform.Service.CameraRTPStreamManagement) ||
|
|
62
|
-
accessory.addService(this.platform.Service.CameraRTPStreamManagement)), `${accessory.displayName} Indoor Camera`;
|
|
63
|
-
|
|
64
|
-
// To avoid "Cannot add a Service with the same UUID another Service without also defining a unique 'subtype' property." error,
|
|
65
|
-
// when creating multiple services of the same type, you need to use the following syntax to specify a name and subtype id:
|
|
66
|
-
// accessory.getService('NAME') ?? accessory.addService(this.platform.Service.Lightbulb, 'NAME', 'USER_DEFINED_SUBTYPE');
|
|
67
|
-
|
|
68
|
-
// set the service name, this is what is displayed as the default name on the Home app
|
|
69
|
-
// in this example we are using the name we stored in the `accessory.context` in the `discoverDevices` method.
|
|
70
|
-
this.service.setCharacteristic(this.platform.Characteristic.Name, accessory.displayName);
|
|
71
|
-
|
|
72
|
-
// each service must implement at-minimum the "required characteristics" for the given service type
|
|
73
|
-
// see https://developers.homebridge.io/#/service/WindowCovering
|
|
74
|
-
|
|
75
|
-
// create handlers for required characteristics
|
|
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));
|
|
87
|
-
|
|
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));
|
|
96
|
-
|
|
97
|
-
// Update Homekit
|
|
98
|
-
this.updateHomeKitCharacteristics();
|
|
99
|
-
|
|
100
|
-
// Start an update interval
|
|
101
|
-
interval(this.platform.config.options!.refreshRate! * 1000)
|
|
102
|
-
.pipe(skipWhile(() => this.cameraUpdateInProgress))
|
|
103
|
-
.subscribe(() => {
|
|
104
|
-
this.refreshStatus();
|
|
105
|
-
});
|
|
106
|
-
|
|
107
|
-
// Watch for Camera change events
|
|
108
|
-
// We put in a debounce of 100ms so we don't make duplicate calls
|
|
109
|
-
this.doCameraUpdate
|
|
110
|
-
.pipe(
|
|
111
|
-
tap(() => {
|
|
112
|
-
this.cameraUpdateInProgress = true;
|
|
113
|
-
}),
|
|
114
|
-
debounceTime(this.platform.config.options!.pushRate! * 1000),
|
|
115
|
-
)
|
|
116
|
-
.subscribe(async () => {
|
|
117
|
-
try {
|
|
118
|
-
await this.pushChanges();
|
|
119
|
-
} catch (e: any) {
|
|
120
|
-
this.platform.log.error(`Indoor Cam: ${this.accessory.displayName} failed pushChanges`);
|
|
121
|
-
if (this.deviceDebug) {
|
|
122
|
-
this.platform.log.error(`Indoor Cam: ${this.accessory.displayName} failed pushChanges,`
|
|
123
|
-
+ ` Error Message: ${JSON.stringify(e.message)}`);
|
|
124
|
-
}
|
|
125
|
-
if (this.debugDebug) {
|
|
126
|
-
this.platform.log.error(`Indoor Cam: ${this.accessory.displayName} failed pushChanges,`
|
|
127
|
-
+ ` Error: ${JSON.stringify(e)}`);
|
|
128
|
-
}
|
|
129
|
-
this.apiError(e);
|
|
130
|
-
}
|
|
131
|
-
this.cameraUpdateInProgress = false;
|
|
132
|
-
});
|
|
133
|
-
}
|
|
134
|
-
|
|
135
|
-
parseStatus() {
|
|
136
|
-
this.platform.debug(`Indoor Cam ${this.accessory.displayName} SelectedRTPStreamConfiguration: ${this.SelectedRTPStreamConfiguration}`);
|
|
137
|
-
}
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
private async refreshStatus() {
|
|
141
|
-
try {
|
|
142
|
-
this.deviceStatus = (await this.platform.axios.get(`${DeviceURL}/${this.device.deviceId}/status`)).data;
|
|
143
|
-
this.platform.device(`Indoor Cam: ${this.accessory.displayName} refreshStatus: ${JSON.stringify(this.deviceStatus)}`);
|
|
144
|
-
this.parseStatus();
|
|
145
|
-
this.updateHomeKitCharacteristics();
|
|
146
|
-
} catch (e: any) {
|
|
147
|
-
this.platform.log.error(`Indoor Cam: ${this.accessory.displayName} failed refreshStatus with BLE Connection`);
|
|
148
|
-
if (this.deviceDebug) {
|
|
149
|
-
this.platform.log.error(`Indoor Cam: ${this.accessory.displayName} failed refreshStatus with BLE Connection,`
|
|
150
|
-
+ ` Error Message: ${JSON.stringify(e.message)}`);
|
|
151
|
-
}
|
|
152
|
-
if (this.debugDebug) {
|
|
153
|
-
this.platform.log.error(`Indoor Cam: ${this.accessory.displayName} failed refreshStatus with BLE Connection,`
|
|
154
|
-
+ ` Error: ${JSON.stringify(e)}`);
|
|
155
|
-
}
|
|
156
|
-
this.apiError(e);
|
|
157
|
-
}
|
|
158
|
-
}
|
|
159
|
-
|
|
160
|
-
/**
|
|
161
|
-
* Pushes the requested changes to the SwitchBot API
|
|
162
|
-
* deviceType commandType Command command parameter Description
|
|
163
|
-
* Camera - "command" "turnOff" "default" = set to OFF state
|
|
164
|
-
* Camera - "command" "turnOn" "default" = set to ON state
|
|
165
|
-
*/
|
|
166
|
-
async pushChanges() {
|
|
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
|
-
interval(5000)
|
|
182
|
-
.pipe(skipWhile(() => this.cameraUpdateInProgress))
|
|
183
|
-
.pipe(take(1))
|
|
184
|
-
.subscribe(() => {
|
|
185
|
-
this.refreshStatus();
|
|
186
|
-
});
|
|
187
|
-
} else {
|
|
188
|
-
this.platform.device(`Indoor Cam: ${this.accessory.displayName} No pushChanges. Active: ${this.Active}`);
|
|
189
|
-
}
|
|
190
|
-
}
|
|
191
|
-
|
|
192
|
-
updateHomeKitCharacteristics() {
|
|
193
|
-
if (this.SelectedRTPStreamConfiguration === undefined) {
|
|
194
|
-
this.platform.debug(`Indoor Cam: ${this.accessory.displayName} On: ${this.SelectedRTPStreamConfiguration}`);
|
|
195
|
-
} else {
|
|
196
|
-
this.service.updateCharacteristic(this.platform.Characteristic.SelectedRTPStreamConfiguration, this.SelectedRTPStreamConfiguration);
|
|
197
|
-
this.platform.device(`Indoor Cam: ${this.accessory.displayName} updateCharacteristic On: ${this.SelectedRTPStreamConfiguration}`);
|
|
198
|
-
}
|
|
199
|
-
}
|
|
200
|
-
|
|
201
|
-
public apiError(e: any) {
|
|
202
|
-
this.service.updateCharacteristic(this.platform.Characteristic.SelectedRTPStreamConfiguration, e);
|
|
203
|
-
}
|
|
204
|
-
|
|
205
|
-
private statusCode(push: AxiosResponse<{ statusCode: number; }>) {
|
|
206
|
-
switch (push.data.statusCode) {
|
|
207
|
-
case 151:
|
|
208
|
-
this.platform.log.error(`Indoor Cam: ${this.accessory.displayName} Command not supported by this device type.`);
|
|
209
|
-
break;
|
|
210
|
-
case 152:
|
|
211
|
-
this.platform.log.error(`Indoor Cam: ${this.accessory.displayName} Device not found.`);
|
|
212
|
-
break;
|
|
213
|
-
case 160:
|
|
214
|
-
this.platform.log.error(`Indoor Cam: ${this.accessory.displayName} Command is not supported.`);
|
|
215
|
-
break;
|
|
216
|
-
case 161:
|
|
217
|
-
this.platform.log.error(`Indoor Cam: ${this.accessory.displayName} Device is offline.`);
|
|
218
|
-
if (this.device.offline) {
|
|
219
|
-
this.Active = false;
|
|
220
|
-
}
|
|
221
|
-
break;
|
|
222
|
-
case 171:
|
|
223
|
-
this.platform.log.error(`Indoor Cam: ${this.accessory.displayName} Hub Device is offline. Hub: ${this.device.hubDeviceId}`);
|
|
224
|
-
if (this.device.offline) {
|
|
225
|
-
this.Active = false;
|
|
226
|
-
}
|
|
227
|
-
break;
|
|
228
|
-
case 190:
|
|
229
|
-
this.platform.log.error(`Indoor Cam: ${this.accessory.displayName} Device internal error due to device states not synchronized with server,`
|
|
230
|
-
+ ` Or command: ${JSON.stringify(push.data)} format is invalid`);
|
|
231
|
-
break;
|
|
232
|
-
case 100:
|
|
233
|
-
this.platform.debug(`Indoor Cam: ${this.accessory.displayName} Command successfully sent.`);
|
|
234
|
-
break;
|
|
235
|
-
default:
|
|
236
|
-
this.platform.debug(`Indoor Cam: ${this.accessory.displayName} Unknown statusCode.`);
|
|
237
|
-
}
|
|
238
|
-
}
|
|
239
|
-
|
|
240
|
-
/**
|
|
241
|
-
* Handle requests to set the value of the "Active" characteristic
|
|
242
|
-
*/
|
|
243
|
-
ActiveSet(value: CharacteristicValue) {
|
|
244
|
-
this.platform.debug(`Indoor Cam: ${this.accessory.displayName} Active: ${value}`);
|
|
245
|
-
|
|
246
|
-
this.Active = value;
|
|
247
|
-
this.doCameraUpdate.next();
|
|
248
|
-
}
|
|
249
|
-
|
|
250
|
-
/**
|
|
251
|
-
* Handle requests to set the value of the "SelectedRTPStreamConfiguration" characteristic
|
|
252
|
-
*/
|
|
253
|
-
SelectedRTPStreamConfigurationSet(value: CharacteristicValue) {
|
|
254
|
-
this.platform.debug(`Indoor Cam: ${this.accessory.displayName} SelectedRTPStreamConfiguration: ${value}`);
|
|
255
|
-
|
|
256
|
-
this.SelectedRTPStreamConfiguration = value;
|
|
257
|
-
this.doCameraUpdate.next();
|
|
258
|
-
}
|
|
259
|
-
|
|
260
|
-
/**
|
|
261
|
-
* Handle requests to set the value of the "On" characteristic
|
|
262
|
-
*/
|
|
263
|
-
SetupEndpointsSet(value: CharacteristicValue) {
|
|
264
|
-
this.platform.debug(`Indoor Cam: ${this.accessory.displayName} SetupEndpoints: ${value}`);
|
|
265
|
-
|
|
266
|
-
this.SetupEndpoints = value;
|
|
267
|
-
this.doCameraUpdate.next();
|
|
268
|
-
}
|
|
269
|
-
|
|
270
|
-
/**
|
|
271
|
-
* Handle requests to set the value of the "On" characteristic
|
|
272
|
-
*/
|
|
273
|
-
SupportedAudioStreamConfigurationSet(value: CharacteristicValue) {
|
|
274
|
-
this.platform.debug(`Indoor Cam: ${this.accessory.displayName} SupportedAudioStreamConfiguration: ${value}`);
|
|
275
|
-
|
|
276
|
-
this.SupportedAudioStreamConfiguration = value;
|
|
277
|
-
this.doCameraUpdate.next();
|
|
278
|
-
}
|
|
279
|
-
|
|
280
|
-
/**
|
|
281
|
-
* Handle requests to set the value of the "On" characteristic
|
|
282
|
-
*/
|
|
283
|
-
SupportedRTPConfigurationSet(value: CharacteristicValue) {
|
|
284
|
-
this.platform.debug(`Indoor Cam: ${this.accessory.displayName} SupportedRTPConfiguration: ${value}`);
|
|
285
|
-
|
|
286
|
-
this.SupportedRTPConfiguration = value;
|
|
287
|
-
this.doCameraUpdate.next();
|
|
288
|
-
}
|
|
289
|
-
|
|
290
|
-
/**
|
|
291
|
-
* Handle requests to set the value of the "On" characteristic
|
|
292
|
-
*/
|
|
293
|
-
StreamingStatusSet(value: CharacteristicValue) {
|
|
294
|
-
this.platform.debug(`Indoor Cam: ${this.accessory.displayName} StreamingStatus: ${value}`);
|
|
295
|
-
|
|
296
|
-
this.StreamingStatus = value;
|
|
297
|
-
this.doCameraUpdate.next();
|
|
298
|
-
}
|
|
299
|
-
|
|
300
|
-
/**
|
|
301
|
-
* Handle requests to set the value of the "On" characteristic
|
|
302
|
-
*/
|
|
303
|
-
SupportedVideoStreamConfigurationSet(value: CharacteristicValue) {
|
|
304
|
-
this.platform.debug(`Indoor Cam: ${this.accessory.displayName} SupportedVideoStreamConfiguration: ${value}`);
|
|
305
|
-
|
|
306
|
-
this.SupportedVideoStreamConfiguration = value;
|
|
307
|
-
this.doCameraUpdate.next();
|
|
308
|
-
}
|
|
309
|
-
}
|