homebridge-eufy-security 2.2.4 → 2.3.0

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.
Files changed (102) hide show
  1. package/CHANGELOG.md +39 -11
  2. package/README.md +26 -25
  3. package/dist/accessories/CameraAccessory.d.ts +55 -21
  4. package/dist/accessories/CameraAccessory.d.ts.map +1 -1
  5. package/dist/accessories/CameraAccessory.js +460 -214
  6. package/dist/accessories/CameraAccessory.js.map +1 -1
  7. package/dist/accessories/Device.d.ts +3 -3
  8. package/dist/accessories/Device.d.ts.map +1 -1
  9. package/dist/accessories/Device.js +15 -0
  10. package/dist/accessories/Device.js.map +1 -1
  11. package/dist/accessories/DoorbellCameraAccessory.d.ts +4 -1
  12. package/dist/accessories/DoorbellCameraAccessory.d.ts.map +1 -1
  13. package/dist/accessories/DoorbellCameraAccessory.js +65 -4
  14. package/dist/accessories/DoorbellCameraAccessory.js.map +1 -1
  15. package/dist/accessories/SmartLockAccessory.d.ts +2 -2
  16. package/dist/accessories/StationAccessory.d.ts +4 -0
  17. package/dist/accessories/StationAccessory.d.ts.map +1 -1
  18. package/dist/accessories/StationAccessory.js +64 -7
  19. package/dist/accessories/StationAccessory.js.map +1 -1
  20. package/dist/config.d.ts +4 -0
  21. package/dist/config.d.ts.map +1 -1
  22. package/dist/controller/LocalLivestreamManager.d.ts +3 -8
  23. package/dist/controller/LocalLivestreamManager.d.ts.map +1 -1
  24. package/dist/controller/LocalLivestreamManager.js +4 -47
  25. package/dist/controller/LocalLivestreamManager.js.map +1 -1
  26. package/dist/controller/SnapshotManager.d.ts +1 -1
  27. package/dist/controller/SnapshotManager.d.ts.map +1 -1
  28. package/dist/controller/SnapshotManager.js +23 -1
  29. package/dist/controller/SnapshotManager.js.map +1 -1
  30. package/dist/controller/recordingDelegate.d.ts +29 -0
  31. package/dist/controller/recordingDelegate.d.ts.map +1 -0
  32. package/dist/controller/recordingDelegate.js +186 -0
  33. package/dist/controller/recordingDelegate.js.map +1 -0
  34. package/dist/controller/streamingDelegate.d.ts +6 -6
  35. package/dist/controller/streamingDelegate.d.ts.map +1 -1
  36. package/dist/controller/streamingDelegate.js +21 -60
  37. package/dist/controller/streamingDelegate.js.map +1 -1
  38. package/dist/index.d.ts +1 -1
  39. package/dist/index.d.ts.map +1 -1
  40. package/dist/platform.d.ts +6 -0
  41. package/dist/platform.d.ts.map +1 -1
  42. package/dist/platform.js +112 -66
  43. package/dist/platform.js.map +1 -1
  44. package/dist/utils/EufyClientInteractor.d.ts +36 -0
  45. package/dist/utils/EufyClientInteractor.d.ts.map +1 -0
  46. package/dist/utils/EufyClientInteractor.js +357 -0
  47. package/dist/utils/EufyClientInteractor.js.map +1 -0
  48. package/dist/utils/Talkback.d.ts +0 -1
  49. package/dist/utils/Talkback.d.ts.map +1 -1
  50. package/dist/utils/configTypes.d.ts +15 -5
  51. package/dist/utils/configTypes.d.ts.map +1 -1
  52. package/dist/utils/experimental.d.ts +4 -0
  53. package/dist/utils/experimental.d.ts.map +1 -0
  54. package/dist/utils/experimental.js +49 -0
  55. package/dist/utils/experimental.js.map +1 -0
  56. package/dist/utils/ffmpeg.d.ts +30 -4
  57. package/dist/utils/ffmpeg.d.ts.map +1 -1
  58. package/dist/utils/ffmpeg.js +322 -30
  59. package/dist/utils/ffmpeg.js.map +1 -1
  60. package/dist/utils/interfaces.d.ts +13 -0
  61. package/dist/utils/interfaces.d.ts.map +1 -0
  62. package/dist/utils/interfaces.js +12 -0
  63. package/dist/utils/interfaces.js.map +1 -0
  64. package/homebridge-ui/configui/app/accessory.d.ts +1 -1
  65. package/homebridge-ui/configui/app/accessory.d.ts.map +1 -1
  66. package/homebridge-ui/configui/app/util/types.d.ts +2 -2
  67. package/homebridge-ui/configui/app/util/types.d.ts.map +1 -1
  68. package/homebridge-ui/configui/app/util/types.js +1 -1
  69. package/homebridge-ui/configui/app/util/types.js.map +1 -1
  70. package/homebridge-ui/plugin/utils/EufyClientInteractor.d.ts +36 -0
  71. package/homebridge-ui/plugin/utils/EufyClientInteractor.d.ts.map +1 -0
  72. package/homebridge-ui/plugin/utils/EufyClientInteractor.js +357 -0
  73. package/homebridge-ui/plugin/utils/EufyClientInteractor.js.map +1 -0
  74. package/homebridge-ui/plugin/utils/experimental.d.ts +4 -0
  75. package/homebridge-ui/plugin/utils/experimental.d.ts.map +1 -0
  76. package/homebridge-ui/plugin/utils/experimental.js +49 -0
  77. package/homebridge-ui/plugin/utils/experimental.js.map +1 -0
  78. package/homebridge-ui/plugin/utils/interfaces.d.ts +13 -0
  79. package/homebridge-ui/plugin/utils/interfaces.d.ts.map +1 -0
  80. package/homebridge-ui/plugin/utils/interfaces.js +12 -0
  81. package/homebridge-ui/plugin/utils/interfaces.js.map +1 -0
  82. package/homebridge-ui/plugin/utils/logger.d.ts +12 -0
  83. package/homebridge-ui/plugin/utils/logger.d.ts.map +1 -0
  84. package/homebridge-ui/plugin/utils/logger.js +36 -0
  85. package/homebridge-ui/plugin/utils/logger.js.map +1 -0
  86. package/homebridge-ui/public/3rdpartylicenses.txt +191 -6
  87. package/homebridge-ui/public/index.html +2 -2
  88. package/homebridge-ui/public/main.22a0c49e2138888f.js +1 -0
  89. package/homebridge-ui/public/polyfills.6050693665c0e882.js +1 -0
  90. package/homebridge-ui/public/styles.e02689e7df4304da.css +6 -0
  91. package/homebridge-ui/server.js +17 -1
  92. package/homebridge-ui/server.js.map +1 -1
  93. package/package.json +48 -46
  94. package/homebridge-ui/public/assets/devices/4g_lte_starlight_large.jpg +0 -0
  95. package/homebridge-ui/public/assets/devices/garage_camera_t8452_large.jpg +0 -0
  96. package/homebridge-ui/public/assets/devices/smartdrop_t8790_large.jpg +0 -0
  97. package/homebridge-ui/public/assets/devices/smartsafe_s10_t7400_large.jpg +0 -0
  98. package/homebridge-ui/public/assets/devices/smartsafe_s12_t7401_large.jpg +0 -0
  99. package/homebridge-ui/public/assets/devices/walllight_s100_large.jpg +0 -0
  100. package/homebridge-ui/public/main.0d25748cc9303f6b.js +0 -1
  101. package/homebridge-ui/public/polyfills.cdb21ff95fdea645.js +0 -1
  102. package/homebridge-ui/public/styles.021488511c20c432.css +0 -5
