mirror of
https://github.com/koush/scrypted.git
synced 2026-02-10 01:02:18 +00:00
homekit: make status light indicator an option
This commit is contained in:
4
plugins/homekit/package-lock.json
generated
4
plugins/homekit/package-lock.json
generated
@@ -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",
|
||||
|
||||
@@ -40,5 +40,5 @@
|
||||
"@types/qrcode": "^1.4.1",
|
||||
"@types/url-parse": "^1.4.3"
|
||||
},
|
||||
"version": "0.0.172"
|
||||
"version": "0.0.173"
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
|
||||
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user