Skip to content

Commit

Permalink
Increase cache tresholds
Browse files Browse the repository at this point in the history
The previous cache and debounce thresholds where too tight, this sometimes led to the RequestingTooQuickly error.
  • Loading branch information
milo526 committed Aug 14, 2020
1 parent 68d8c89 commit 70e68a9
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/accessories/BaseAccessory.ts
Original file line number Diff line number Diff line change
@@ -30,7 +30,7 @@ class Cache<DeviceConfig extends TuyaDevice = TuyaDevice> {
}

public set(data: DeviceConfig['data']): void {
this.validUntil = Cache.getCurrentEpoch() + TUYA_DEVICE_TIMEOUT;
this.validUntil = Cache.getCurrentEpoch() + TUYA_DEVICE_TIMEOUT + 5;
this.value = data;
}

@@ -146,7 +146,7 @@ export abstract class BaseAccessory<DeviceConfig extends TuyaDevice = TuyaDevice
return this.cache.get(always) as unknown as TuyaDeviceState & T;
}

private debouncedDeviceStateRequest = debounce(this.resolveDeviceStateRequest, 200, {maxWait: 1000})
private debouncedDeviceStateRequest = debounce(this.resolveDeviceStateRequest, 500, {maxWait: 1500})
private debouncedDeviceStateRequestPromise?: DebouncedPromise<TuyaDeviceState & DeviceConfig['data']>
public async resolveDeviceStateRequest() {
const promise = this.debouncedDeviceStateRequestPromise;

0 comments on commit 70e68a9

Please sign in to comment.