homekit: populate override address options

This commit is contained in:
Koushik Dutta
2021-10-18 22:59:22 -07:00
parent 55f1da7da4
commit 4694135cae
3 changed files with 10 additions and 5 deletions

View File

@@ -1,12 +1,12 @@
{
"name": "@scrypted/homekit",
"version": "0.0.95",
"version": "0.0.96",
"lockfileVersion": 2,
"requires": true,
"packages": {
"": {
"name": "@scrypted/homekit",
"version": "0.0.95",
"version": "0.0.96",
"dependencies": {
"hap-nodejs": "file:../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.95"
"version": "0.0.96"
}

View File

@@ -10,6 +10,7 @@ import qrcode from 'qrcode';
import packageJson from "../package.json";
import { randomPinCode } from './pincode';
import { EventedHTTPServer } from '../HAP-NodeJS/src/lib/util/eventedhttp';
import { AddressInfo } from 'net';
const { systemManager, deviceManager } = sdk;
@@ -83,13 +84,15 @@ class HomeKit extends ScryptedDeviceBase implements MixinProvider, Settings, Hom
getHomeKitHubs(): string[] {
try {
return JSON.parse(this.storage.getItem('homekitHubs'));
return JSON.parse(this.storage.getItem('homekitHubs'));
}
catch (e) {
}
}
async getSettings(): Promise<Setting[]> {
const addresses = (Object.entries(os.networkInterfaces()).filter(([iface]) => iface.startsWith('en') || iface.startsWith('wlan')) as any)
.flat().map(([, entry]) => entry.address).filter((address: string) => address);
return [
{
title: "Manual Pairing Code",
@@ -112,7 +115,9 @@ class HomeKit extends ScryptedDeviceBase implements MixinProvider, Settings, Hom
title: 'Bridge Address',
value: localStorage.getItem('addressOverride'),
key: 'addressOverride',
description: 'Optional: The network address used by the Scrypted bridge. Set this to the wired address to prevent usage of wireless address.'
description: 'Optional: The network address used by the Scrypted bridge. Set this to the wired address to prevent usage of wireless address.',
choices: addresses,
combobox: true,
},
{
title: 'HomeKit Hubs',