Skip to content

Commit

Permalink
Add support for ignoring doors by ID
Browse files Browse the repository at this point in the history
  • Loading branch information
derek-miller committed May 6, 2024
1 parent a9e1e0a commit be2e181
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 7 deletions.
35 changes: 30 additions & 5 deletions config.schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -65,25 +65,50 @@
"title": "Show doors that have been shared with me",
"type": "boolean",
"default": false
},
"ignoreDevices": {
"title": "Ignore Doors By ID",
"description": "Ignore doors by their device ID obtained from the logs during startup.",
"type": "array",
"default": [],
"required": false,
"items": {
"title": "Device ID",
"type": "string"
}
}
}
},
"form": [
"layout": [
"name",
"username",
"password",
{
"type": "fieldset",
"expandable": true,
"type": "section",
"title": "Advanced Settings",
"description": "",
"expandable": true,
"expanded": false,
"items": [
"batteryLowLevel",
"doorStatusStationaryCacheTtl",
"doorStatusTransitioningCacheTtl",
"doorStatusPollInterval",
"logApiResponses",
"showShared"
"showShared",
{
"key": "ignoreDevices",
"type": "array",
"name": "Device ID",
"orderable": false,
"buttonText": "Add Device ID",
"items": {
"key": "ignoreDevices[]",
"type": "string",
"pattern": "^[A-F0-9]{12}_[1-9]+$",
"title": "Device ID",
"placeholder": "eg. F0AD4E1BC74D_1"
}
}
]
}
]
Expand Down
12 changes: 10 additions & 2 deletions src/platform.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,10 @@ export class GenieAladdinConnectHomebridgePlatform implements DynamicPlatformPlu
const discoveredUUIDs: Set<string> = new Set();

for (const door of doors) {
if (Array.isArray(this.config.ignoreDevices) && this.config.ignoreDevices.includes(door.id)) {
this.log.info('Skipping ignored accessory: %s (id: %s)', door.name, door.id);
continue;
}
if (door.ownership === 'owned' || this.config.showShared === true) {
const uuid = this.api.hap.uuid.generate(`${door.deviceId}:${door.index}`);
discoveredUUIDs.add(uuid);
Expand All @@ -64,10 +68,14 @@ export class GenieAladdinConnectHomebridgePlatform implements DynamicPlatformPlu
};

if (existingAccessory) {
this.log.info('Restoring existing accessory from cache:', accessory.displayName);
this.log.info(
'Restoring existing accessory from cache: %s (id: %s)',
accessory.displayName,
door.id,
);
this.api.updatePlatformAccessories([accessory]);
} else {
this.log.info('Adding new accessory:', door.name);
this.log.info('Adding new accessory: %s (id: %s)', door.name, door.id);
this.api.registerPlatformAccessories(PLUGIN_NAME, PLATFORM_NAME, [accessory]);
}
new GenieAladdinConnectGarageDoorAccessory(this, accessory);
Expand Down

0 comments on commit be2e181

Please sign in to comment.