UNPKG

4.52 kBTypeScriptView Raw
1import { Accessory, Bridge, CharacteristicWarning, InterfaceName, IPAddress, MacAddress, MDNSAdvertiser } from "hap-nodejs";
2import { AccessoryIdentifier, AccessoryName, AccessoryPlugin, HomebridgeAPI, PlatformIdentifier, PlatformName, PluginIdentifier, StaticPlatformPlugin } from "./api";
3import { ExternalPortService, ExternalPortsConfiguration } from "./externalPortService";
4import { Logging } from "./logger";
5import { PlatformAccessory } from "./platformAccessory";
6import { Plugin } from "./plugin";
7import { PluginManager } from "./pluginManager";
8import { HomebridgeOptions } from "./server";
9export interface BridgeConfiguration {
10 name: string;
11 username: MacAddress;
12 pin: string;
13 advertiser?: MDNSAdvertiser;
14 port?: number;
15 bind?: (InterfaceName | IPAddress) | (InterfaceName | IPAddress)[];
16 setupID?: string[4];
17 manufacturer?: string;
18 model?: string;
19 disableIpc?: boolean;
20 firmwareRevision?: string;
21 env?: {
22 DEBUG?: string;
23 NODE_OPTIONS?: string;
24 };
25}
26export interface AccessoryConfig extends Record<string, any> {
27 accessory: AccessoryName | AccessoryIdentifier;
28 name: string;
29 uuid_base?: string;
30 _bridge?: BridgeConfiguration;
31}
32export interface PlatformConfig extends Record<string, any> {
33 platform: PlatformName | PlatformIdentifier;
34 name?: string;
35 _bridge?: BridgeConfiguration;
36}
37export interface HomebridgeConfig {
38 bridge: BridgeConfiguration;
39 /**
40 * @deprecated
41 */
42 mdns?: any;
43 accessories: AccessoryConfig[];
44 platforms: PlatformConfig[];
45 plugins?: PluginIdentifier[];
46 /**
47 * Array of disabled plugins.
48 * Unlike the plugins[] config which prevents plugins from being initialised at all, disabled plugins still have their alias loaded, so
49 * we can match config blocks of disabled plugins and show an appropriate message in the logs.
50 */
51 disabledPlugins?: PluginIdentifier[];
52 ports?: ExternalPortsConfiguration;
53}
54export interface BridgeOptions extends HomebridgeOptions {
55 cachedAccessoriesDir: string;
56 cachedAccessoriesItemName: string;
57}
58export interface CharacteristicWarningOpts {
59 ignoreSlow?: boolean;
60}
61export declare class BridgeService {
62 private api;
63 private pluginManager;
64 private externalPortService;
65 private bridgeOptions;
66 private bridgeConfig;
67 private config;
68 bridge: Bridge;
69 private storageService;
70 private readonly allowInsecureAccess;
71 private cachedPlatformAccessories;
72 private cachedAccessoriesFileLoaded;
73 private readonly publishedExternalAccessories;
74 constructor(api: HomebridgeAPI, pluginManager: PluginManager, externalPortService: ExternalPortService, bridgeOptions: BridgeOptions, bridgeConfig: BridgeConfiguration, config: HomebridgeConfig);
75 static printCharacteristicWriteWarning(plugin: Plugin, accessory: Accessory, opts: CharacteristicWarningOpts, warning: CharacteristicWarning): void;
76 publishBridge(): void;
77 /**
78 * Attempt to load the cached accessories from disk.
79 */
80 loadCachedPlatformAccessoriesFromDisk(): Promise<void>;
81 /**
82 * Return the name of the backup cache file
83 */
84 private get backupCacheFileName();
85 /**
86 * Create a backup of the cached file
87 * This is used if we ever have trouble reading the main cache file
88 */
89 private createCachedAccessoriesBackup;
90 /**
91 * Restore a cached accessories backup
92 * This is used if the main cache file has a JSON syntax error / is corrupted
93 */
94 private restoreCachedAccessoriesBackup;
95 restoreCachedPlatformAccessories(): void;
96 /**
97 * Save the cached accessories back to disk.
98 */
99 saveCachedPlatformAccessoriesOnDisk(): void;
100 handleRegisterPlatformAccessories(accessories: PlatformAccessory[]): void;
101 handleUpdatePlatformAccessories(accessories: PlatformAccessory[]): void;
102 handleUnregisterPlatformAccessories(accessories: PlatformAccessory[]): void;
103 handlePublishExternalAccessories(accessories: PlatformAccessory[]): Promise<void>;
104 createHAPAccessory(plugin: Plugin, accessoryInstance: AccessoryPlugin, displayName: string, accessoryType: AccessoryName | AccessoryIdentifier, uuidBase?: string): Accessory | undefined;
105 loadPlatformAccessories(plugin: Plugin, platformInstance: StaticPlatformPlugin, platformType: PlatformName | PlatformIdentifier, logger: Logging): Promise<void>;
106 teardown(): void;
107 private static strippingPinCode;
108}
109//# sourceMappingURL=bridgeService.d.ts.map
\No newline at end of file