homebridge-eufy-security 2.2.2 → 2.2.4
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/dist/accessories/CameraAccessory.d.ts +16 -39
- package/dist/accessories/CameraAccessory.d.ts.map +1 -1
- package/dist/accessories/CameraAccessory.js +187 -236
- package/dist/accessories/CameraAccessory.js.map +1 -1
- package/dist/accessories/Device.d.ts +3 -3
- package/dist/accessories/Device.d.ts.map +1 -1
- package/dist/accessories/Device.js.map +1 -1
- package/dist/accessories/SmartLockAccessory.d.ts +2 -2
- package/dist/controller/LocalLivestreamManager.d.ts +3 -1
- package/dist/controller/LocalLivestreamManager.d.ts.map +1 -1
- package/dist/controller/SnapshotManager.d.ts +1 -0
- package/dist/controller/SnapshotManager.d.ts.map +1 -1
- package/dist/controller/streamingDelegate.d.ts +4 -2
- package/dist/controller/streamingDelegate.d.ts.map +1 -1
- package/dist/controller/streamingDelegate.js +13 -13
- package/dist/controller/streamingDelegate.js.map +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/platform.d.ts.map +1 -1
- package/dist/platform.js +49 -62
- package/dist/platform.js.map +1 -1
- package/dist/utils/Talkback.d.ts +1 -0
- package/dist/utils/Talkback.d.ts.map +1 -1
- package/dist/utils/configTypes.d.ts +3 -3
- package/dist/utils/configTypes.d.ts.map +1 -1
- package/dist/utils/ffmpeg.d.ts +2 -0
- package/dist/utils/ffmpeg.d.ts.map +1 -1
- package/dist/utils/ffmpeg.js +2 -2
- package/dist/utils/ffmpeg.js.map +1 -1
- package/homebridge-ui/configui/app/accessory.d.ts +1 -1
- package/homebridge-ui/configui/app/accessory.d.ts.map +1 -1
- package/homebridge-ui/configui/app/util/types.d.ts +2 -2
- package/homebridge-ui/configui/app/util/types.d.ts.map +1 -1
- package/homebridge-ui/configui/app/util/types.js +1 -1
- package/homebridge-ui/configui/app/util/types.js.map +1 -1
- package/homebridge-ui/public/3rdpartylicenses.txt +6 -22
- package/homebridge-ui/public/index.html +2 -2
- package/homebridge-ui/public/main.0d25748cc9303f6b.js +1 -0
- package/homebridge-ui/public/polyfills.cdb21ff95fdea645.js +1 -0
- package/homebridge-ui/public/styles.021488511c20c432.css +5 -0
- package/package.json +45 -47
- package/homebridge-ui/public/main.9ba34b55431f3fae.js +0 -1
- package/homebridge-ui/public/polyfills.6050693665c0e882.js +0 -1
- package/homebridge-ui/public/styles.e02689e7df4304da.css +0 -6
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { Service, PlatformAccessory, CharacteristicValue } from 'homebridge';
|
|
2
2
|
import { EufySecurityPlatform } from '../platform';
|
|
3
3
|
import { DeviceAccessory } from './Device';
|
|
4
|
-
import { Camera } from 'eufy-security-client';
|
|
4
|
+
import { Camera, Device, PropertyValue } from 'eufy-security-client';
|
|
5
5
|
import { StreamingDelegate } from '../controller/streamingDelegate';
|
|
6
6
|
import { CameraConfig } from '../utils/configTypes';
|
|
7
7
|
/**
|
|
@@ -12,50 +12,27 @@ import { CameraConfig } from '../utils/configTypes';
|
|
|
12
12
|
export declare class CameraAccessory extends DeviceAccessory {
|
|
13
13
|
protected service: Service;
|
|
14
14
|
protected CameraService: Service;
|
|
15
|
+
protected cameraStatus: {
|
|
16
|
+
isEnabled: boolean;
|
|
17
|
+
timestamp: number;
|
|
18
|
+
};
|
|
15
19
|
readonly cameraConfig: CameraConfig;
|
|
16
20
|
protected streamingDelegate: StreamingDelegate | null;
|
|
17
21
|
private motionTimeout?;
|
|
18
22
|
constructor(platform: EufySecurityPlatform, accessory: PlatformAccessory, eufyDevice: Camera);
|
|
23
|
+
private setupButtonService;
|
|
24
|
+
private setupEnableButton;
|
|
25
|
+
private setupMotionButton;
|
|
26
|
+
private setupLightButton;
|
|
19
27
|
private getCameraConfig;
|
|
20
28
|
private cameraFunction;
|
|
21
|
-
|
|
22
|
-
/**
|
|
23
|
-
* Handle requests to set the "Event Snapshots Active" characteristic
|
|
24
|
-
*/
|
|
25
|
-
handleEventSnapshotsActiveSet(value: any): void;
|
|
26
|
-
/**
|
|
27
|
-
* Handle requests to get the current value of the "HomeKit Camera Active" characteristic
|
|
28
|
-
*/
|
|
29
|
-
handleHomeKitCameraActiveGet(): Promise<CharacteristicValue>;
|
|
30
|
-
/**
|
|
31
|
-
* Handle requests to set the "HomeKit Camera Active" characteristic
|
|
32
|
-
*/
|
|
33
|
-
handleHomeKitCameraActiveSet(value: any): void;
|
|
34
|
-
/**
|
|
35
|
-
* Handle requests to get the current value of the "HomeKit Camera Active" characteristic
|
|
36
|
-
*/
|
|
37
|
-
handleHomeKitCameraOperatingModeIndicatorGet(): Promise<CharacteristicValue>;
|
|
38
|
-
/**
|
|
39
|
-
* Handle requests to set the "HomeKit Camera Active" characteristic
|
|
40
|
-
*/
|
|
41
|
-
handleHomeKitCameraOperatingModeIndicatorSet(value: any): Promise<void>;
|
|
42
|
-
/**
|
|
43
|
-
* Handle requests to get the current value of the "HomeKit Camera Active" characteristic
|
|
44
|
-
*/
|
|
45
|
-
handleHomeKitNightVisionGet(): Promise<CharacteristicValue>;
|
|
46
|
-
/**
|
|
47
|
-
* Handle requests to set the "HomeKit Camera Active" characteristic
|
|
48
|
-
*/
|
|
49
|
-
handleHomeKitNightVisionSet(value: any): Promise<void>;
|
|
50
|
-
private motionFunction;
|
|
51
|
-
handleMotionDetectedGet(): Promise<CharacteristicValue>;
|
|
29
|
+
private setupMotionFunction;
|
|
52
30
|
private onDeviceEventDetectedPushNotification;
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
handleLightOnSet(value: CharacteristicValue): Promise<void>;
|
|
31
|
+
private setupSwitchService;
|
|
32
|
+
private getPropertyValue;
|
|
33
|
+
private setPropertyValue;
|
|
34
|
+
protected handlePropertyChange(device: Device, name: string, value: PropertyValue): void;
|
|
35
|
+
handleDummyEventGet(serviceName: string): Promise<CharacteristicValue>;
|
|
36
|
+
handleDummyEventSet(serviceName: string, value: CharacteristicValue): void;
|
|
60
37
|
}
|
|
61
38
|
//# sourceMappingURL=CameraAccessory.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CameraAccessory.d.ts","sourceRoot":"","sources":["../../src/plugin/accessories/CameraAccessory.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,iBAAiB,EAAE,mBAAmB,EAAE,MAAM,YAAY,CAAC;AAE7E,OAAO,EAAE,oBAAoB,EAAE,MAAM,aAAa,CAAC;AACnD,OAAO,EAAE,eAAe,EAAE,MAAM,UAAU,CAAC;AAM3C,OAAO,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"CameraAccessory.d.ts","sourceRoot":"","sources":["../../src/plugin/accessories/CameraAccessory.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,iBAAiB,EAAE,mBAAmB,EAAE,MAAM,YAAY,CAAC;AAE7E,OAAO,EAAE,oBAAoB,EAAE,MAAM,aAAa,CAAC;AACnD,OAAO,EAAE,eAAe,EAAE,MAAM,UAAU,CAAC;AAM3C,OAAO,EAAE,MAAM,EAAE,MAAM,EAA2C,aAAa,EAAE,MAAM,sBAAsB,CAAC;AAC9G,OAAO,EAAE,iBAAiB,EAAE,MAAM,iCAAiC,CAAC;AAEpE,OAAO,EAAE,YAAY,EAAe,MAAM,sBAAsB,CAAC;AAEjE;;;;GAIG;AACH,qBAAa,eAAgB,SAAQ,eAAe;IAElD,SAAS,CAAC,OAAO,EAAE,OAAO,CAAC;IAC3B,SAAS,CAAC,aAAa,EAAE,OAAO,CAAC;IAGjC,SAAS,CAAC,YAAY,EAAE;QAAE,SAAS,EAAE,OAAO,CAAC;QAAC,SAAS,EAAE,MAAM,CAAA;KAAE,CAAC;IAElE,SAAgB,YAAY,EAAE,YAAY,CAAC;IAE3C,SAAS,CAAC,iBAAiB,EAAE,iBAAiB,GAAG,IAAI,CAAQ;IAE7D,OAAO,CAAC,aAAa,CAAC,CAAiB;gBAGrC,QAAQ,EAAE,oBAAoB,EAC9B,SAAS,EAAE,iBAAiB,EAC5B,UAAU,EAAE,MAAM;IAuCpB,OAAO,CAAC,kBAAkB;YAuBZ,iBAAiB;YAIjB,iBAAiB;YAIjB,gBAAgB;IAI9B,OAAO,CAAC,eAAe;IAqCvB,OAAO,CAAC,cAAc;IAiDtB,OAAO,CAAC,mBAAmB;IA0C3B,OAAO,CAAC,qCAAqC;IA0B7C,OAAO,CAAC,kBAAkB;YA6BZ,gBAAgB;YAmChB,gBAAgB;cA8DX,oBAAoB,CACrC,MAAM,EAAE,MAAM,EACd,IAAI,EAAE,MAAM,EACZ,KAAK,EAAE,aAAa,GACnB,IAAI;IAgBP,mBAAmB,CAAC,WAAW,EAAE,MAAM,GAAG,OAAO,CAAC,mBAAmB,CAAC;IAgBtE,mBAAmB,CAAC,WAAW,EAAE,MAAM,EAAE,KAAK,EAAE,mBAAmB;CAGpE"}
|
|
@@ -19,89 +19,59 @@ class CameraAccessory extends Device_1.DeviceAccessory {
|
|
|
19
19
|
this.service = {};
|
|
20
20
|
this.CameraService = {};
|
|
21
21
|
this.cameraConfig = {};
|
|
22
|
+
this.cameraStatus = { isEnabled: false, timestamp: 0 }; // Initialize the cameraStatus object
|
|
22
23
|
this.platform.log.debug(this.accessory.displayName, 'Constructed Camera');
|
|
23
24
|
this.cameraConfig = this.getCameraConfig();
|
|
24
25
|
this.platform.log.debug(this.accessory.displayName, 'config is:', this.cameraConfig);
|
|
25
26
|
if (this.cameraConfig.enableCamera || (typeof this.eufyDevice.isDoorbell === 'function' && this.eufyDevice.isDoorbell())) {
|
|
26
27
|
this.platform.log.debug(this.accessory.displayName, 'has a camera');
|
|
27
28
|
try {
|
|
28
|
-
this.CameraService = this.cameraFunction(
|
|
29
|
+
this.CameraService = this.cameraFunction();
|
|
29
30
|
this.CameraService.setPrimaryService(true);
|
|
30
31
|
const delegate = new streamingDelegate_1.StreamingDelegate(this.platform, eufyDevice, this.cameraConfig, this.platform.api, this.platform.api.hap);
|
|
31
32
|
this.streamingDelegate = delegate;
|
|
32
33
|
accessory.configureController(delegate.controller);
|
|
33
34
|
}
|
|
34
|
-
catch (
|
|
35
|
-
this.platform.log.error(this.accessory.displayName, 'raise error to check and attach livestream function.',
|
|
35
|
+
catch (error) {
|
|
36
|
+
this.platform.log.error(this.accessory.displayName, 'raise error to check and attach livestream function.', error);
|
|
36
37
|
}
|
|
37
38
|
}
|
|
38
39
|
else {
|
|
39
40
|
this.platform.log.debug(this.accessory.displayName, 'has a motion sensor.');
|
|
40
41
|
}
|
|
42
|
+
this.service = this.setupMotionFunction(accessory);
|
|
43
|
+
this.setupEnableButton();
|
|
44
|
+
this.setupMotionButton();
|
|
45
|
+
this.setupLightButton();
|
|
46
|
+
}
|
|
47
|
+
setupButtonService(serviceName, configValue, PropertyName, serviceType) {
|
|
41
48
|
try {
|
|
42
|
-
this.
|
|
43
|
-
|
|
44
|
-
catch (Error) {
|
|
45
|
-
this.platform.log.error(this.accessory.displayName, 'raise error to check and attach motion function.', Error);
|
|
46
|
-
}
|
|
47
|
-
try {
|
|
48
|
-
this.platform.log.debug(this.accessory.displayName, 'enableButton config:', this.cameraConfig.enableButton);
|
|
49
|
-
if (this.cameraConfig.enableButton
|
|
50
|
-
&& this.eufyDevice.hasProperty('enabled')) {
|
|
51
|
-
this.platform.log.debug(this.accessory.displayName, 'has a isEnabled, so append switchEnabledService characteristic to him.');
|
|
52
|
-
const switchEnabledService = this.accessory.getService('Enabled') ||
|
|
53
|
-
this.accessory.addService(this.platform.Service.Switch, 'Enabled', 'enabled');
|
|
54
|
-
switchEnabledService.setCharacteristic(this.platform.Characteristic.Name, accessory.displayName + ' Enabled');
|
|
55
|
-
switchEnabledService.getCharacteristic(this.characteristic.On)
|
|
56
|
-
.onGet(this.handleEnableGet.bind(this))
|
|
57
|
-
.onSet(this.handleEnableSet.bind(this));
|
|
58
|
-
}
|
|
59
|
-
else {
|
|
60
|
-
// eslint-disable-next-line max-len
|
|
61
|
-
this.platform.log.debug(this.accessory.displayName, 'Looks like not compatible with isEnabled or this has been disabled within configuration');
|
|
62
|
-
}
|
|
63
|
-
}
|
|
64
|
-
catch (Error) {
|
|
65
|
-
this.platform.log.error(this.accessory.displayName, 'raise error to check and attach switchEnabledService.', Error);
|
|
66
|
-
}
|
|
67
|
-
try {
|
|
68
|
-
this.platform.log.debug(this.accessory.displayName, 'motionButton config:', this.cameraConfig.motionButton);
|
|
69
|
-
if (this.cameraConfig.motionButton && this.eufyDevice.hasProperty('motionDetection')) {
|
|
49
|
+
this.platform.log.debug(`${this.accessory.displayName} ${serviceName} config:`, configValue);
|
|
50
|
+
if (configValue && this.eufyDevice.hasProperty(PropertyName)) {
|
|
70
51
|
// eslint-disable-next-line max-len
|
|
71
|
-
this.platform.log.debug(this.accessory.displayName
|
|
72
|
-
const
|
|
73
|
-
|
|
74
|
-
switchMotionService.setCharacteristic(this.platform.Characteristic.Name, accessory.displayName + ' Motion');
|
|
75
|
-
switchMotionService.getCharacteristic(this.characteristic.On)
|
|
76
|
-
.onGet(this.handleMotionOnGet.bind(this))
|
|
77
|
-
.onSet(this.handleMotionOnSet.bind(this));
|
|
52
|
+
this.platform.log.debug(`${this.accessory.displayName} has a ${PropertyName}, so append ${serviceType}${serviceName} characteristic to it.`);
|
|
53
|
+
const newService = this.setupSwitchService(serviceName, serviceType, PropertyName);
|
|
54
|
+
this.service.addLinkedService(newService);
|
|
78
55
|
}
|
|
79
56
|
else {
|
|
80
57
|
// eslint-disable-next-line max-len
|
|
81
|
-
this.platform.log.debug(this.accessory.displayName
|
|
58
|
+
this.platform.log.debug(`${this.accessory.displayName} Looks like not compatible with ${PropertyName} or this has been disabled within configuration`);
|
|
82
59
|
}
|
|
83
60
|
}
|
|
84
|
-
catch (
|
|
85
|
-
this.platform.log.error(this.accessory.displayName
|
|
86
|
-
|
|
87
|
-
try {
|
|
88
|
-
if (this.eufyDevice.hasProperty('light') && (typeof this.eufyDevice.isFloodLight === 'function' && this.eufyDevice.isFloodLight())) {
|
|
89
|
-
this.platform.log.debug(this.accessory.displayName, 'has a DeviceLight, so append switchLightService characteristic to him.');
|
|
90
|
-
const switchLightService = this.accessory.getService('Light') ||
|
|
91
|
-
this.accessory.addService(this.platform.Service.Switch, 'Light', 'light');
|
|
92
|
-
switchLightService.setCharacteristic(this.platform.Characteristic.Name, accessory.displayName + ' Light');
|
|
93
|
-
switchLightService.getCharacteristic(this.characteristic.On)
|
|
94
|
-
.onGet(this.handleLightOnGet.bind(this))
|
|
95
|
-
.onSet(this.handleLightOnSet.bind(this));
|
|
96
|
-
}
|
|
97
|
-
else {
|
|
98
|
-
this.platform.log.debug(this.accessory.displayName, 'Looks like not compatible with DeviceLight');
|
|
99
|
-
}
|
|
100
|
-
}
|
|
101
|
-
catch (Error) {
|
|
102
|
-
this.platform.log.error(this.accessory.displayName, 'raise error to check and attach switchLightService.', Error);
|
|
61
|
+
catch (error) {
|
|
62
|
+
this.platform.log.error(`${this.accessory.displayName} raise error to check and attach ${serviceType}${serviceName}.`, error);
|
|
63
|
+
throw Error;
|
|
103
64
|
}
|
|
104
65
|
}
|
|
66
|
+
async setupEnableButton() {
|
|
67
|
+
this.setupButtonService('Enabled', this.cameraConfig.enableButton, eufy_security_client_1.PropertyName.DeviceEnabled, 'switch');
|
|
68
|
+
}
|
|
69
|
+
async setupMotionButton() {
|
|
70
|
+
this.setupButtonService('Motion', this.cameraConfig.motionButton, eufy_security_client_1.PropertyName.DeviceMotionDetection, 'switch');
|
|
71
|
+
}
|
|
72
|
+
async setupLightButton() {
|
|
73
|
+
this.setupButtonService('Light', true, eufy_security_client_1.PropertyName.DeviceLight, 'lightbulb');
|
|
74
|
+
}
|
|
105
75
|
getCameraConfig() {
|
|
106
76
|
var _a, _b, _c, _d, _e, _f, _g, _h, _j;
|
|
107
77
|
let config = {};
|
|
@@ -133,150 +103,70 @@ class CameraAccessory extends Device_1.DeviceAccessory {
|
|
|
133
103
|
}
|
|
134
104
|
return config;
|
|
135
105
|
}
|
|
136
|
-
cameraFunction(
|
|
106
|
+
cameraFunction() {
|
|
137
107
|
const service = this.accessory.getService(this.platform.Service.CameraOperatingMode) ||
|
|
138
108
|
this.accessory.addService(this.platform.Service.CameraOperatingMode);
|
|
139
|
-
service.setCharacteristic(this.characteristic.Name, accessory.displayName);
|
|
140
|
-
service
|
|
141
|
-
.
|
|
142
|
-
.
|
|
143
|
-
service
|
|
144
|
-
.
|
|
145
|
-
.onSet(this.
|
|
146
|
-
service
|
|
147
|
-
.getCharacteristic(this.characteristic.HomeKitCameraActive)
|
|
148
|
-
.onGet(this.handleHomeKitCameraActiveGet.bind(this));
|
|
149
|
-
service
|
|
150
|
-
.getCharacteristic(this.characteristic.HomeKitCameraActive)
|
|
151
|
-
.onSet(this.handleHomeKitCameraActiveSet.bind(this));
|
|
109
|
+
service.setCharacteristic(this.characteristic.Name, this.accessory.displayName);
|
|
110
|
+
service.getCharacteristic(this.characteristic.EventSnapshotsActive)
|
|
111
|
+
.onGet(this.handleDummyEventGet.bind(this, 'EventSnapshotsActive'))
|
|
112
|
+
.onSet(this.handleDummyEventSet.bind(this, 'EventSnapshotsActive'));
|
|
113
|
+
service.getCharacteristic(this.characteristic.HomeKitCameraActive)
|
|
114
|
+
.onGet(this.getPropertyValue.bind(this, 'this.characteristic.HomeKitCameraActive', eufy_security_client_1.PropertyName.DeviceEnabled))
|
|
115
|
+
.onSet(this.getPropertyValue.bind(this, 'this.characteristic.HomeKitCameraActive', eufy_security_client_1.PropertyName.DeviceEnabled));
|
|
152
116
|
if (this.eufyDevice.hasProperty('enabled')) {
|
|
153
|
-
service
|
|
154
|
-
.
|
|
155
|
-
.onGet(this.handleManuallyDisabledGet.bind(this));
|
|
117
|
+
service.getCharacteristic(this.characteristic.ManuallyDisabled)
|
|
118
|
+
.onGet(this.getPropertyValue.bind(this, 'this.characteristic.ManuallyDisabled', eufy_security_client_1.PropertyName.DeviceEnabled));
|
|
156
119
|
}
|
|
157
120
|
if (this.eufyDevice.hasProperty('statusLed')) {
|
|
158
|
-
service
|
|
159
|
-
.
|
|
160
|
-
.
|
|
161
|
-
.onSet(this.handleHomeKitCameraOperatingModeIndicatorSet.bind(this));
|
|
121
|
+
service.getCharacteristic(this.characteristic.CameraOperatingModeIndicator)
|
|
122
|
+
.onGet(this.getPropertyValue.bind(this, 'this.characteristic.CameraOperatingModeIndicator', eufy_security_client_1.PropertyName.DeviceStatusLed))
|
|
123
|
+
.onSet(this.setPropertyValue.bind(this, 'this.characteristic.CameraOperatingModeIndicator', eufy_security_client_1.PropertyName.DeviceStatusLed));
|
|
162
124
|
}
|
|
163
125
|
if (this.eufyDevice.hasProperty('nightvision')) {
|
|
164
|
-
service
|
|
165
|
-
.
|
|
166
|
-
.
|
|
167
|
-
.onSet(this.handleHomeKitNightVisionSet.bind(this));
|
|
168
|
-
}
|
|
169
|
-
return service;
|
|
170
|
-
}
|
|
171
|
-
handleEventSnapshotsActiveGet() {
|
|
172
|
-
const currentValue = this.characteristic.EventSnapshotsActive.DISABLE;
|
|
173
|
-
this.platform.log.debug(this.accessory.displayName, 'GET EventSnapshotsActive:', currentValue);
|
|
174
|
-
return currentValue;
|
|
175
|
-
}
|
|
176
|
-
/**
|
|
177
|
-
* Handle requests to set the "Event Snapshots Active" characteristic
|
|
178
|
-
*/
|
|
179
|
-
handleEventSnapshotsActiveSet(value) {
|
|
180
|
-
this.platform.log.debug(this.accessory.displayName, 'SET EventSnapshotsActive:', value);
|
|
181
|
-
}
|
|
182
|
-
/**
|
|
183
|
-
* Handle requests to get the current value of the "HomeKit Camera Active" characteristic
|
|
184
|
-
*/
|
|
185
|
-
handleHomeKitCameraActiveGet() {
|
|
186
|
-
const currentValue = this.characteristic.HomeKitCameraActive.OFF;
|
|
187
|
-
this.platform.log.debug(this.accessory.displayName, 'GET HomeKitCameraActive:', currentValue);
|
|
188
|
-
return currentValue;
|
|
189
|
-
}
|
|
190
|
-
/**
|
|
191
|
-
* Handle requests to set the "HomeKit Camera Active" characteristic
|
|
192
|
-
*/
|
|
193
|
-
handleHomeKitCameraActiveSet(value) {
|
|
194
|
-
this.platform.log.debug(this.accessory.displayName, 'SET HomeKitCameraActive:', value);
|
|
195
|
-
}
|
|
196
|
-
/**
|
|
197
|
-
* Handle requests to get the current value of the "HomeKit Camera Active" characteristic
|
|
198
|
-
*/
|
|
199
|
-
async handleHomeKitCameraOperatingModeIndicatorGet() {
|
|
200
|
-
try {
|
|
201
|
-
const currentValue = this.eufyDevice.getPropertyValue(eufy_security_client_1.PropertyName.DeviceStatusLed);
|
|
202
|
-
this.platform.log.debug(this.accessory.displayName, 'GET DeviceStatusLed:', currentValue);
|
|
203
|
-
return currentValue;
|
|
204
|
-
}
|
|
205
|
-
catch (_a) {
|
|
206
|
-
this.platform.log.debug(this.accessory.displayName, 'handleHomeKitCameraOperatingModeIndicatorGet', 'Wrong return value');
|
|
207
|
-
return false;
|
|
208
|
-
}
|
|
209
|
-
}
|
|
210
|
-
/**
|
|
211
|
-
* Handle requests to set the "HomeKit Camera Active" characteristic
|
|
212
|
-
*/
|
|
213
|
-
async handleHomeKitCameraOperatingModeIndicatorSet(value) {
|
|
214
|
-
this.platform.log.debug(this.accessory.displayName, 'SET HomeKitCameraOperatingModeIndicator:', value);
|
|
215
|
-
const station = await this.platform.getStationById(this.eufyDevice.getStationSerial());
|
|
216
|
-
station.setStatusLed(this.eufyDevice, value);
|
|
217
|
-
this.CameraService.getCharacteristic(this.characteristic.CameraOperatingModeIndicator).updateValue(value);
|
|
218
|
-
}
|
|
219
|
-
/**
|
|
220
|
-
* Handle requests to get the current value of the "HomeKit Camera Active" characteristic
|
|
221
|
-
*/
|
|
222
|
-
async handleHomeKitNightVisionGet() {
|
|
223
|
-
try {
|
|
224
|
-
const currentValue = this.eufyDevice.getPropertyValue(eufy_security_client_1.PropertyName.DeviceNightvision);
|
|
225
|
-
this.platform.log.debug(this.accessory.displayName, 'GET DeviceNightvision:', currentValue);
|
|
226
|
-
return currentValue;
|
|
126
|
+
service.getCharacteristic(this.characteristic.NightVision)
|
|
127
|
+
.onGet(this.getPropertyValue.bind(this, 'this.characteristic.NightVision', eufy_security_client_1.PropertyName.DeviceNightvision))
|
|
128
|
+
.onSet(this.setPropertyValue.bind(this, 'this.characteristic.NightVision', eufy_security_client_1.PropertyName.DeviceNightvision));
|
|
227
129
|
}
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
130
|
+
if (this.eufyDevice.hasProperty('autoNightvision')) {
|
|
131
|
+
service.getCharacteristic(this.characteristic.NightVision)
|
|
132
|
+
.onGet(this.getPropertyValue.bind(this, 'this.characteristic.NightVision', eufy_security_client_1.PropertyName.DeviceAutoNightvision))
|
|
133
|
+
.onSet(this.setPropertyValue.bind(this, 'this.characteristic.NightVision', eufy_security_client_1.PropertyName.DeviceAutoNightvision));
|
|
231
134
|
}
|
|
232
|
-
|
|
233
|
-
/**
|
|
234
|
-
* Handle requests to set the "HomeKit Camera Active" characteristic
|
|
235
|
-
*/
|
|
236
|
-
async handleHomeKitNightVisionSet(value) {
|
|
237
|
-
this.platform.log.debug(this.accessory.displayName, 'SET handleHomeKitNightVisionSet:', value);
|
|
238
|
-
const station = await this.platform.getStationById(this.eufyDevice.getStationSerial());
|
|
239
|
-
station.setNightVision(this.eufyDevice, value);
|
|
240
|
-
this.CameraService.getCharacteristic(this.characteristic.NightVision).updateValue(value);
|
|
241
|
-
}
|
|
242
|
-
motionFunction(accessory) {
|
|
243
|
-
const service = this.accessory.getService(this.platform.Service.MotionSensor) ||
|
|
244
|
-
this.accessory.addService(this.platform.Service.MotionSensor);
|
|
245
|
-
service.setCharacteristic(this.characteristic.Name, accessory.displayName);
|
|
246
|
-
service
|
|
247
|
-
.getCharacteristic(this.characteristic.MotionDetected)
|
|
248
|
-
.onGet(this.handleMotionDetectedGet.bind(this));
|
|
249
|
-
// List of event types
|
|
250
|
-
const eventTypesToHandle = [
|
|
251
|
-
'motion detected',
|
|
252
|
-
'person detected',
|
|
253
|
-
'pet detected',
|
|
254
|
-
'vehicle detected',
|
|
255
|
-
'sound detected',
|
|
256
|
-
'crying detected',
|
|
257
|
-
'dog detected',
|
|
258
|
-
'stranger person detected',
|
|
259
|
-
];
|
|
260
|
-
// Attach the common event handler to each event type
|
|
261
|
-
eventTypesToHandle.forEach(eventType => {
|
|
262
|
-
this.platform.log.debug(this.accessory.displayName, 'SETON Firing on:', eventType);
|
|
263
|
-
this.eufyDevice.on(eventType, (device, motion) => this.onDeviceEventDetectedPushNotification(device, motion, eventType));
|
|
264
|
-
});
|
|
135
|
+
this.eufyDevice.on('property changed', (device, name, value) => this.handlePropertyChange(device, name, value));
|
|
265
136
|
return service;
|
|
266
137
|
}
|
|
267
|
-
|
|
138
|
+
setupMotionFunction(accessory) {
|
|
268
139
|
try {
|
|
269
|
-
const
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
140
|
+
const service = this.accessory.getService(this.platform.Service.MotionSensor) ||
|
|
141
|
+
this.accessory.addService(this.platform.Service.MotionSensor);
|
|
142
|
+
service.setCharacteristic(this.characteristic.Name, this.accessory.displayName);
|
|
143
|
+
service.getCharacteristic(this.characteristic.MotionDetected)
|
|
144
|
+
.onGet(this.getPropertyValue.bind(this, 'this.characteristic.MotionDetected', eufy_security_client_1.PropertyName.DeviceMotionDetected));
|
|
145
|
+
// List of event types
|
|
146
|
+
const eventTypesToHandle = [
|
|
147
|
+
'motion detected',
|
|
148
|
+
'person detected',
|
|
149
|
+
'pet detected',
|
|
150
|
+
'vehicle detected',
|
|
151
|
+
'sound detected',
|
|
152
|
+
'crying detected',
|
|
153
|
+
'dog detected',
|
|
154
|
+
'stranger person detected',
|
|
155
|
+
];
|
|
156
|
+
// Attach the common event handler to each event type
|
|
157
|
+
eventTypesToHandle.forEach(eventType => {
|
|
158
|
+
this.platform.log.debug(this.accessory.displayName, 'SETON Firing on:', eventType);
|
|
159
|
+
this.eufyDevice.on(eventType, (device, motion) => this.onDeviceEventDetectedPushNotification(device, motion, eventType));
|
|
160
|
+
});
|
|
161
|
+
return service;
|
|
162
|
+
}
|
|
163
|
+
catch (error) {
|
|
164
|
+
this.platform.log.error(this.accessory.displayName, 'raise error to check and attach motion function.', error);
|
|
165
|
+
throw Error;
|
|
276
166
|
}
|
|
277
167
|
}
|
|
278
168
|
onDeviceEventDetectedPushNotification(device, motion, eventType) {
|
|
279
|
-
this.platform.log.info(this.accessory.displayName
|
|
169
|
+
this.platform.log.info(`${this.accessory.displayName} ON Event Detected (${eventType}): ${motion}`);
|
|
280
170
|
if (motion) {
|
|
281
171
|
this.motionTimeout = setTimeout(() => {
|
|
282
172
|
this.platform.log.debug(this.accessory.displayName, 'Reseting motion through timout.');
|
|
@@ -297,67 +187,128 @@ class CameraAccessory extends Device_1.DeviceAccessory {
|
|
|
297
187
|
.getCharacteristic(this.characteristic.MotionDetected)
|
|
298
188
|
.updateValue(motion);
|
|
299
189
|
}
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
this.platform.
|
|
304
|
-
|
|
305
|
-
}
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
190
|
+
setupSwitchService(serviceName, serviceType, propertyName) {
|
|
191
|
+
const platformServiceMapping = {
|
|
192
|
+
switch: this.platform.Service.Switch,
|
|
193
|
+
lightbulb: this.platform.Service.Lightbulb,
|
|
194
|
+
outlet: this.platform.Service.Outlet,
|
|
195
|
+
};
|
|
196
|
+
const platformService = platformServiceMapping[serviceType] || this.platform.Service.Switch;
|
|
197
|
+
const service = this.accessory.getService(serviceName) ||
|
|
198
|
+
this.accessory.addService(platformService, serviceName, serviceName);
|
|
199
|
+
service.setCharacteristic(this.characteristic.Name, this.accessory.displayName + ' ' + serviceName);
|
|
200
|
+
service.getCharacteristic(this.characteristic.On)
|
|
201
|
+
.onGet(this.getPropertyValue.bind(this, 'this.characteristic.On', propertyName))
|
|
202
|
+
.onSet(this.setPropertyValue.bind(this, 'this.characteristic.On', propertyName));
|
|
203
|
+
return service;
|
|
310
204
|
}
|
|
311
|
-
async
|
|
205
|
+
async getPropertyValue(characteristic, propertyName) {
|
|
312
206
|
try {
|
|
313
|
-
|
|
314
|
-
this.platform.log.debug(this.accessory.displayName
|
|
315
|
-
|
|
207
|
+
let value = await this.eufyDevice.getPropertyValue(propertyName);
|
|
208
|
+
this.platform.log.debug(`${this.accessory.displayName} GET '${characteristic}' ${propertyName}: ${value}`);
|
|
209
|
+
if (propertyName === eufy_security_client_1.PropertyName.DeviceNightvision) {
|
|
210
|
+
return value === 1;
|
|
211
|
+
}
|
|
212
|
+
// Override for PropertyName.DeviceEnabled when enabled button is fired and
|
|
213
|
+
if (propertyName === eufy_security_client_1.PropertyName.DeviceEnabled &&
|
|
214
|
+
Date.now() - this.cameraStatus.timestamp <= 60000) {
|
|
215
|
+
// eslint-disable-next-line max-len
|
|
216
|
+
this.platform.log.debug(`${this.accessory.displayName} CACHED for (1 min) '${characteristic}' ${propertyName}: ${this.cameraStatus.isEnabled}`);
|
|
217
|
+
value = this.cameraStatus.isEnabled;
|
|
218
|
+
}
|
|
219
|
+
if (characteristic === 'this.characteristic.ManuallyDisabled') {
|
|
220
|
+
this.platform.log.debug(`${this.accessory.displayName} INVERSED '${characteristic}' ${propertyName}: ${!value}`);
|
|
221
|
+
value = !value;
|
|
222
|
+
}
|
|
223
|
+
if (value === undefined) {
|
|
224
|
+
return false;
|
|
225
|
+
}
|
|
226
|
+
return value;
|
|
316
227
|
}
|
|
317
|
-
catch (
|
|
318
|
-
this.platform.log.debug(this.accessory.displayName
|
|
228
|
+
catch (error) {
|
|
229
|
+
this.platform.log.debug(`${this.accessory.displayName} Error getting '${characteristic}' ${propertyName}: ${error}`);
|
|
319
230
|
return false;
|
|
320
231
|
}
|
|
321
232
|
}
|
|
322
|
-
async
|
|
323
|
-
this.platform.log.debug(this.accessory.displayName, 'SET DeviceEnabled:', value);
|
|
324
|
-
const station = await this.platform.getStationById(this.eufyDevice.getStationSerial());
|
|
325
|
-
station.enableDevice(this.eufyDevice, value);
|
|
326
|
-
if (this.cameraConfig.enableCamera) {
|
|
327
|
-
this.CameraService.getCharacteristic(this.characteristic.ManuallyDisabled).updateValue(!value);
|
|
328
|
-
}
|
|
329
|
-
}
|
|
330
|
-
async handleMotionOnGet() {
|
|
233
|
+
async setPropertyValue(characteristic, propertyName, value) {
|
|
331
234
|
try {
|
|
332
|
-
|
|
333
|
-
this.platform.log.debug(this.accessory.displayName
|
|
334
|
-
|
|
235
|
+
// eslint-disable-next-line max-len
|
|
236
|
+
this.platform.log.debug(`${this.accessory.displayName} SET '${typeof characteristic} / ${characteristic}' ${propertyName}: ${value}`);
|
|
237
|
+
const station = await this.platform.getStationById(this.eufyDevice.getStationSerial());
|
|
238
|
+
switch (propertyName) {
|
|
239
|
+
case eufy_security_client_1.PropertyName.DeviceEnabled: {
|
|
240
|
+
if (characteristic === 'this.characteristic.On') {
|
|
241
|
+
this.cameraStatus = { isEnabled: value, timestamp: Date.now() };
|
|
242
|
+
await station.enableDevice(this.eufyDevice, value);
|
|
243
|
+
this.CameraService.updateCharacteristic(this.characteristic.ManuallyDisabled, !value);
|
|
244
|
+
}
|
|
245
|
+
break;
|
|
246
|
+
}
|
|
247
|
+
case eufy_security_client_1.PropertyName.DeviceMotionDetection: {
|
|
248
|
+
await station.setMotionDetection(this.eufyDevice, value);
|
|
249
|
+
this.CameraService.updateCharacteristic(this.characteristic.CameraOperatingModeIndicator, value);
|
|
250
|
+
break;
|
|
251
|
+
}
|
|
252
|
+
case eufy_security_client_1.PropertyName.DeviceStatusLed: {
|
|
253
|
+
await station.setStatusLed(this.eufyDevice, value);
|
|
254
|
+
this.CameraService.updateCharacteristic(this.characteristic.CameraOperatingModeIndicator, value);
|
|
255
|
+
break;
|
|
256
|
+
}
|
|
257
|
+
case eufy_security_client_1.PropertyName.DeviceNightvision: {
|
|
258
|
+
// Convert true to 1 (B&W Night Vision) and false to 0 (off)
|
|
259
|
+
await station.setNightVision(this.eufyDevice, Number(value));
|
|
260
|
+
this.CameraService.updateCharacteristic(this.characteristic.NightVision, value);
|
|
261
|
+
break;
|
|
262
|
+
}
|
|
263
|
+
case eufy_security_client_1.PropertyName.DeviceAutoNightvision: {
|
|
264
|
+
await station.setAutoNightVision(this.eufyDevice, value);
|
|
265
|
+
this.CameraService.updateCharacteristic(this.characteristic.NightVision, value);
|
|
266
|
+
break;
|
|
267
|
+
}
|
|
268
|
+
case eufy_security_client_1.PropertyName.DeviceLight: {
|
|
269
|
+
await station.switchLight(this.eufyDevice, value);
|
|
270
|
+
this.service.updateCharacteristic(this.characteristic.On, value);
|
|
271
|
+
break;
|
|
272
|
+
}
|
|
273
|
+
default: {
|
|
274
|
+
// eslint-disable-next-line max-len
|
|
275
|
+
this.platform.log.error(`${this.accessory.displayName} Shouldn't Match '${characteristic}' ${propertyName}: ${value}`);
|
|
276
|
+
throw Error;
|
|
277
|
+
break;
|
|
278
|
+
}
|
|
279
|
+
}
|
|
335
280
|
}
|
|
336
|
-
catch (
|
|
337
|
-
this.platform.log.debug(this.accessory.displayName
|
|
338
|
-
return false;
|
|
281
|
+
catch (error) {
|
|
282
|
+
this.platform.log.debug(`${this.accessory.displayName} Error setting '${characteristic}' ${propertyName}: ${error}`);
|
|
339
283
|
}
|
|
340
284
|
}
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
catch (_a) {
|
|
353
|
-
this.platform.log.debug(this.accessory.displayName, 'handleLightOnGet', 'Wrong return value');
|
|
354
|
-
return false;
|
|
285
|
+
handlePropertyChange(device, name, value) {
|
|
286
|
+
switch (name) {
|
|
287
|
+
case 'enabled': {
|
|
288
|
+
break;
|
|
289
|
+
}
|
|
290
|
+
case 'statusLed': {
|
|
291
|
+
break;
|
|
292
|
+
}
|
|
293
|
+
default: {
|
|
294
|
+
break;
|
|
295
|
+
}
|
|
355
296
|
}
|
|
356
297
|
}
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
298
|
+
handleDummyEventGet(serviceName) {
|
|
299
|
+
const characteristicValues = {
|
|
300
|
+
'EventSnapshotsActive': this.characteristic.EventSnapshotsActive.DISABLE,
|
|
301
|
+
'HomeKitCameraActive': this.characteristic.HomeKitCameraActive.OFF,
|
|
302
|
+
};
|
|
303
|
+
const currentValue = characteristicValues[serviceName];
|
|
304
|
+
if (currentValue === undefined) {
|
|
305
|
+
throw new Error(`Invalid serviceName: ${serviceName}`);
|
|
306
|
+
}
|
|
307
|
+
this.platform.log.debug(`${this.accessory.displayName} GET ${serviceName}: ${currentValue}`);
|
|
308
|
+
return Promise.resolve(currentValue);
|
|
309
|
+
}
|
|
310
|
+
handleDummyEventSet(serviceName, value) {
|
|
311
|
+
this.platform.log.debug(`${this.accessory.displayName} SET ${serviceName}: ${value}`);
|
|
361
312
|
}
|
|
362
313
|
}
|
|
363
314
|
exports.CameraAccessory = CameraAccessory;
|