diff --git a/plugins/homekit/package-lock.json b/plugins/homekit/package-lock.json index 4e2a89e56..be30bf7ca 100644 --- a/plugins/homekit/package-lock.json +++ b/plugins/homekit/package-lock.json @@ -1,12 +1,12 @@ { "name": "@scrypted/homekit", - "version": "0.0.172", + "version": "0.0.173", "lockfileVersion": 2, "requires": true, "packages": { "": { "name": "@scrypted/homekit", - "version": "0.0.172", + "version": "0.0.173", "dependencies": { "hap-nodejs": "file:../../external/HAP-NodeJS", "lodash": "^4.17.21", diff --git a/plugins/homekit/package.json b/plugins/homekit/package.json index c05593d11..68e4ac8a1 100644 --- a/plugins/homekit/package.json +++ b/plugins/homekit/package.json @@ -40,5 +40,5 @@ "@types/qrcode": "^1.4.1", "@types/url-parse": "^1.4.3" }, - "version": "0.0.172" + "version": "0.0.173" } diff --git a/plugins/homekit/src/camera-mixin.ts b/plugins/homekit/src/camera-mixin.ts index 135b65a91..fede70fb0 100644 --- a/plugins/homekit/src/camera-mixin.ts +++ b/plugins/homekit/src/camera-mixin.ts @@ -1,4 +1,4 @@ -import sdk, { VideoCamera, Settings, Setting, ScryptedInterface, ObjectDetector, SettingValue, MediaStreamOptions } from "@scrypted/sdk"; +import sdk, { VideoCamera, Settings, Setting, ScryptedInterface, ObjectDetector, SettingValue, MediaStreamOptions, ScryptedInterfaceProperty } from "@scrypted/sdk"; import { SettingsMixinDeviceBase } from "../../../common/src/settings-mixin"; import { getH264DecoderArgs, getH264EncoderArgs } from "../../../common/src/ffmpeg-hardware-acceleration"; @@ -199,6 +199,16 @@ export class CameraMixin extends SettingsMixinDeviceBase implements Setting } } + if (this.interfaces.includes(ScryptedInterface.OnOff)) { + settings.push({ + title: 'Camera Status Indicator', + description: 'Allow HomeKit to control the camera status indicator light.', + key: 'statusIndicator', + value: this.storage.getItem('statusIndicator') === 'true', + type: 'boolean', + }); + } + return settings; } diff --git a/plugins/homekit/src/types/camera.ts b/plugins/homekit/src/types/camera.ts index 1b85c9881..10b8873b7 100644 --- a/plugins/homekit/src/types/camera.ts +++ b/plugins/homekit/src/types/camera.ts @@ -602,14 +602,24 @@ addSupportedType({ } else { const indicator = controller.cameraOperatingModeService.getCharacteristic(Characteristic.CameraOperatingModeIndicator); - bindCharacteristic(device, ScryptedInterface.OnOff, controller.cameraOperatingModeService, Characteristic.CameraOperatingModeIndicator, () => device.on ? 1 : 0); + const linkStatusIndicator = storage.getItem('statusIndicator') === 'true'; + const property = `characteristic-v2-${Characteristic.CameraOperatingModeIndicator.UUID}` + bindCharacteristic(device, ScryptedInterface.OnOff, controller.cameraOperatingModeService, Characteristic.CameraOperatingModeIndicator, () => { + if (!linkStatusIndicator) + return storage.getItem(property) === 'true' ? 1 : 0; + + return device.on ? 1 : 0; + }); indicator.on(CharacteristicEventTypes.SET, (value, callback) => { callback(); + if (!linkStatusIndicator) + return storage.setItem(property, (!!value).toString()); + if (value) device.turnOn(); else device.turnOff(); - }) + }); } recordingManagement.getService().getCharacteristic(Characteristic.SelectedCameraRecordingConfiguration)