@@ -2,78 +2,272 @@
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
- // eslint-disable-next-line @typescript-eslint/ban-ts-comment
7
- // @ts-ignore
8
5
  const eufy_security_client_1 = require("eufy-security-client");
9
6
  const streamingDelegate_1 = require("../controller/streamingDelegate");
7
+ const recordingDelegate_1 = require("../controller/recordingDelegate");
8
+ const experimental_1 = require("../utils/experimental");
10
9
  /**
11
10
  * Platform Accessory
12
11
  * An instance of this class is created for each accessory your platform registers
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, eufyDevice) {
15
+ constructor(platform, accessory, eufyDevice, isDoorbell = false) {
16
+ var _a, _b, _c, _d;
17
17
  super(platform, accessory, eufyDevice);
18
18
  this.streamingDelegate = null;
19
19
  this.service = {};
20
20
  this.CameraService = {};
21
21
  this.cameraConfig = {};
22
- this.cameraStatus = { isEnabled: false, timestamp: 0 }; // Initialize the cameraStatus object
23
22
  this.platform.log.debug(this.accessory.displayName, 'Constructed Camera');
24
23
  this.cameraConfig = this.getCameraConfig();
25
24
  this.platform.log.debug(this.accessory.displayName, 'config is:', this.cameraConfig);
25
+ try {
26
+ this.service = this.motionFunction(accessory);
27
+ }
28
+ catch (Error) {
29
+ this.platform.log.error(this.accessory.displayName, 'raise error to check and attach motion function.', Error);
30
+ }
26
31
  if (this.cameraConfig.enableCamera || (typeof this.eufyDevice.isDoorbell === 'function' && this.eufyDevice.isDoorbell())) {
27
32
  this.platform.log.debug(this.accessory.displayName, 'has a camera');
28
33
  try {
29
- this.CameraService = this.cameraFunction();
30
- this.CameraService.setPrimaryService(true);
31
34
  const delegate = new streamingDelegate_1.StreamingDelegate(this.platform, eufyDevice, this.cameraConfig, this.platform.api, this.platform.api.hap);
32
35
  this.streamingDelegate = delegate;
33
- accessory.configureController(delegate.controller);
36
+ this.recordingDelegate = new recordingDelegate_1.RecordingDelegate(this.platform, this.accessory, eufyDevice, this.cameraConfig, this.streamingDelegate.getLivestreamManager(), this.platform.log);
37
+ let samplerate = 16 /* KHZ_16 */;
38
+ if (((_a = this.cameraConfig.videoConfig) === null || _a === void 0 ? void 0 : _a.audioSampleRate) === 8) {
39
+ samplerate = 8 /* KHZ_8 */;
40
+ }
41
+ else if (((_b = this.cameraConfig.videoConfig) === null || _b === void 0 ? void 0 : _b.audioSampleRate) === 24) {
42
+ samplerate = 24 /* KHZ_24 */;
43
+ }
44
+ let audioCodecType = "AAC-eld" /* AAC_ELD */;
45
+ if ((_c = this.cameraConfig.videoConfig) === null || _c === void 0 ? void 0 : _c.acodecHK) {
46
+ audioCodecType = this.cameraConfig.videoConfig.acodecHK;
47
+ }
48
+ this.platform.log.debug(this.accessory.displayName, `Audio sample rate set to ${samplerate} kHz.`);
49
+ this.platform.log.debug(this.accessory.displayName, `Audio Codec for HK: ${audioCodecType}`);
50
+ this.cameraControllerOptions = {
51
+ cameraStreamCount: ((_d = this.cameraConfig.videoConfig) === null || _d === void 0 ? void 0 : _d.maxStreams) || 2,
52
+ delegate: this.streamingDelegate,
53
+ streamingOptions: {
54
+ supportedCryptoSuites: [0 /* AES_CM_128_HMAC_SHA1_80 */],
55
+ video: {
56
+ resolutions: [
57
+ [320, 180, 30],
58
+ [320, 240, 15],
59
+ [320, 240, 30],
60
+ [480, 270, 30],
61
+ [480, 360, 30],
62
+ [640, 360, 30],
63
+ [640, 480, 30],
64
+ [1280, 720, 30],
65
+ [1280, 960, 30],
66
+ [1920, 1080, 30],
67
+ [1600, 1200, 30],
68
+ ],
69
+ codec: {
70
+ profiles: [
71
+ 0 /* BASELINE */,
72
+ 1 /* MAIN */,
73
+ 2 /* HIGH */,
74
+ ],
75
+ levels: [
76
+ 0 /* LEVEL3_1 */,
77
+ 1 /* LEVEL3_2 */,
78
+ 2 /* LEVEL4_0 */,
79
+ ],
80
+ },
81
+ },
82
+ audio: {
83
+ twoWayAudio: this.cameraConfig.talkback,
84
+ codecs: [
85
+ {
86
+ type: audioCodecType,
87
+ samplerate: samplerate,
88
+ },
89
+ ],
90
+ },
91
+ },
92
+ recording: this.cameraConfig.hsv
93
+ ? {
94
+ options: {
95
+ overrideEventTriggerOptions: [
96
+ 1 /* MOTION */,
97
+ 2 /* DOORBELL */,
98
+ ],
99
+ prebufferLength: 0,
100
+ mediaContainerConfiguration: [
101
+ {
102
+ type: 0 /* FRAGMENTED_MP4 */,
103
+ fragmentLength: 4000,
104
+ },
105
+ ],
106
+ video: {
107
+ type: 0 /* H264 */,
108
+ parameters: {
109
+ profiles: [
110
+ 0 /* BASELINE */,
111
+ 1 /* MAIN */,
112
+ 2 /* HIGH */,
113
+ ],
114
+ levels: [
115
+ 0 /* LEVEL3_1 */,
116
+ 1 /* LEVEL3_2 */,
117
+ 2 /* LEVEL4_0 */,
118
+ ],
119
+ },
120
+ resolutions: [
121
+ [320, 180, 30],
122
+ [320, 240, 15],
123
+ [320, 240, 30],
124
+ [480, 270, 30],
125
+ [480, 360, 30],
126
+ [640, 360, 30],
127
+ [640, 480, 30],
128
+ [1280, 720, 30],
129
+ [1280, 960, 30],
130
+ [1920, 1080, 30],
131
+ [1600, 1200, 30],
132
+ ],
133
+ },
134
+ audio: {
135
+ codecs: {
136
+ type: 1 /* AAC_ELD */,
137
+ samplerate: 2 /* KHZ_24 */,
138
+ bitrateMode: 0,
139
+ audioChannels: 1,
140
+ },
141
+ },
142
+ },
143
+ delegate: this.recordingDelegate,
144
+ }
145
+ : undefined,
146
+ sensors: this.cameraConfig.hsv
147
+ ? {
148
+ motion: this.service,
149
+ // eslint-disable-next-line max-len
150
+ // occupancy: this.accessory.getServiceById(this.platform.api.hap.Service.OccupancySensor, 'occupancy') || false, //not implemented yet
151
+ }
152
+ : undefined,
153
+ };
154
+ if (!isDoorbell) {
155
+ const controller = new this.platform.api.hap.CameraController(this.cameraControllerOptions);
156
+ this.streamingDelegate.setController(controller);
157
+ this.recordingDelegate.setController(controller);
158
+ accessory.configureController(controller);
159
+ this.cameraSetup(accessory);
160
+ }
34
161
  }
