mirror of
https://github.com/koush/scrypted.git
synced 2026-09-18 01:30:39 +01:00
homekit: fix security system nullref bug causing bridge to not start
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
import { StorageSettings } from "@scrypted/common/src/settings";
|
||||
import { StorageSettings } from "@scrypted/sdk/storage-settings";
|
||||
import { SettingsMixinDeviceOptions } from "@scrypted/common/src/settings-mixin";
|
||||
import sdk, { ObjectDetector, Readme, ScryptedDeviceType, ScryptedInterface, Setting, SettingValue, VideoCamera } from "@scrypted/sdk";
|
||||
import { HomekitMixin } from "./homekit-mixin";
|
||||
|
||||
@@ -1,14 +1,12 @@
|
||||
import { MixinDeviceBase, ScryptedDeviceBase, ScryptedDeviceType } from '@scrypted/sdk';
|
||||
import { randomBytes } from 'crypto';
|
||||
import { Categories, EventedHTTPServer, HAPStorage } from './hap';
|
||||
import './types';
|
||||
import os from 'os';
|
||||
import { StorageSettingsDict } from '@scrypted/common/src/settings';
|
||||
import crypto from 'crypto';
|
||||
import { closeQuiet, createBindZero } from '@scrypted/common/src/listen-cluster';
|
||||
import sdk, { ScryptedDeviceType } from '@scrypted/sdk';
|
||||
import { StorageSettingsDict } from "@scrypted/sdk/storage-settings";
|
||||
import crypto, { randomBytes } from 'crypto';
|
||||
import { once } from 'events';
|
||||
import os from 'os';
|
||||
import { Categories, EventedHTTPServer, HAPStorage } from './hap';
|
||||
import { randomPinCode } from './pincode';
|
||||
import sdk from '@scrypted/sdk';
|
||||
import './types';
|
||||
|
||||
class HAPLocalStorage {
|
||||
initSync() {
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
import { StorageSettings } from "@scrypted/common/src/settings";
|
||||
import { SettingsMixinDeviceBase, SettingsMixinDeviceOptions } from "@scrypted/common/src/settings-mixin";
|
||||
import sdk, { ScryptedInterface, SettingValue } from "@scrypted/sdk";
|
||||
import crypto from 'crypto';
|
||||
import { StorageSettings } from "@scrypted/sdk/storage-settings";
|
||||
import { createHAPUsernameStorageSettingsDict } from "./hap-utils";
|
||||
const { log } = sdk;
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { StorageSettings } from '@scrypted/common/src/settings';
|
||||
import { StorageSettings } from "@scrypted/sdk/storage-settings";
|
||||
import { SettingsMixinDeviceOptions } from '@scrypted/common/src/settings-mixin';
|
||||
import sdk, { DeviceProvider, MixinProvider, Online, ScryptedDeviceBase, ScryptedDeviceType, ScryptedInterface, ScryptedInterfaceProperty, Setting, Settings } from '@scrypted/sdk';
|
||||
import crypto from 'crypto';
|
||||
|
||||
@@ -19,6 +19,8 @@ addSupportedType({
|
||||
// Set available modes based on plugin
|
||||
function systemStates(supportedModes: Array<SecuritySystemMode>): number[] {
|
||||
let modes = [Characteristic.SecuritySystemTargetState.DISARM]
|
||||
if (!supportedModes)
|
||||
return modes;
|
||||
|
||||
if (supportedModes.includes(SecuritySystemMode.HomeArmed)) modes.push(Characteristic.SecuritySystemTargetState.STAY_ARM);
|
||||
if (supportedModes.includes(SecuritySystemMode.AwayArmed)) modes.push(Characteristic.SecuritySystemTargetState.AWAY_ARM);
|
||||
@@ -27,7 +29,7 @@ addSupportedType({
|
||||
return modes;
|
||||
}
|
||||
service.getCharacteristic(Characteristic.SecuritySystemTargetState)
|
||||
.setProps({validValues: systemStates(device.securitySystemState.supportedModes)});
|
||||
.setProps({validValues: systemStates(device.securitySystemState?.supportedModes)});
|
||||
|
||||
function toCurrentState(mode: SecuritySystemMode, triggered: boolean) {
|
||||
if (!!triggered)
|
||||
@@ -70,10 +72,10 @@ addSupportedType({
|
||||
}
|
||||
|
||||
bindCharacteristic(device, ScryptedInterface.SecuritySystem, service, Characteristic.SecuritySystemCurrentState,
|
||||
() => toCurrentState(device.securitySystemState.mode, device.securitySystemState.triggered));
|
||||
() => toCurrentState(device.securitySystemState?.mode, device.securitySystemState?.triggered));
|
||||
|
||||
bindCharacteristic(device, ScryptedInterface.SecuritySystem, service, Characteristic.SecuritySystemTargetState,
|
||||
() => toTargetState(device.securitySystemState.mode));
|
||||
() => toTargetState(device.securitySystemState?.mode));
|
||||
|
||||
service.getCharacteristic(Characteristic.SecuritySystemTargetState)
|
||||
.on(CharacteristicEventTypes.SET, (value: CharacteristicValue, callback: CharacteristicSetCallback) => {
|
||||
@@ -86,7 +88,7 @@ addSupportedType({
|
||||
})
|
||||
|
||||
bindCharacteristic(device, ScryptedInterface.SecuritySystem, service, Characteristic.SecuritySystemAlarmType,
|
||||
() => !!device.securitySystemState.triggered);
|
||||
() => !!device.securitySystemState?.triggered);
|
||||
|
||||
return accessory;
|
||||
},
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { StorageSettings } from "@scrypted/common/src/settings";
|
||||
import { StorageSettings } from "@scrypted/sdk/storage-settings";
|
||||
import sdk, { MediaObject, MixinProvider, Readme, ScryptedDeviceBase, ScryptedDeviceType, ScryptedInterface, ScryptedMimeTypes, Setting, Settings, SettingValue, VideoClip, VideoClipOptions, VideoClips } from "@scrypted/sdk";
|
||||
import checkDiskSpace from 'check-disk-space';
|
||||
import { canCameraMixin } from "./camera-mixin";
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
{
|
||||
"compilerOptions": {
|
||||
"resolveJsonModule": true,
|
||||
"moduleResolution": "node",
|
||||
"moduleResolution": "Node16",
|
||||
"target": "esnext",
|
||||
"esModuleInterop": true,
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user