Skip to content

Commit c3dd63f

Browse files
committed
Don't reset timer unless InUse changes
1 parent 1d49de1 commit c3dd63f

1 file changed

Lines changed: 4 additions & 2 deletions

File tree

src/accessory/valve.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -98,16 +98,18 @@ export class ValveAccessory extends BaseAccessory<ValveConfig> {
9898

9999
override onUpdate(key: HKCharacteristicKey, value: CharacteristicValue, logString: string | undefined = undefined): boolean {
100100

101+
const changed = super.onUpdate(key, value, logString);
102+
101103
if (this.simulateDuration && key === HKCharacteristicKey.InUse) {
102104

103-
if (value === this.Characteristic.InUse.IN_USE) {
105+
if (changed && value === this.Characteristic.InUse.IN_USE) {
104106
this.startTimerSimulator();
105107
} else if (value === this.Characteristic.InUse.NOT_IN_USE) {
106108
this.stopTimerSimulator();
107109
}
108110
}
109111

110-
return super.onUpdate(key, value, logString);
112+
return changed;
111113
}
112114

113115
private get remainingDuration(): number {

0 commit comments

Comments
 (0)