diff options
| author | Li Zhineng <[email protected]> | 2025-07-22 09:58:56 +0800 |
|---|---|---|
| committer | Li Zhineng <[email protected]> | 2025-07-22 09:58:56 +0800 |
| commit | 23f21de1692ac277de4888c34f62c166a46ffd68 (patch) | |
| tree | fe5e9aec31c13e70aed9d5e897686bc867b4a207 /src | |
| parent | 7f3732e13ac0f6fbf923b1a93e9d1230b3388cc5 (diff) | |
| download | homebridge-airmx-23f21de1692ac277de4888c34f62c166a46ffd68.tar.gz homebridge-airmx-23f21de1692ac277de4888c34f62c166a46ffd68.zip | |
comments
Diffstat (limited to 'src')
| -rw-r--r-- | src/index.ts | 12 |
1 files changed, 11 insertions, 1 deletions
diff --git a/src/index.ts b/src/index.ts index 55cfa67..e3bbf40 100644 --- a/src/index.ts +++ b/src/index.ts @@ -50,7 +50,7 @@ const pluginIdentifier = 'homebridge-airmx' const platformName = 'Airmx' /** - * The stub control data for initial sending when we don’t have the latest + * The stub control data for initial sending when we don't have the latest * device status available. */ const stubControl: EagleControlData = { @@ -157,6 +157,10 @@ class AirmxPlatform implements DynamicPlatformPlugin { 'Restoring existing accessory from cache:', accessory.context.device.id ) + + // The accessory has already been registered in the configureAccessory + // hook while restoring from cache. All we need to do is initialize + // the accessory instance and begin handling HomeKit requests. new AirmxProAccessory(this, accessory) } @@ -164,8 +168,14 @@ class AirmxPlatform implements DynamicPlatformPlugin { accessory: PlatformAccessory<AccessoryContext> ): void { this.log.info('Adding new accessory:', accessory.context.device.id) + + // When we "discover" a new device, we store the accessory in our accessory + // map. This allows us to notify HomeKit when we receive a status update + // from the device indicating that the device's status has changed. this.accessories.set(accessory.UUID, accessory) + new AirmxProAccessory(this, accessory) + this.api.registerPlatformAccessories(pluginIdentifier, platformName, [ accessory ]) |