35
- catch (error) {
36
- this.platform.log.error(this.accessory.displayName, 'raise error to check and attach livestream function.', error);
162
+ catch (Error) {
163
+ this.platform.log.error(this.accessory.displayName, 'raise error to check and attach livestream function.', Error);
37
164
  }
38
165
  }
39
166
  else {
40
167
  this.platform.log.debug(this.accessory.displayName, 'has a motion sensor.');
168
+ // remove camera operating mode service if the user has disabled the camera through the config
169
+ const operatingModeService = accessory.getService(this.platform.api.hap.Service.CameraOperatingMode);
170
+ if (operatingModeService) {
171
+ this.platform.log.debug(this.accessory.displayName, 'removing CameraOperatingMode service.');
172
+ accessory.removeService(operatingModeService);
173
+ }
174
+ }
175
+ try {
176
+ this.platform.log.debug(this.accessory.displayName, 'enableButton config:', this.cameraConfig.enableButton);
177
+ if (this.cameraConfig.enableButton
178
+ && this.eufyDevice.hasProperty('enabled')) {
179
+ this.platform.log.debug(this.accessory.displayName, 'has a isEnabled, so append switchEnabledService characteristic to him.');
180
+ const switchEnabledService = this.accessory.getService('Enabled') ||
181
+ this.accessory.addService(this.platform.Service.Switch, 'Enabled', 'enabled');
182
+ switchEnabledService.setCharacteristic(this.platform.Characteristic.Name, accessory.displayName + ' Enabled');
183
+ // switchEnabledService.setCharacteristic(
184
+ // this.platform.Characteristic.ConfiguredName,
185
+ // accessory.displayName + ' Enabled',
186
+ // );
187
+ switchEnabledService.getCharacteristic(this.characteristic.On)
188
+ .onGet(this.handleEnableGet.bind(this))
189
+ .onSet(this.handleEnableSet.bind(this));
190
+ }
191
+ else {
192
+ // eslint-disable-next-line max-len
193
+ this.platform.log.debug(this.accessory.displayName, 'Looks like not compatible with isEnabled or this has been disabled within configuration');
194
+ // remove enableButton service if the user has disabled the it through the config
195
+ const enableButtonService = accessory.getService('Enabled');
196
+ if (enableButtonService) {
197
+ this.platform.log.debug(this.accessory.displayName, 'removing enableButton service.');
198
+ accessory.removeService(enableButtonService);
199
+ }
200
+ }
201
+ }
202
+ catch (Error) {
203
+ this.platform.log.error(this.accessory.displayName, 'raise error to check and attach switchEnabledService.', Error);
41
204
  }
