Skip to content

Commit

Permalink
Merge branch 'master' into fix/air_conditioner_auto_mode
Browse files Browse the repository at this point in the history
  • Loading branch information
tomekkleszcz committed Mar 10, 2024
2 parents c9a34b1 + 69da355 commit 695a123
Show file tree
Hide file tree
Showing 5 changed files with 192 additions and 280 deletions.
28 changes: 28 additions & 0 deletions src/accessories/controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,5 +47,33 @@ export abstract class ElectroluxAccessoryController {
}
}

getCharacteristicValueGuard(
getter: () => Promise<CharacteristicValue>
): () => Promise<CharacteristicValue> {
return async () => {
if (this.appliance.connectionState === 'Disconnected') {
throw new this.platform.api.hap.HapStatusError(
this.platform.api.hap.HAPStatus.SERVICE_COMMUNICATION_FAILURE
);
}

return await getter();
};
}

setCharacteristicValueGuard(
setter: (value: CharacteristicValue) => Promise<void>
): (value: CharacteristicValue) => Promise<void> {
return async (value: CharacteristicValue) => {
if (this.appliance.connectionState === 'Disconnected') {
throw new this.platform.api.hap.HapStatusError(
this.platform.api.hap.HAPStatus.SERVICE_COMMUNICATION_FAILURE
);
}

return setter(value);
};
}

abstract update(appliance: Appliance): void;
}
Loading

0 comments on commit 695a123

Please sign in to comment.