homekit: make status light indicator an option

This commit is contained in:
Koushik Dutta
2022-01-22 10:44:58 -08:00
parent d347218dbc
commit db77f81e06
4 changed files with 26 additions and 6 deletions

View File

@@ -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",

View File

@@ -40,5 +40,5 @@
"@types/qrcode": "^1.4.1",
"@types/url-parse": "^1.4.3"
},
"version": "0.0.172"
"version": "0.0.173"
}

View File

@@ -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<any> 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;
}

View File

@@ -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)