42
- this.service = this.setupMotionFunction(accessory);
43
- this.setupEnableButton();
44
- this.setupMotionButton();
45
- this.setupLightButton();
46
- }
47
- setupButtonService(serviceName, configValue, PropertyName, serviceType) {
48
205
  try {
49
- this.platform.log.debug(`${this.accessory.displayName} ${serviceName} config:`, configValue);
50
- if (configValue && this.eufyDevice.hasProperty(PropertyName)) {
206
+ this.platform.log.debug(this.accessory.displayName, 'motionButton config:', this.cameraConfig.motionButton);
207
+ if (this.cameraConfig.motionButton && this.eufyDevice.hasProperty('motionDetection')) {
51
208
  // eslint-disable-next-line max-len
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);
209
+ this.platform.log.debug(this.accessory.displayName, 'has a isMotionDetectionEnabled, so append switchMotionService characteristic to him.');
210
+ const switchMotionService = this.accessory.getService('Motion') ||
211
+ this.accessory.addService(this.platform.Service.Switch, 'Motion', 'motion');
212
+ switchMotionService.setCharacteristic(this.platform.Characteristic.Name, accessory.displayName + ' Motion');
213
+ // switchMotionService.setCharacteristic(
214
+ // this.platform.Characteristic.ConfiguredName,
215
+ // accessory.displayName + ' Motion',
216
+ // );
217
+ switchMotionService.getCharacteristic(this.characteristic.On)
218
+ .onGet(this.handleMotionOnGet.bind(this))
219
+ .onSet(this.handleMotionOnSet.bind(this));
55
220
  }
56
221
  else {
57
222
  // eslint-disable-next-line max-len
58
- this.platform.log.debug(`${this.accessory.displayName} Looks like not compatible with ${PropertyName} or this has been disabled within configuration`);
223
+ this.platform.log.debug(this.accessory.displayName, 'Looks like not compatible with isMotionDetectionEnabled or this has been disabled within configuration');
224
+ // remove enableButton service if the user has disabled the it through the config
225
+ const motionButtonService = accessory.getService('Motion');
226
+ if (motionButtonService) {
227
+ this.platform.log.debug(this.accessory.displayName, 'removing motionButton service.');
228
+ accessory.removeService(motionButtonService);
229
+ }
59
230
  }
60
231
  }
61
- catch (error) {
62
- this.platform.log.error(`${this.accessory.displayName} raise error to check and attach ${serviceType}${serviceName}.`, error);
63
- throw Error;
232
+ catch (Error) {
233
+ this.platform.log.error(this.accessory.displayName, 'raise error to check and attach switchMotionService.', Error);
234
+ }
235
+ try {
236
+ if (this.eufyDevice.hasProperty('light') && (typeof this.eufyDevice.isFloodLight === 'function' && this.eufyDevice.isFloodLight())) {
237
+ this.platform.log.debug(this.accessory.displayName, 'has a DeviceLight, so append switchLightService characteristic to him.');
238
+ const switchLightService = this.accessory.getService('Light') ||
239
+ this.accessory.addService(this.platform.Service.Switch, 'Light', 'light');
240
+ switchLightService.setCharacteristic(this.platform.Characteristic.Name, accessory.displayName + ' Light');
241
+ // switchLightService.setCharacteristic(
242
+ // this.platform.Characteristic.ConfiguredName,
243
+ // accessory.displayName + ' Light',
244
+ // );
245
+ switchLightService.getCharacteristic(this.characteristic.On)
246
+ .onGet(this.handleLightOnGet.bind(this))
247
+ .onSet(this.handleLightOnSet.bind(this));
248
+ }
249
+ else {
250
+ this.platform.log.debug(this.accessory.displayName, 'Looks like not compatible with DeviceLight');
251
+ }
252
+ }
253
+ catch (Error) {
254
+ this.platform.log.error(this.accessory.displayName, 'raise error to check and attach switchLightService.', Error);
64
255
  }
65
256
  }
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');
257
+ /**
258
+ * Handle the setting of ExperimentalMode since it can not be achieve through the constructor since getStationById is async.
259
+ */
260
+ async setExperimentalMode() {
261
+ // experimental mode
262
+ if (this.platform.config.experimentalMode && this.eufyDevice.hasProperty('experimentalModification')) {
263
+ const value = !!this.cameraConfig.experimentalRTSP;
264
+ const station = await this.platform.getStationById(this.eufyDevice.getStationSerial());
265
+ this.platform.log.debug(this.accessory.displayName, `Setting experimental RTSP capabilities to: ${value}`);
266
+ (0, experimental_1.setRTSPCapability)(station, this.eufyDevice, value);
267
+ }
74
268
  }
75
269
  getCameraConfig() {
76
- var _a, _b, _c, _d, _e, _f, _g, _h, _j;
270
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p;
77
271
  let config = {};
78
272
  if (typeof this.platform.config.cameras !== 'undefined') {
79
273
  // eslint-disable-next-line prefer-arrow-callback, brace-style
@@ -86,13 +280,31 @@ class CameraAccessory extends Device_1.DeviceAccessory {
86
280
  config.rtsp = (_c = config.rtsp) !== null && _c !== void 0 ? _c : (config.rtsp = false);
87
281
  config.forcerefreshsnap = (_d = config.forcerefreshsnap) !== null && _d !== void 0 ? _d : (config.forcerefreshsnap = false);
88
282
  config.videoConfig = (_e = config.videoConfig) !== null && _e !== void 0 ? _e : (config.videoConfig = {});
89
- config.useCachedLocalLivestream = (_f = config.useCachedLocalLivestream) !== null && _f !== void 0 ? _f : (config.useCachedLocalLivestream = false);
90
- config.immediateRingNotificationWithoutSnapshot = (_g = config.immediateRingNotificationWithoutSnapshot) !== null && _g !== void 0 ? _g : (config.immediateRingNotificationWithoutSnapshot = false);
91
- config.delayCameraSnapshot = (_h = config.delayCameraSnapshot) !== null && _h !== void 0 ? _h : (config.delayCameraSnapshot = false);
283
+ config.immediateRingNotificationWithoutSnapshot = (_f = config.immediateRingNotificationWithoutSnapshot) !== null && _f !== void 0 ? _f : (config.immediateRingNotificationWithoutSnapshot = false);
284
+ config.delayCameraSnapshot = (_g = config.delayCameraSnapshot) !== null && _g !== void 0 ? _g : (config.delayCameraSnapshot = false);
285
+ config.hsv = (_h = config.hsv) !== null && _h !== void 0 ? _h : (config.hsv = false);
286
+ config.hsvRecordingDuration = (_j = config.hsvRecordingDuration) !== null && _j !== void 0 ? _j : (config.hsvRecordingDuration = 90);
287
+ config.hsvConfig = (_k = config.hsvConfig) !== null && _k !== void 0 ? _k : (config.hsvConfig = {});
288
+ config.indoorChimeButton = (_l = config.indoorChimeButton) !== null && _l !== void 0 ? _l : (config.indoorChimeButton = false);
289
+ config.experimentalRTSP = (_m = config.experimentalRTSP) !== null && _m !== void 0 ? _m : (config.experimentalRTSP = false);
290
+ if (config.hsvRecordingDuration < 10) {
291
+ this.platform.log.warn(this.accessory.displayName, 'HomeKit Secure Video recording duration is set to ' + config.hsvRecordingDuration + '. Reverting to minimum of 10 seconds.');
292
+ config.hsvRecordingDuration = 10;
293
+ }
294
+ if (config.hsvRecordingDuration > 300) {
295
+ this.platform.log.warn(this.accessory.displayName, 'HomeKit Secure Video recording duration is set to ' + config.hsvRecordingDuration +
296
+ '. Will set it to a maximum of 5 minutes to prevent errors.');
297
+ config.hsvRecordingDuration = 300;
298
+ }
299
+ if (config.hsv && !this.platform.api.versionGreaterOrEqual('1.4.0')) {
300
+ config.hsv = false;
301
+ this.platform.log.warn(this.accessory.displayName, 'HomeKit Secure Video is only supported by Homebridge version >1.4.0! Please update.');
302
+ }
92
303
  if (!config.snapshotHandlingMethod) {
93
304
  config.snapshotHandlingMethod = (config.forcerefreshsnap) ? 1 : 3;
94
305
  }
95
- config.talkback = (_j = config.talkback) !== null && _j !== void 0 ? _j : (config.talkback = false);
306
+ config.talkback = (_o = config.talkback) !== null && _o !== void 0 ? _o : (config.talkback = false);
307
+ config.talkbackChannels = (_p = config.talkbackChannels) !== null && _p !== void 0 ? _p : (config.talkbackChannels = 1);
96
308
  if (config.talkback && !this.eufyDevice.hasCommand(eufy_security_client_1.CommandName.DeviceStartTalkback)) {
97
309
  this.platform.log.warn(this.accessory.displayName, 'Talkback for this device is not supported!');
98
310
  config.talkback = false;
@@ -101,214 +313,248 @@ class CameraAccessory extends Device_1.DeviceAccessory {
101
313
  this.platform.log.warn(this.accessory.displayName, 'Talkback cannot be used with rtsp option. Ignoring talkback setting.');
102
314
  config.talkback = false;
103
315
  }
316
+ if (config.talkbackChannels !== 1 && config.talkbackChannels !== 2) {
317
+ this.platform.log.warn(this.accessory.displayName, 'Talkback cannot be used with ' + config.talkbackChannels + '. Setting it to mono.');
318
+ config.talkbackChannels = 1;
319
+ }
104
320
  return config;
105
321
  }
106
- cameraFunction() {
107
- const service = this.accessory.getService(this.platform.Service.CameraOperatingMode) ||
108
- this.accessory.addService(this.platform.Service.CameraOperatingMode);
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));
322
+ cameraSetup(accessory) {
323
+ const service = accessory.getService(this.platform.Service.CameraOperatingMode) ||
324
+ accessory.addService(this.platform.Service.CameraOperatingMode);
325
+ service.setCharacteristic(this.characteristic.Name, accessory.displayName);
326
+ service
327
+ .getCharacteristic(this.characteristic.EventSnapshotsActive)
328
+ .onGet(this.handleEventSnapshotsActiveGet.bind(this));
329
+ service
330
+ .getCharacteristic(this.characteristic.EventSnapshotsActive)
331
+ .onSet(this.handleEventSnapshotsActiveSet.bind(this));
332
+ service
333
+ .getCharacteristic(this.characteristic.PeriodicSnapshotsActive)
334
+ .onGet(this.handlePeriodicSnapshotsActiveGet.bind(this));
335
+ service
336
+ .getCharacteristic(this.characteristic.PeriodicSnapshotsActive)
337
+ .onSet(this.handlePeriodicSnapshotsActiveSet.bind(this));
338
+ service
339
+ .getCharacteristic(this.characteristic.HomeKitCameraActive)
340
+ .onGet(this.handleHomeKitCameraActiveGet.bind(this));
341
+ service
342
+ .getCharacteristic(this.characteristic.HomeKitCameraActive)
343
+ .onSet(this.handleHomeKitCameraActiveSet.bind(this));
116
344
  if (this.eufyDevice.hasProperty('enabled')) {
117
- service.getCharacteristic(this.characteristic.ManuallyDisabled)
118
- .onGet(this.getPropertyValue.bind(this, 'this.characteristic.ManuallyDisabled', eufy_security_client_1.PropertyName.DeviceEnabled));
345
+ service
346
+ .getCharacteristic(this.characteristic.ManuallyDisabled)
347
+ .onGet(this.handleManuallyDisabledGet.bind(this));
119
348
  }
120
349
  if (this.eufyDevice.hasProperty('statusLed')) {
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));
350
+ service
351
+ .getCharacteristic(this.characteristic.CameraOperatingModeIndicator)
352
+ .onGet(this.handleHomeKitCameraOperatingModeIndicatorGet.bind(this))
353
+ .onSet(this.handleHomeKitCameraOperatingModeIndicatorSet.bind(this));
124
354
  }
125
355
  if (this.eufyDevice.hasProperty('nightvision')) {
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));
129
- }
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));
356
+ service
357
+ .getCharacteristic(this.characteristic.NightVision)
358
+ .onGet(this.handleHomeKitNightVisionGet.bind(this))
359
+ .onSet(this.handleHomeKitNightVisionSet.bind(this));
134
360
  }
