homekit: fixup settings groups

This commit is contained in:
Koushik Dutta
2022-05-25 09:24:30 -07:00
parent e1180dc206
commit 68577ce30f
2 changed files with 6 additions and 3 deletions

View File

@@ -100,15 +100,17 @@ export function getRandomPort() {
return Math.round(30000 + Math.random() * 20000);
}
export function createHAPUsernameStorageSettingsDict(): StorageSettingsDict<'mac' | 'qrCode'> {
export function createHAPUsernameStorageSettingsDict(group?: string): StorageSettingsDict<'mac' | 'qrCode'> {
return {
qrCode: {
group,
title: "Pairing QR Code",
type: 'qrcode',
readonly: true,
description: "Scan with your iOS camera to pair this Scrypted with HomeKit.",
},
mac: {
group,
hide: true,
title: "Username Override",
persistedDefaultValue: createHAPUsername(),

View File

@@ -10,6 +10,7 @@ export const HOMEKIT_MIXIN = 'mixin:@scrypted/homekit';
export class HomekitMixin<T> extends SettingsMixinDeviceBase<T> {
storageSettings = new StorageSettings(this, {
standalone: {
group: 'HomeKit Pairing',
title: 'Standalone Accessory Mode',
description: 'Advertise this to HomeKit as a standalone accessory rather than through the Scrypted HomeKit bridge. Enabling this option will remove it from the bridge. The accessory will then need to be re-paired to HomeKit. The pairing code will be available after the HomeKit plugin has been reloaded.'
+ (this.interfaces.includes(ScryptedInterface.VideoCamera)
@@ -20,8 +21,9 @@ export class HomekitMixin<T> extends SettingsMixinDeviceBase<T> {
// todo: change this at some point.
persistedDefaultValue: false,
},
...createHAPUsernameStorageSettingsDict(),
...createHAPUsernameStorageSettingsDict('HomeKit Pairing'),
resetAccessory: {
group: 'HomeKit Pairing',
title: 'Reset Pairing',
description: 'Resetting the pairing will resync it to HomeKit as a new device. Bridged devices will automatically relink as a new device. Accessory devices must be manually removed from the Home app and re-paired. Enter RESET to reset the pairing.',
placeholder: 'RESET',
@@ -45,7 +47,6 @@ export class HomekitMixin<T> extends SettingsMixinDeviceBase<T> {
this.storageSettings.settings.qrCode.hide = !this.storageSettings.values.standalone;
}
alertReload() {
log.a(`You must reload the HomeKit plugin for the changes to ${this.name} to take effect.`);
}