homebridge-eufy-security 2.2.4 → 2.2.6
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/BaseAccessory.d.ts +32 -0
- package/dist/accessories/BaseAccessory.d.ts.map +1 -0
- package/dist/accessories/BaseAccessory.js +128 -0
- package/dist/accessories/BaseAccessory.js.map +1 -0
- package/dist/accessories/CameraAccessory.d.ts +7 -8
- package/dist/accessories/CameraAccessory.d.ts.map +1 -1
- package/dist/accessories/CameraAccessory.js +126 -93
- package/dist/accessories/CameraAccessory.js.map +1 -1
- package/dist/accessories/Device.d.ts +14 -16
- package/dist/accessories/Device.d.ts.map +1 -1
- package/dist/accessories/Device.js +42 -67
- package/dist/accessories/Device.js.map +1 -1
- package/dist/accessories/EntrySensorAccessory.d.ts +2 -6
- package/dist/accessories/EntrySensorAccessory.d.ts.map +1 -1
- package/dist/accessories/EntrySensorAccessory.js +14 -40
- package/dist/accessories/EntrySensorAccessory.js.map +1 -1
- package/dist/accessories/LockAccessory.d.ts +16 -0
- package/dist/accessories/LockAccessory.d.ts.map +1 -0
- package/dist/accessories/LockAccessory.js +102 -0
- package/dist/accessories/LockAccessory.js.map +1 -0
- package/dist/accessories/MotionSensorAccessory.d.ts +2 -6
- package/dist/accessories/MotionSensorAccessory.d.ts.map +1 -1
- package/dist/accessories/MotionSensorAccessory.js +14 -40
- package/dist/accessories/MotionSensorAccessory.js.map +1 -1
- package/dist/accessories/StationAccessory.d.ts +18 -14
- package/dist/accessories/StationAccessory.d.ts.map +1 -1
- package/dist/accessories/StationAccessory.js +115 -111
- package/dist/accessories/StationAccessory.js.map +1 -1
- package/dist/config.d.ts +1 -0
- package/dist/config.d.ts.map +1 -1
- package/dist/controller/SnapshotManager.d.ts +1 -7
- package/dist/controller/SnapshotManager.d.ts.map +1 -1
- package/dist/controller/SnapshotManager.js +46 -128
- package/dist/controller/SnapshotManager.js.map +1 -1
- package/dist/platform.d.ts +1 -0
- package/dist/platform.d.ts.map +1 -1
- package/dist/platform.js +81 -46
- package/dist/platform.js.map +1 -1
- package/dist/utils/configTypes.d.ts +0 -1
- package/dist/utils/configTypes.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/index.html +1 -1
- package/homebridge-ui/public/main.632736b6fba20915.js +1 -0
- package/homebridge-ui/server.js +41 -11
- package/homebridge-ui/server.js.map +1 -1
- package/package.json +22 -21
- package/dist/accessories/DoorbellCameraAccessory.d.ts +0 -17
- package/dist/accessories/DoorbellCameraAccessory.d.ts.map +0 -1
- package/dist/accessories/DoorbellCameraAccessory.js +0 -47
- package/dist/accessories/DoorbellCameraAccessory.js.map +0 -1
- package/dist/accessories/KeypadAccessory.d.ts +0 -24
- package/dist/accessories/KeypadAccessory.d.ts.map +0 -1
- package/dist/accessories/KeypadAccessory.js +0 -52
- package/dist/accessories/KeypadAccessory.js.map +0 -1
- package/dist/accessories/SmartLockAccessory.d.ts +0 -24
- package/dist/accessories/SmartLockAccessory.d.ts.map +0 -1
- package/dist/accessories/SmartLockAccessory.js +0 -99
- package/dist/accessories/SmartLockAccessory.js.map +0 -1
- package/homebridge-ui/public/main.0d25748cc9303f6b.js +0 -1
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
/// <reference types="node" />
|
|
2
|
+
import { PlatformAccessory, Characteristic, Service, WithUUID } from 'homebridge';
|
|
3
|
+
import { EufySecurityPlatform } from '../platform';
|
|
4
|
+
import { PropertyValue } from 'eufy-security-client';
|
|
5
|
+
import { EventEmitter } from 'events';
|
|
6
|
+
export type CharacteristicType = WithUUID<{
|
|
7
|
+
new (): Characteristic;
|
|
8
|
+
}>;
|
|
9
|
+
export type ServiceType = WithUUID<typeof Service> | Service;
|
|
10
|
+
export declare abstract class BaseAccessory extends EventEmitter {
|
|
11
|
+
protected platform: EufySecurityPlatform;
|
|
12
|
+
protected accessory: PlatformAccessory;
|
|
13
|
+
protected device: any;
|
|
14
|
+
protected servicesInUse: Service[];
|
|
15
|
+
protected SN: string;
|
|
16
|
+
constructor(platform: EufySecurityPlatform, accessory: PlatformAccessory, device: any);
|
|
17
|
+
protected handleRawPropertyChange(device: any, type: number, value: string): void;
|
|
18
|
+
protected handlePropertyChange(device: any, name: string, value: PropertyValue): void;
|
|
19
|
+
registerCharacteristic({ characteristicType, serviceType, getValue, setValue, onValue, onSimpleValue, name, serviceSubType, }: {
|
|
20
|
+
characteristicType: CharacteristicType;
|
|
21
|
+
serviceType: ServiceType;
|
|
22
|
+
serviceSubType?: string;
|
|
23
|
+
name?: string;
|
|
24
|
+
getValue: (data: any) => any;
|
|
25
|
+
setValue?: (value: any) => any;
|
|
26
|
+
onValue?: (service: Service, characteristic: Characteristic) => any;
|
|
27
|
+
onSimpleValue?: string;
|
|
28
|
+
}): void;
|
|
29
|
+
protected getService(serviceType: ServiceType, name?: string, subType?: string): Service;
|
|
30
|
+
pruneUnusedServices(): void;
|
|
31
|
+
}
|
|
32
|
+
//# sourceMappingURL=BaseAccessory.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"BaseAccessory.d.ts","sourceRoot":"","sources":["../../src/plugin/accessories/BaseAccessory.ts"],"names":[],"mappings":";AAAA,OAAO,EACL,iBAAiB,EACjB,cAAc,EAEd,OAAO,EACP,QAAQ,EACT,MAAM,YAAY,CAAC;AACpB,OAAO,EAAE,oBAAoB,EAAE,MAAM,aAAa,CAAC;AACnD,OAAO,EAAc,aAAa,EAAmB,MAAM,sBAAsB,CAAC;AAClF,OAAO,EAAE,YAAY,EAAE,MAAM,QAAQ,CAAC;AAStC,MAAM,MAAM,kBAAkB,GAAG,QAAQ,CAAC;IAAE,QAAO,cAAc,CAAA;CAAE,CAAC,CAAC;AACrE,MAAM,MAAM,WAAW,GAAG,QAAQ,CAAC,OAAO,OAAO,CAAC,GAAG,OAAO,CAAC;AAE7D,8BAAsB,aAAc,SAAQ,YAAY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|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.BaseAccessory = void 0;
|
|
4
|
+
const eufy_security_client_1 = require("eufy-security-client");
|
|
5
|
+
const events_1 = require("events");
|
|
6
|
+
function isServiceInstance(serviceType) {
|
|
7
|
+
// eslint-disable-next-line
|
|
8
|
+
return typeof serviceType === 'object';
|
|
9
|
+
}
|
|
10
|
+
class BaseAccessory extends events_1.EventEmitter {
|
|
11
|
+
constructor(platform, accessory,
|
|
12
|
+
// eslint-disable-next-line
|
|
13
|
+
device) {
|
|
14
|
+
super();
|
|
15
|
+
this.platform = platform;
|
|
16
|
+
this.accessory = accessory;
|
|
17
|
+
this.device = device;
|
|
18
|
+
this.servicesInUse = [];
|
|
19
|
+
this.platform = platform;
|
|
20
|
+
this.accessory = accessory;
|
|
21
|
+
this.device = device;
|
|
22
|
+
this.SN = this.device.getSerial();
|
|
23
|
+
this.registerCharacteristic({
|
|
24
|
+
serviceType: this.platform.Service.AccessoryInformation,
|
|
25
|
+
characteristicType: this.platform.Characteristic.Manufacturer,
|
|
26
|
+
getValue: (data) => 'Eufy',
|
|
27
|
+
});
|
|
28
|
+
this.registerCharacteristic({
|
|
29
|
+
serviceType: this.platform.Service.AccessoryInformation,
|
|
30
|
+
characteristicType: this.platform.Characteristic.Name,
|
|
31
|
+
getValue: (data) => this.accessory.displayName || 'Unknowm',
|
|
32
|
+
});
|
|
33
|
+
this.registerCharacteristic({
|
|
34
|
+
serviceType: this.platform.Service.AccessoryInformation,
|
|
35
|
+
characteristicType: this.platform.Characteristic.Model,
|
|
36
|
+
getValue: (data) => eufy_security_client_1.DeviceType[this.device.getDeviceType()] || 'Unknowm',
|
|
37
|
+
});
|
|
38
|
+
this.registerCharacteristic({
|
|
39
|
+
serviceType: this.platform.Service.AccessoryInformation,
|
|
40
|
+
characteristicType: this.platform.Characteristic.SerialNumber,
|
|
41
|
+
getValue: (data) => this.SN || 'Unknowm',
|
|
42
|
+
});
|
|
43
|
+
this.registerCharacteristic({
|
|
44
|
+
serviceType: this.platform.Service.AccessoryInformation,
|
|
45
|
+
characteristicType: this.platform.Characteristic.FirmwareRevision,
|
|
46
|
+
getValue: (data) => this.device.getSoftwareVersion() || 'Unknowm',
|
|
47
|
+
});
|
|
48
|
+
this.registerCharacteristic({
|
|
49
|
+
serviceType: this.platform.Service.AccessoryInformation,
|
|
50
|
+
characteristicType: this.platform.Characteristic.HardwareRevision,
|
|
51
|
+
getValue: (data) => this.device.getHardwareVersion() || 'Unknowm',
|
|
52
|
+
});
|
|
53
|
+
if (this.platform.config.enableDetailedLogging) {
|
|
54
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
55
|
+
this.device.on('raw property changed', (device, type, value) => this.handleRawPropertyChange(device, type, value));
|
|
56
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
57
|
+
this.device.on('property changed', (device, name, value) => this.handlePropertyChange(device, name, value));
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
61
|
+
handleRawPropertyChange(device, type, value) {
|
|
62
|
+
this.platform.log.debug(`${this.accessory.displayName} Raw Property Changes: ${type} ${value}`);
|
|
63
|
+
}
|
|
64
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
65
|
+
handlePropertyChange(device, name, value) {
|
|
66
|
+
this.platform.log.debug(`${this.accessory.displayName} Property Changes: ${name} ${value}`);
|
|
67
|
+
}
|
|
68
|
+
registerCharacteristic({ characteristicType, serviceType, getValue, setValue, onValue, onSimpleValue, name, serviceSubType, }) {
|
|
69
|
+
const service = this.getService(serviceType, name, serviceSubType);
|
|
70
|
+
const characteristic = service.getCharacteristic(characteristicType);
|
|
71
|
+
// eslint-disable-next-line max-len
|
|
72
|
+
this.platform.log.debug(`${this.accessory.displayName} REGISTER SERVICE '${serviceType.name} / ${characteristic.displayName}': ${characteristic.UUID}`);
|
|
73
|
+
characteristic.onGet(async (data) => {
|
|
74
|
+
const value = getValue(data);
|
|
75
|
+
this.platform.log.debug(`${this.accessory.displayName} GET '${serviceType.name} / ${characteristicType.name}': ${value}`);
|
|
76
|
+
return value;
|
|
77
|
+
});
|
|
78
|
+
if (setValue) {
|
|
79
|
+
characteristic.onSet(async (value) => {
|
|
80
|
+
this.platform.log.debug(`${this.accessory.displayName} SET '${serviceType.name} / ${characteristicType.name}': ${value}`);
|
|
81
|
+
Promise.resolve(setValue(value));
|
|
82
|
+
});
|
|
83
|
+
}
|
|
84
|
+
if (onSimpleValue) {
|
|
85
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
86
|
+
this.device.on(onSimpleValue, (device, state) => {
|
|
87
|
+
// eslint-disable-next-line max-len
|
|
88
|
+
this.platform.log.info(`${this.accessory.displayName} ON '${serviceType.name} / ${characteristicType.name} / ${onSimpleValue}': ${state}`);
|
|
89
|
+
characteristic.updateValue(state);
|
|
90
|
+
});
|
|
91
|
+
}
|
|
92
|
+
else if (onValue) {
|
|
93
|
+
onValue(service, characteristic);
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
getService(serviceType, name = this.accessory.displayName, subType) {
|
|
97
|
+
if (isServiceInstance(serviceType)) {
|
|
98
|
+
return serviceType;
|
|
99
|
+
}
|
|
100
|
+
const existingService = subType ? this.accessory.getServiceById(serviceType, subType) : this.accessory.getService(serviceType);
|
|
101
|
+
const service = existingService ||
|
|
102
|
+
this.accessory.addService(serviceType, name, subType);
|
|
103
|
+
if (existingService &&
|
|
104
|
+
existingService.displayName &&
|
|
105
|
+
name !== existingService.displayName) {
|
|
106
|
+
throw new Error(`Overlapping services for device ${this.accessory.displayName} - ${name} != ${existingService.displayName} - ${serviceType}`);
|
|
107
|
+
}
|
|
108
|
+
if (!this.servicesInUse.includes(service)) {
|
|
109
|
+
this.servicesInUse.push(service);
|
|
110
|
+
}
|
|
111
|
+
return service;
|
|
112
|
+
}
|
|
113
|
+
pruneUnusedServices() {
|
|
114
|
+
const safeServiceUUIDs = [
|
|
115
|
+
this.platform.Service.CameraRTPStreamManagement.UUID,
|
|
116
|
+
];
|
|
117
|
+
this.accessory.services.forEach((service) => {
|
|
118
|
+
if (!this.servicesInUse.includes(service) &&
|
|
119
|
+
!safeServiceUUIDs.includes(service.UUID)) {
|
|
120
|
+
// eslint-disable-next-line max-len
|
|
121
|
+
this.platform.log.debug(`${this.accessory.displayName} Pruning unused service ${service.UUID} ${service.displayName || service.name}`);
|
|
122
|
+
this.accessory.removeService(service);
|
|
123
|
+
}
|
|
124
|
+
});
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
exports.BaseAccessory = BaseAccessory;
|
|
128
|
+
//# sourceMappingURL=BaseAccessory.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"BaseAccessory.js","sourceRoot":"","sources":["../../src/plugin/accessories/BaseAccessory.ts"],"names":[],"mappings":";;;AAQA,+DAAkF;AAClF,mCAAsC;AAEtC,SAAS,iBAAiB,CACxB,WAA+C;IAE/C,2BAA2B;IAC3B,OAAO,OAAQ,WAAmB,KAAK,QAAQ,CAAC;AAClD,CAAC;AAKD,MAAsB,aAAc,SAAQ,qBAAY;IAKtD,YACY,QAA8B,EAC9B,SAA4B;IACtC,2BAA2B;IACjB,MAAW;QAErB,KAAK,EAAE,CAAC;QALE,aAAQ,GAAR,QAAQ,CAAsB;QAC9B,cAAS,GAAT,SAAS,CAAmB;QAE5B,WAAM,GAAN,MAAM,CAAK;QAPb,kBAAa,GAAc,EAAE,CAAC;QAWtC,IAAI,CAAC,QAAQ,GAAG,QAAQ,CAAC;QACzB,IAAI,CAAC,SAAS,GAAG,SAAS,CAAC;QAC3B,IAAI,CAAC,MAAM,GAAG,MAA0B,CAAC;QAEzC,IAAI,CAAC,EAAE,GAAG,IAAI,CAAC,MAAM,CAAC,SAAS,EAAE,CAAC;QAElC,IAAI,CAAC,sBAAsB,CAAC;YAC1B,WAAW,EAAE,IAAI,CAAC,QAAQ,CAAC,OAAO,CA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,CAAC,CAAC;SAClC;QAED,OAAO,OAAO,CAAC;IACjB,CAAC;IAED,mBAAmB;QACjB,MAAM,gBAAgB,GAAG;YACvB,IAAI,CAAC,QAAQ,CAAC,OAAO,CAAC,yBAAyB,CAAC,IAAI;SACrD,CAAC;QAEF,IAAI,CAAC,SAAS,CAAC,QAAQ,CAAC,OAAO,CAAC,CAAC,OAAO,EAAE,EAAE;YAC1C,IACE,CAAC,IAAI,CAAC,aAAa,CAAC,QAAQ,CAAC,OAAO,CAAC;gBACrC,CAAC,gBAAgB,CAAC,QAAQ,CAAC,OAAO,CAAC,IAAI,CAAC,EACxC;gBACA,mCAAmC;gBACnC,IAAI,CAAC,QAAQ,CAAC,GAAG,CAAC,KAAK,CAAC,GAAG,IAAI,CAAC,SAAS,CAAC,WAAW,2BAA2B,OAAO,CAAC,IAAI,IAAI,OAAO,CAAC,WAAW,IAAI,OAAO,CAAC,IAAI,EAAE,CAAC,CAAC;gBACvI,IAAI,CAAC,SAAS,CAAC,aAAa,CAAC,OAAO,CAAC,CAAC;aACvC;QACH,CAAC,CAAC,CAAC;IACL,CAAC;CACF;AA/KD,sCA+KC"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { PlatformAccessory, CharacteristicValue } from 'homebridge';
|
|
2
2
|
import { EufySecurityPlatform } from '../platform';
|
|
3
3
|
import { DeviceAccessory } from './Device';
|
|
4
|
-
import { Camera,
|
|
4
|
+
import { Camera, PropertyName } from 'eufy-security-client';
|
|
5
5
|
import { StreamingDelegate } from '../controller/streamingDelegate';
|
|
6
6
|
import { CameraConfig } from '../utils/configTypes';
|
|
7
7
|
/**
|
|
@@ -10,16 +10,15 @@ import { CameraConfig } from '../utils/configTypes';
|
|
|
10
10
|
* Each accessory may expose multiple services of different service types.
|
|
11
11
|
*/
|
|
12
12
|
export declare class CameraAccessory extends DeviceAccessory {
|
|
13
|
-
protected service: Service;
|
|
14
|
-
protected CameraService: Service;
|
|
15
13
|
protected cameraStatus: {
|
|
16
14
|
isEnabled: boolean;
|
|
17
15
|
timestamp: number;
|
|
18
16
|
};
|
|
17
|
+
private ring_triggered;
|
|
19
18
|
readonly cameraConfig: CameraConfig;
|
|
20
19
|
protected streamingDelegate: StreamingDelegate | null;
|
|
21
20
|
private motionTimeout?;
|
|
22
|
-
constructor(platform: EufySecurityPlatform, accessory: PlatformAccessory,
|
|
21
|
+
constructor(platform: EufySecurityPlatform, accessory: PlatformAccessory, device: Camera);
|
|
23
22
|
private setupButtonService;
|
|
24
23
|
private setupEnableButton;
|
|
25
24
|
private setupMotionButton;
|
|
@@ -29,10 +28,10 @@ export declare class CameraAccessory extends DeviceAccessory {
|
|
|
29
28
|
private setupMotionFunction;
|
|
30
29
|
private onDeviceEventDetectedPushNotification;
|
|
31
30
|
private setupSwitchService;
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
protected handlePropertyChange(device: Device, name: string, value: PropertyValue): void;
|
|
31
|
+
protected getCameraPropertyValue(characteristic: string, propertyName: PropertyName): CharacteristicValue;
|
|
32
|
+
protected setCameraPropertyValue(characteristic: string, propertyName: PropertyName, value: CharacteristicValue): Promise<void>;
|
|
35
33
|
handleDummyEventGet(serviceName: string): Promise<CharacteristicValue>;
|
|
36
34
|
handleDummyEventSet(serviceName: string, value: CharacteristicValue): void;
|
|
35
|
+
private onDeviceRingsPushNotification;
|
|
37
36
|
}
|
|
38
37
|
//# 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,
|
|
1
|
+
{"version":3,"file":"CameraAccessory.d.ts","sourceRoot":"","sources":["../../src/plugin/accessories/CameraAccessory.ts"],"names":[],"mappings":"AAAA,OAAO,EAAW,iBAAiB,EAAkB,mBAAmB,EAAE,MAAM,YAAY,CAAC;AAE7F,OAAO,EAAE,oBAAoB,EAAE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2,6 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.CameraAccessory = void 0;
|
|
4
4
|
const Device_1 = require("./Device");
|
|
5
|
-
// import { HttpService, LocalLookupService, DeviceClientService, CommandType } from 'eufy-node-client';
|
|
6
5
|
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
7
6
|
// @ts-ignore
|
|
8
7
|
const eufy_security_client_1 = require("eufy-security-client");
|
|
@@ -13,22 +12,20 @@ const streamingDelegate_1 = require("../controller/streamingDelegate");
|
|
|
13
12
|
* Each accessory may expose multiple services of different service types.
|
|
14
13
|
*/
|
|
15
14
|
class CameraAccessory extends Device_1.DeviceAccessory {
|
|
16
|
-
constructor(platform, accessory,
|
|
17
|
-
super(platform, accessory,
|
|
15
|
+
constructor(platform, accessory, device) {
|
|
16
|
+
super(platform, accessory, device);
|
|
17
|
+
this.ring_triggered = false;
|
|
18
18
|
this.streamingDelegate = null;
|
|
19
|
-
this.service = {};
|
|
20
|
-
this.CameraService = {};
|
|
21
19
|
this.cameraConfig = {};
|
|
22
20
|
this.cameraStatus = { isEnabled: false, timestamp: 0 }; // Initialize the cameraStatus object
|
|
23
21
|
this.platform.log.debug(this.accessory.displayName, 'Constructed Camera');
|
|
24
22
|
this.cameraConfig = this.getCameraConfig();
|
|
25
|
-
this.platform.log.debug(this.accessory.displayName, 'config is:', this.cameraConfig);
|
|
26
|
-
if (this.cameraConfig.enableCamera || (typeof this.
|
|
23
|
+
// this.platform.log.debug(this.accessory.displayName, 'config is:', this.cameraConfig);
|
|
24
|
+
if (this.cameraConfig.enableCamera || (typeof this.device.isDoorbell === 'function' && this.device.isDoorbell())) {
|
|
27
25
|
this.platform.log.debug(this.accessory.displayName, 'has a camera');
|
|
28
26
|
try {
|
|
29
|
-
this.
|
|
30
|
-
this.
|
|
31
|
-
const delegate = new streamingDelegate_1.StreamingDelegate(this.platform, eufyDevice, this.cameraConfig, this.platform.api, this.platform.api.hap);
|
|
27
|
+
this.cameraFunction();
|
|
28
|
+
const delegate = new streamingDelegate_1.StreamingDelegate(this.platform, device, this.cameraConfig, this.platform.api, this.platform.api.hap);
|
|
32
29
|
this.streamingDelegate = delegate;
|
|
33
30
|
accessory.configureController(delegate.controller);
|
|
34
31
|
}
|
|
@@ -39,19 +36,17 @@ class CameraAccessory extends Device_1.DeviceAccessory {
|
|
|
39
36
|
else {
|
|
40
37
|
this.platform.log.debug(this.accessory.displayName, 'has a motion sensor.');
|
|
41
38
|
}
|
|
42
|
-
this.
|
|
43
|
-
this.setupEnableButton();
|
|
39
|
+
this.setupMotionFunction(accessory);
|
|
44
40
|
this.setupMotionButton();
|
|
45
41
|
this.setupLightButton();
|
|
46
42
|
}
|
|
47
43
|
setupButtonService(serviceName, configValue, PropertyName, serviceType) {
|
|
48
44
|
try {
|
|
49
45
|
this.platform.log.debug(`${this.accessory.displayName} ${serviceName} config:`, configValue);
|
|
50
|
-
if (configValue && this.
|
|
46
|
+
if (configValue && this.device.hasProperty(PropertyName)) {
|
|
51
47
|
// eslint-disable-next-line max-len
|
|
52
48
|
this.platform.log.debug(`${this.accessory.displayName} has a ${PropertyName}, so append ${serviceType}${serviceName} characteristic to it.`);
|
|
53
|
-
|
|
54
|
-
this.service.addLinkedService(newService);
|
|
49
|
+
this.setupSwitchService(serviceName, serviceType, PropertyName);
|
|
55
50
|
}
|
|
56
51
|
else {
|
|
57
52
|
// eslint-disable-next-line max-len
|
|
@@ -77,7 +72,7 @@ class CameraAccessory extends Device_1.DeviceAccessory {
|
|
|
77
72
|
let config = {};
|
|
78
73
|
if (typeof this.platform.config.cameras !== 'undefined') {
|
|
79
74
|
// eslint-disable-next-line prefer-arrow-callback, brace-style
|
|
80
|
-
const pos = this.platform.config.cameras.map(function (e) { return e.serialNumber; }).indexOf(this.
|
|
75
|
+
const pos = this.platform.config.cameras.map(function (e) { return e.serialNumber; }).indexOf(this.device.getSerial());
|
|
81
76
|
config = { ...this.platform.config.cameras[pos] };
|
|
82
77
|
}
|
|
83
78
|
config.name = this.accessory.displayName;
|
|
@@ -93,7 +88,7 @@ class CameraAccessory extends Device_1.DeviceAccessory {
|
|
|
93
88
|
config.snapshotHandlingMethod = (config.forcerefreshsnap) ? 1 : 3;
|
|
94
89
|
}
|
|
95
90
|
config.talkback = (_j = config.talkback) !== null && _j !== void 0 ? _j : (config.talkback = false);
|
|
96
|
-
if (config.talkback && !this.
|
|
91
|
+
if (config.talkback && !this.device.hasCommand(eufy_security_client_1.CommandName.DeviceStartTalkback)) {
|
|
97
92
|
this.platform.log.warn(this.accessory.displayName, 'Talkback for this device is not supported!');
|
|
98
93
|
config.talkback = false;
|
|
99
94
|
}
|
|
@@ -104,44 +99,78 @@ class CameraAccessory extends Device_1.DeviceAccessory {
|
|
|
104
99
|
return config;
|
|
105
100
|
}
|
|
106
101
|
cameraFunction() {
|
|
107
|
-
|
|
108
|
-
this.
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
102
|
+
this.registerCharacteristic({
|
|
103
|
+
serviceType: this.platform.Service.CameraOperatingMode,
|
|
104
|
+
characteristicType: this.platform.Characteristic.EventSnapshotsActive,
|
|
105
|
+
getValue: (data) => this.handleDummyEventGet('EventSnapshotsActive'),
|
|
106
|
+
setValue: (value) => this.handleDummyEventSet('EventSnapshotsActive', value),
|
|
107
|
+
});
|
|
108
|
+
this.registerCharacteristic({
|
|
109
|
+
serviceType: this.platform.Service.CameraOperatingMode,
|
|
110
|
+
characteristicType: this.platform.Characteristic.HomeKitCameraActive,
|
|
111
|
+
// eslint-disable-next-line max-len
|
|
112
|
+
getValue: (data) => this.getCameraPropertyValue('this.platform.Characteristic.HomeKitCameraActive', eufy_security_client_1.PropertyName.DeviceEnabled),
|
|
113
|
+
// eslint-disable-next-line max-len
|
|
114
|
+
setValue: (value) => this.setCameraPropertyValue('this.platform.Characteristic.HomeKitCameraActive', eufy_security_client_1.PropertyName.DeviceEnabled, value),
|
|
115
|
+
});
|
|
116
|
+
if (this.device.hasProperty('enabled')) {
|
|
117
|
+
this.setupEnableButton();
|
|
118
|
+
this.registerCharacteristic({
|
|
119
|
+
serviceType: this.platform.Service.CameraOperatingMode,
|
|
120
|
+
characteristicType: this.platform.Characteristic.ManuallyDisabled,
|
|
121
|
+
// eslint-disable-next-line max-len
|
|
122
|
+
getValue: (data) => this.getCameraPropertyValue('this.platform.Characteristic.ManuallyDisabled', eufy_security_client_1.PropertyName.DeviceEnabled),
|
|
123
|
+
});
|
|
119
124
|
}
|
|
120
|
-
if (this.
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
125
|
+
if (this.device.hasProperty('statusLed')) {
|
|
126
|
+
this.registerCharacteristic({
|
|
127
|
+
serviceType: this.platform.Service.CameraOperatingMode,
|
|
128
|
+
characteristicType: this.platform.Characteristic.CameraOperatingModeIndicator,
|
|
129
|
+
// eslint-disable-next-line max-len
|
|
130
|
+
getValue: (data) => this.getCameraPropertyValue('this.platform.Characteristic.CameraOperatingModeIndicator', eufy_security_client_1.PropertyName.DeviceStatusLed),
|
|
131
|
+
// eslint-disable-next-line max-len
|
|
132
|
+
setValue: (value) => this.setCameraPropertyValue('this.platform.Characteristic.CameraOperatingModeIndicator', eufy_security_client_1.PropertyName.DeviceStatusLed, value),
|
|
133
|
+
});
|
|
124
134
|
}
|
|
125
|
-
if (this.
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
135
|
+
if (this.device.hasProperty('nightvision')) {
|
|
136
|
+
this.registerCharacteristic({
|
|
137
|
+
serviceType: this.platform.Service.CameraOperatingMode,
|
|
138
|
+
characteristicType: this.platform.Characteristic.NightVision,
|
|
139
|
+
// eslint-disable-next-line max-len
|
|
140
|
+
getValue: (data) => this.getCameraPropertyValue('this.platform.Characteristic.NightVision', eufy_security_client_1.PropertyName.DeviceNightvision),
|
|
141
|
+
// eslint-disable-next-line max-len
|
|
142
|
+
setValue: (value) => this.setCameraPropertyValue('this.platform.Characteristic.NightVision', eufy_security_client_1.PropertyName.DeviceNightvision, value),
|
|
143
|
+
});
|
|
129
144
|
}
|
|
130
|
-
if (this.
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
145
|
+
if (this.device.hasProperty('autoNightvision')) {
|
|
146
|
+
this.registerCharacteristic({
|
|
147
|
+
serviceType: this.platform.Service.CameraOperatingMode,
|
|
148
|
+
characteristicType: this.platform.Characteristic.NightVision,
|
|
149
|
+
// eslint-disable-next-line max-len
|
|
150
|
+
getValue: (data) => this.getCameraPropertyValue('this.platform.Characteristic.NightVision', eufy_security_client_1.PropertyName.DeviceAutoNightvision),
|
|
151
|
+
// eslint-disable-next-line max-len
|
|
152
|
+
setValue: (value) => this.setCameraPropertyValue('this.platform.Characteristic.NightVision', eufy_security_client_1.PropertyName.DeviceAutoNightvision, value),
|
|
153
|
+
});
|
|
134
154
|
}
|
|
135
|
-
|
|
136
|
-
|
|
155
|
+
if (this.device.isDoorbell()) {
|
|
156
|
+
this.registerCharacteristic({
|
|
157
|
+
serviceType: this.platform.Service.Doorbell,
|
|
158
|
+
characteristicType: this.platform.Characteristic.ProgrammableSwitchEvent,
|
|
159
|
+
getValue: (data) => this.handleDummyEventGet('EventSnapshotsActive'),
|
|
160
|
+
onValue: (service, characteristic) => {
|
|
161
|
+
this.device.on('rings', (device, state) => this.onDeviceRingsPushNotification(characteristic));
|
|
162
|
+
},
|
|
163
|
+
});
|
|
164
|
+
}
|
|
165
|
+
this.getService(this.platform.Service.CameraOperatingMode).setPrimaryService(true);
|
|
137
166
|
}
|
|
138
167
|
setupMotionFunction(accessory) {
|
|
139
168
|
try {
|
|
140
169
|
const service = this.accessory.getService(this.platform.Service.MotionSensor) ||
|
|
141
170
|
this.accessory.addService(this.platform.Service.MotionSensor);
|
|
142
|
-
service.setCharacteristic(this.
|
|
143
|
-
service.getCharacteristic(this.
|
|
144
|
-
.onGet(this.
|
|
171
|
+
service.setCharacteristic(this.platform.Characteristic.Name, this.accessory.displayName);
|
|
172
|
+
service.getCharacteristic(this.platform.Characteristic.MotionDetected)
|
|
173
|
+
.onGet(this.getCameraPropertyValue.bind(this, 'this.platform.Characteristic.MotionDetected', eufy_security_client_1.PropertyName.DeviceMotionDetected));
|
|
145
174
|
// List of event types
|
|
146
175
|
const eventTypesToHandle = [
|
|
147
176
|
'motion detected',
|
|
@@ -156,7 +185,7 @@ class CameraAccessory extends Device_1.DeviceAccessory {
|
|
|
156
185
|
// Attach the common event handler to each event type
|
|
157
186
|
eventTypesToHandle.forEach(eventType => {
|
|
158
187
|
this.platform.log.debug(this.accessory.displayName, 'SETON Firing on:', eventType);
|
|
159
|
-
this.
|
|
188
|
+
this.device.on(eventType, (device, motion) => this.onDeviceEventDetectedPushNotification(device, motion, eventType));
|
|
160
189
|
});
|
|
161
190
|
return service;
|
|
162
191
|
}
|
|
@@ -170,9 +199,9 @@ class CameraAccessory extends Device_1.DeviceAccessory {
|
|
|
170
199
|
if (motion) {
|
|
171
200
|
this.motionTimeout = setTimeout(() => {
|
|
172
201
|
this.platform.log.debug(this.accessory.displayName, 'Reseting motion through timout.');
|
|
173
|
-
this.service
|
|
174
|
-
|
|
175
|
-
|
|
202
|
+
// this.service
|
|
203
|
+
// .getCharacteristic(this.platform.Characteristic.MotionDetected)
|
|
204
|
+
// .updateValue(false);
|
|
176
205
|
}, 15000);
|
|
177
206
|
}
|
|
178
207
|
else {
|
|
@@ -183,9 +212,9 @@ class CameraAccessory extends Device_1.DeviceAccessory {
|
|
|
183
212
|
if (this.cameraConfig.useCachedLocalLivestream && this.streamingDelegate && motion) {
|
|
184
213
|
this.streamingDelegate.prepareCachedStream();
|
|
185
214
|
}
|
|
186
|
-
this.service
|
|
187
|
-
|
|
188
|
-
|
|
215
|
+
// this.service
|
|
216
|
+
// .getCharacteristic(this.platform.Characteristic.MotionDetected)
|
|
217
|
+
// .updateValue(motion);
|
|
189
218
|
}
|
|
190
219
|
setupSwitchService(serviceName, serviceType, propertyName) {
|
|
191
220
|
const platformServiceMapping = {
|
|
@@ -194,17 +223,18 @@ class CameraAccessory extends Device_1.DeviceAccessory {
|
|
|
194
223
|
outlet: this.platform.Service.Outlet,
|
|
195
224
|
};
|
|
196
225
|
const platformService = platformServiceMapping[serviceType] || this.platform.Service.Switch;
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
226
|
+
this.registerCharacteristic({
|
|
227
|
+
serviceType: platformService,
|
|
228
|
+
characteristicType: this.platform.Characteristic.On,
|
|
229
|
+
name: this.accessory.displayName + '_' + serviceName,
|
|
230
|
+
serviceSubType: serviceName,
|
|
231
|
+
getValue: (data) => this.getCameraPropertyValue('this.platform.Characteristic.On', propertyName),
|
|
232
|
+
setValue: (value) => this.setCameraPropertyValue('this.platform.Characteristic.On', propertyName, value),
|
|
233
|
+
});
|
|
204
234
|
}
|
|
205
|
-
|
|
235
|
+
getCameraPropertyValue(characteristic, propertyName) {
|
|
206
236
|
try {
|
|
207
|
-
let value =
|
|
237
|
+
let value = this.device.getPropertyValue(propertyName);
|
|
208
238
|
this.platform.log.debug(`${this.accessory.displayName} GET '${characteristic}' ${propertyName}: ${value}`);
|
|
209
239
|
if (propertyName === eufy_security_client_1.PropertyName.DeviceNightvision) {
|
|
210
240
|
return value === 1;
|
|
@@ -216,7 +246,7 @@ class CameraAccessory extends Device_1.DeviceAccessory {
|
|
|
216
246
|
this.platform.log.debug(`${this.accessory.displayName} CACHED for (1 min) '${characteristic}' ${propertyName}: ${this.cameraStatus.isEnabled}`);
|
|
217
247
|
value = this.cameraStatus.isEnabled;
|
|
218
248
|
}
|
|
219
|
-
if (characteristic === 'this.
|
|
249
|
+
if (characteristic === 'this.platform.Characteristic.ManuallyDisabled') {
|
|
220
250
|
this.platform.log.debug(`${this.accessory.displayName} INVERSED '${characteristic}' ${propertyName}: ${!value}`);
|
|
221
251
|
value = !value;
|
|
222
252
|
}
|
|
@@ -230,44 +260,45 @@ class CameraAccessory extends Device_1.DeviceAccessory {
|
|
|
230
260
|
return false;
|
|
231
261
|
}
|
|
232
262
|
}
|
|
233
|
-
async
|
|
263
|
+
async setCameraPropertyValue(characteristic, propertyName, value) {
|
|
234
264
|
try {
|
|
235
265
|
// eslint-disable-next-line max-len
|
|
236
266
|
this.platform.log.debug(`${this.accessory.displayName} SET '${typeof characteristic} / ${characteristic}' ${propertyName}: ${value}`);
|
|
237
|
-
const station = await this.platform.getStationById(this.
|
|
267
|
+
const station = await this.platform.getStationById(this.device.getStationSerial());
|
|
268
|
+
const cameraService = this.getService(this.platform.Service.CameraOperatingMode);
|
|
238
269
|
switch (propertyName) {
|
|
239
270
|
case eufy_security_client_1.PropertyName.DeviceEnabled: {
|
|
240
|
-
if (characteristic === 'this.
|
|
271
|
+
if (characteristic === 'this.platform.Characteristic.On') {
|
|
241
272
|
this.cameraStatus = { isEnabled: value, timestamp: Date.now() };
|
|
242
|
-
await station.enableDevice(this.
|
|
243
|
-
|
|
273
|
+
await station.enableDevice(this.device, value);
|
|
274
|
+
cameraService.updateCharacteristic(this.platform.Characteristic.ManuallyDisabled, !value);
|
|
244
275
|
}
|
|
245
276
|
break;
|
|
246
277
|
}
|
|
247
278
|
case eufy_security_client_1.PropertyName.DeviceMotionDetection: {
|
|
248
|
-
await station.setMotionDetection(this.
|
|
249
|
-
|
|
279
|
+
await station.setMotionDetection(this.device, value);
|
|
280
|
+
cameraService.updateCharacteristic(this.platform.Characteristic.CameraOperatingModeIndicator, value);
|
|
250
281
|
break;
|
|
251
282
|
}
|
|
252
283
|
case eufy_security_client_1.PropertyName.DeviceStatusLed: {
|
|
253
|
-
await station.setStatusLed(this.
|
|
254
|
-
|
|
284
|
+
await station.setStatusLed(this.device, value);
|
|
285
|
+
cameraService.updateCharacteristic(this.platform.Characteristic.CameraOperatingModeIndicator, value);
|
|
255
286
|
break;
|
|
256
287
|
}
|
|
257
288
|
case eufy_security_client_1.PropertyName.DeviceNightvision: {
|
|
258
289
|
// Convert true to 1 (B&W Night Vision) and false to 0 (off)
|
|
259
|
-
await station.setNightVision(this.
|
|
260
|
-
|
|
290
|
+
await station.setNightVision(this.device, Number(value));
|
|
291
|
+
cameraService.updateCharacteristic(this.platform.Characteristic.NightVision, value);
|
|
261
292
|
break;
|
|
262
293
|
}
|
|
263
294
|
case eufy_security_client_1.PropertyName.DeviceAutoNightvision: {
|
|
264
|
-
await station.setAutoNightVision(this.
|
|
265
|
-
|
|
295
|
+
await station.setAutoNightVision(this.device, value);
|
|
296
|
+
cameraService.updateCharacteristic(this.platform.Characteristic.NightVision, value);
|
|
266
297
|
break;
|
|
267
298
|
}
|
|
268
299
|
case eufy_security_client_1.PropertyName.DeviceLight: {
|
|
269
|
-
await station.switchLight(this.
|
|
270
|
-
this.service.updateCharacteristic(this.
|
|
300
|
+
await station.switchLight(this.device, value);
|
|
301
|
+
// this.service.updateCharacteristic(this.platform.Characteristic.On, value as boolean);
|
|
271
302
|
break;
|
|
272
303
|
}
|
|
273
304
|
default: {
|
|
@@ -282,23 +313,10 @@ class CameraAccessory extends Device_1.DeviceAccessory {
|
|
|
282
313
|
this.platform.log.debug(`${this.accessory.displayName} Error setting '${characteristic}' ${propertyName}: ${error}`);
|
|
283
314
|
}
|
|
284
315
|
}
|
|
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
|
-
}
|
|
296
|
-
}
|
|
297
|
-
}
|
|
298
316
|
handleDummyEventGet(serviceName) {
|
|
299
317
|
const characteristicValues = {
|
|
300
|
-
'EventSnapshotsActive': this.
|
|
301
|
-
'HomeKitCameraActive': this.
|
|
318
|
+
'EventSnapshotsActive': this.platform.Characteristic.EventSnapshotsActive.DISABLE,
|
|
319
|
+
'HomeKitCameraActive': this.platform.Characteristic.HomeKitCameraActive.OFF,
|
|
302
320
|
};
|
|
303
321
|
const currentValue = characteristicValues[serviceName];
|
|
304
322
|
if (currentValue === undefined) {
|
|
@@ -310,6 +328,21 @@ class CameraAccessory extends Device_1.DeviceAccessory {
|
|
|
310
328
|
handleDummyEventSet(serviceName, value) {
|
|
311
329
|
this.platform.log.debug(`${this.accessory.displayName} SET ${serviceName}: ${value}`);
|
|
312
330
|
}
|
|
331
|
+
// We receive 2 push when Doorbell ring, mute the second by checking if we already send
|
|
332
|
+
// the event to HK then reset the marker when 2nd times occurs
|
|
333
|
+
onDeviceRingsPushNotification(characteristic) {
|
|
334
|
+
if (!this.ring_triggered) {
|
|
335
|
+
this.ring_triggered = true;
|
|
336
|
+
this.platform.log.debug(this.accessory.displayName, 'DoorBell ringing');
|
|
337
|
+
if (this.cameraConfig.useCachedLocalLivestream && this.streamingDelegate) {
|
|
338
|
+
this.streamingDelegate.prepareCachedStream();
|
|
339
|
+
}
|
|
340
|
+
characteristic.updateValue(this.platform.Characteristic.ProgrammableSwitchEvent.SINGLE_PRESS);
|
|
341
|
+
}
|
|
342
|
+
else {
|
|
343
|
+
this.ring_triggered = false;
|
|
344
|
+
}
|
|
345
|
+
}
|
|
313
346
|
}
|
|
314
347
|
exports.CameraAccessory = CameraAccessory;
|
|
315
348
|
//# sourceMappingURL=CameraAccessory.js.map
|