135
- this.eufyDevice.on('property changed', (device, name, value) => this.handlePropertyChange(device, name, value));
136
- return service;
361
+ this.CameraService = service;
362
+ this.CameraService.setPrimaryService(true);
363
+ }
364
+ handleEventSnapshotsActiveGet() {
365
+ const currentValue = this.characteristic.EventSnapshotsActive.ENABLE;
366
+ this.platform.log.debug(this.accessory.displayName, 'GET EventSnapshotsActive:', currentValue);
367
+ return currentValue;
368
+ }
369
+ /**
370
+ * Handle requests to set the "Event Snapshots Active" characteristic
371
+ */
372
+ handleEventSnapshotsActiveSet(value) {
373
+ this.platform.log.debug(this.accessory.displayName, 'Will not SET EventSnapshotsActive:', value);
374
+ }
375
+ handlePeriodicSnapshotsActiveGet() {
376
+ const currentValue = this.characteristic.PeriodicSnapshotsActive.ENABLE;
377
+ this.platform.log.debug(this.accessory.displayName, 'GET PeriodicSnapshotsActive:', currentValue);
378
+ return currentValue;
379
+ }
380
+ /**
381
+ * Handle requests to set the "Periodic Snapshots Active" characteristic
382
+ */
383
+ handlePeriodicSnapshotsActiveSet(value) {
384
+ this.platform.log.debug(this.accessory.displayName, 'Will not SET PeriodicSnapshotsActive:', value);
385
+ }
386
+ /**
387
+ * Handle requests to get the current value of the "HomeKit Camera Active" characteristic
388
+ */
389
+ handleHomeKitCameraActiveGet() {
390
+ const currentValue = this.characteristic.HomeKitCameraActive.ON;
391
+ this.platform.log.debug(this.accessory.displayName, 'GET HomeKitCameraActive:', currentValue);
392
+ return currentValue;
137
393
  }
