Skip to content

Commit

Permalink
homekit: Fix autoadd (#1716)
Browse files Browse the repository at this point in the history
Co-authored-by: Gianluca Ruocco <[email protected]>
  • Loading branch information
apocaliss92 and Gianluca Ruocco authored Jan 31, 2025
1 parent 1300073 commit 73b85e1
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions plugins/homekit/src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -216,6 +216,7 @@ export class HomeKitPlugin extends ScryptedDeviceBase implements MixinProvider,
throw Error(`error in device reordering, expected ${uniqueDeviceIds.size} unique devices but only got ${uniqueReorderedIds.size} entries!`);
}

const autoAdd = this.storageSettings.values.autoAdd ?? true;
for (const id of reorderedDeviceIds) {
const device = systemManager.getDeviceById<Online>(id);
const supportedType = supportedTypes[device.type];
Expand All @@ -224,8 +225,7 @@ export class HomeKitPlugin extends ScryptedDeviceBase implements MixinProvider,

try {
const mixins = (device.mixins || []).slice();
const autoAdd = this.storageSettings.values.autoAdd ?? true;
if (!mixins.includes(this.id) && autoAdd) {
if (!mixins.includes(this.id)) {
// don't sync this by default, as it's solely for automations
if (device.type === ScryptedDeviceType.Notifier)
continue;
Expand All @@ -235,6 +235,8 @@ export class HomeKitPlugin extends ScryptedDeviceBase implements MixinProvider,
continue;
if (defaultIncluded[device.id] === includeToken)
continue;
if (!autoAdd)
continue;
mixins.push(this.id);
await device.setMixins(mixins);
defaultIncluded[device.id] = includeToken;
Expand Down

0 comments on commit 73b85e1

Please sign in to comment.