138
- setupMotionFunction(accessory) {
394
+ /**
395
+ * Handle requests to set the "HomeKit Camera Active" characteristic
396
+ */
397
+ handleHomeKitCameraActiveSet(value) {
398
+ this.platform.log.debug(this.accessory.displayName, 'Will not SET HomeKitCameraActive:', value);
399
+ }
400
+ /**
401
+ * Handle requests to get the current value of the "HomeKit Camera Active" characteristic
402
+ */
403
+ async handleHomeKitCameraOperatingModeIndicatorGet() {
139
404
  try {
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;
405
+ const currentValue = this.eufyDevice.getPropertyValue(eufy_security_client_1.PropertyName.DeviceStatusLed);
406
+ this.platform.log.debug(this.accessory.displayName, 'GET DeviceStatusLed:', currentValue);
407
+ return currentValue;
166
408
  }
167
- }
168
- onDeviceEventDetectedPushNotification(device, motion, eventType) {
169
- this.platform.log.info(`${this.accessory.displayName} ON Event Detected (${eventType}): ${motion}`);
170
- if (motion) {
171
- this.motionTimeout = setTimeout(() => {
172
- this.platform.log.debug(this.accessory.displayName, 'Reseting motion through timout.');
173
- this.service
174
- .getCharacteristic(this.characteristic.MotionDetected)
175
- .updateValue(false);
176
- }, 15000);
409
+ catch (_a) {
410
+ this.platform.log.debug(this.accessory.displayName, 'handleHomeKitCameraOperatingModeIndicatorGet', 'Wrong return value');
411
+ return false;
177
412
  }
178
- else {
179
- if (this.motionTimeout) {
180
- clearTimeout(this.motionTimeout);
181
- }
413
+ }
414
+ /**
415
+ * Handle requests to set the "HomeKit Camera Active" characteristic
416
+ */
417
+ async handleHomeKitCameraOperatingModeIndicatorSet(value) {
418
+ this.platform.log.debug(this.accessory.displayName, 'SET HomeKitCameraOperatingModeIndicator:', value);
419
+ const station = await this.platform.getStationById(this.eufyDevice.getStationSerial());
420
+ station.setStatusLed(this.eufyDevice, value);
421
+ this.CameraService.getCharacteristic(this.characteristic.CameraOperatingModeIndicator).updateValue(value);
422
+ }
423
+ /**
424
+ * Handle requests to get the current value of the "HomeKit Camera Active" characteristic
425
+ */
426
+ async handleHomeKitNightVisionGet() {
427
+ try {
428
+ const currentValue = this.eufyDevice.getPropertyValue(eufy_security_client_1.PropertyName.DeviceNightvision);
429
+ this.platform.log.debug(this.accessory.displayName, 'GET DeviceNightvision:', currentValue);
430
+ return currentValue;
182
431
  }
183
- if (this.cameraConfig.useCachedLocalLivestream && this.streamingDelegate && motion) {
184
- this.streamingDelegate.prepareCachedStream();
432
+ catch (_a) {
433
+ this.platform.log.debug(this.accessory.displayName, 'handleHomeKitNightVisionGet', 'Wrong return value');
434
+ return false;
185
435
  }
186
- this.service
187
- .getCharacteristic(this.characteristic.MotionDetected)
188
- .updateValue(motion);
189
436
  }
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));
437
+ /**
438
+ * Handle requests to set the "HomeKit Camera Active" characteristic
439
+ */
440
+ async handleHomeKitNightVisionSet(value) {
441
+ this.platform.log.debug(this.accessory.displayName, 'SET handleHomeKitNightVisionSet:', value);
442
+ const station = await this.platform.getStationById(this.eufyDevice.getStationSerial());
443
+ station.setNightVision(this.eufyDevice, value);
444
+ this.CameraService.getCharacteristic(this.characteristic.NightVision).updateValue(value);
445
+ }
446
+ motionFunction(accessory) {
447
+ const service = this.accessory.getService(this.platform.Service.MotionSensor) ||
448
+ this.accessory.addService(this.platform.Service.MotionSensor);
449
+ service.setCharacteristic(this.characteristic.Name, accessory.displayName);
450
+ service
451
+ .getCharacteristic(this.characteristic.MotionDetected)
452
+ .onGet(this.handleMotionDetectedGet.bind(this));
453
+ this.eufyDevice.on('property changed', this.onPropertyChange.bind(this));
203
454
  return service;
204
455
  }
205
- async getPropertyValue(characteristic, propertyName) {
456
+ async handleMotionDetectedGet() {
457
+ var _a;
206
458
  try {
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;
459
+ let currentValue = this.eufyDevice.getPropertyValue(eufy_security_client_1.PropertyName.DeviceMotionDetected);
460
+ if ((_a = this.recordingDelegate) === null || _a === void 0 ? void 0 : _a.isRecording()) {
461
+ currentValue = true; // assume ongoing motion when HKSV is recording
462
+ // HKSV will remove unnecessary bits of the recorded video itself when there is no more motion
463
+ // but since eufy-security-client doesn't return a proper value for MotionDetected while
464
+ // streaming we assume motion to be ongoing
465
+ // otherwise the recording would almost always end prematurely
218
466
  }
219
- if (characteristic === 'this.characteristic.ManuallyDisabled') {
220
- this.platform.log.debug(`${this.accessory.displayName} INVERSED '${characteristic}' ${propertyName}: ${!value}`);
221
- value = !value;
467
+ this.platform.log.debug(this.accessory.displayName, 'GET DeviceMotionDetected:', currentValue);
468
+ return currentValue;
469
+ }
470
+ catch (_b) {
471
+ this.platform.log.debug(this.accessory.displayName, 'handleMotionDetectedGet', 'Wrong return value');
472
+ return false;
473
+ }
474
+ }
475
+ onPropertyChange(_, name, value) {
476
+ var _a;
477
+ const motionValues = [
478
+ 'motionDetected',
479
+ 'personDetected',
480
+ 'petDetected',
481
+ ];
482
+ if (motionValues.indexOf(name) !== -1) {
483
+ const isRecording = (_a = this.recordingDelegate) === null || _a === void 0 ? void 0 : _a.isRecording();
484
+ if (!isRecording) {
485
+ const motionDetected = value;
486
+ this.platform.log.debug(this.accessory.displayName, 'ON DeviceMotionDetected:', motionDetected);
487
+ this.service
488
+ .getCharacteristic(this.characteristic.MotionDetected)
489
+ .updateValue(motionDetected);
222
490
  }
223
- if (value === undefined) {
224
- return false;
491
+ else {
492
+ this.platform.log.debug(this.accessory.displayName, 'ignore change of motion detected state, since HKSV is still recording.' +
493
+ 'The recording controller will reset the motion state afterwards.');
225
494
  }
226
- return value;
227
495
  }
228
- catch (error) {
229
- this.platform.log.debug(`${this.accessory.displayName} Error getting '${characteristic}' ${propertyName}: ${error}`);
496
+ }
497
+ async handleEnableGet() {
498
+ try {
499
+ const currentValue = this.eufyDevice.getPropertyValue(eufy_security_client_1.PropertyName.DeviceEnabled);
500
+ this.platform.log.debug(this.accessory.displayName, 'GET DeviceEnabled:', currentValue);
501
+ return currentValue;
502
+ }
503
+ catch (_a) {
504
+ this.platform.log.debug(this.accessory.displayName, 'handleEnableGet', 'Wrong return value');
230
505
  return false;
231
506
  }
232
507
  }
233
- async setPropertyValue(characteristic, propertyName, value) {
508
+ async handleManuallyDisabledGet() {
234
509
  try {
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
- }
510
+ const currentValue = this.eufyDevice.getPropertyValue(eufy_security_client_1.PropertyName.DeviceEnabled);
511
+ this.platform.log.debug(this.accessory.displayName, 'GET DeviceEnabled:', currentValue);
512
+ return !currentValue;
280
513
  }
281
- catch (error) {
282
- this.platform.log.debug(`${this.accessory.displayName} Error setting '${characteristic}' ${propertyName}: ${error}`);
514
+ catch (_a) {
515
+ this.platform.log.debug(this.accessory.displayName, 'handleManuallyDisabledGet', 'Wrong return value');
516
+ return false;
283
517
  }
284
518
  }
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
- }
519
+ async handleEnableSet(value) {
520
+ this.platform.log.debug(this.accessory.displayName, 'SET DeviceEnabled:', value);
521
+ const station = await this.platform.getStationById(this.eufyDevice.getStationSerial());
522
+ station.enableDevice(this.eufyDevice, value);
523
+ if (this.cameraConfig.enableCamera) {
524
+ this.CameraService.getCharacteristic(this.characteristic.ManuallyDisabled).updateValue(!value);
525
+ }
526
+ }
527
+ async handleMotionOnGet() {
528
+ try {
529
+ const currentValue = await this.eufyDevice.getPropertyValue(eufy_security_client_1.PropertyName.DeviceMotionDetection);
530
+ this.platform.log.debug(this.accessory.displayName, 'GET DeviceMotionDetection:', currentValue);
531
+ return currentValue;
532
+ }
533
+ catch (_a) {
534
+ this.platform.log.debug(this.accessory.displayName, 'handleMotionOnGet', 'Wrong return value');
535
+ return false;
296
536
  }
297
537
  }
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);
538
+ async handleMotionOnSet(value) {
539
+ this.platform.log.debug(this.accessory.displayName, 'SET DeviceMotionDetection:', value);
540
+ const station = await this.platform.getStationById(this.eufyDevice.getStationSerial());
541
+ station.setMotionDetection(this.eufyDevice, value);
542
+ }
543
+ async handleLightOnGet() {
544
+ try {
545
+ const currentValue = await this.eufyDevice.getPropertyValue(eufy_security_client_1.PropertyName.DeviceLight);
546
+ this.platform.log.debug(this.accessory.displayName, 'GET DeviceLight:', currentValue);
547
+ return currentValue;
548
+ }
549
+ catch (_a) {
550
+ this.platform.log.debug(this.accessory.displayName, 'handleLightOnGet', 'Wrong return value');
551
+ return false;
552
+ }
309
553
  }
310
- handleDummyEventSet(serviceName, value) {
311
- this.platform.log.debug(`${this.accessory.displayName} SET ${serviceName}: ${value}`);
554
+ async handleLightOnSet(value) {
555
+ this.platform.log.debug(this.accessory.displayName, 'SET DeviceLight:', value);
556
+ const station = await this.platform.getStationById(this.eufyDevice.getStationSerial());
557
+ station.switchLight(this.eufyDevice, value);
312
558
  }
313
559
  }
314
560
  exports.CameraAccessory = CameraAccessory;