From 6489f20ba370ccb64084fbce553c407bd27549bd Mon Sep 17 00:00:00 2001 From: Thiemo Hoffmann <20605452+theimo1221@users.noreply.github.com> Date: Sun, 6 Aug 2023 21:20:34 +0200 Subject: [PATCH] #548 Debounce Doorbell Presses --- README.md | 1 + src/lib/ownRingCamera.ts | 10 ++++++++++ 2 files changed, 11 insertions(+) diff --git a/README.md b/README.md index 037dd752..d2c4f281 100755 --- a/README.md +++ b/README.md @@ -93,6 +93,7 @@ doorbell recorded video. * (theimo1221) Compliance to adapter-checker * (theimo1221) Update Packages +* (theimo1221) #548 Debounce Doorbell Presses ### 3.4.0 (2023-06-09) diff --git a/src/lib/ownRingCamera.ts b/src/lib/ownRingCamera.ts index d21e0493..dea25170 100644 --- a/src/lib/ownRingCamera.ts +++ b/src/lib/ownRingCamera.ts @@ -94,6 +94,7 @@ export class OwnRingCamera extends OwnRingDevice { private _snapshotCount = 0; private _liveStreamCount = 0; private _state = EventState.Idle; + private _doorbellEventActive: boolean = false; get lastLiveStreamDir(): string { return this._lastLiveStreamDir; @@ -631,11 +632,20 @@ export class OwnRingCamera extends OwnRingDevice { } private onDorbell(value: PushNotificationDing): void { + if (this._doorbellEventActive) { + this.debug(`Recieved Doorbell Event, but we are already reacting. Ignoring.`) + return; + } + this.info("Doorbell pressed --> Will ignore additional presses for the next 25s.") this.debug(`Recieved Doorbell Event (${util.inspect(value, true, 1)})`); + this._doorbellEventActive = true; this._adapter.upsertState(`${this.eventsChannelId}.doorbell`, COMMON_EVENTS_DOORBELL, true); setTimeout(() => { this._adapter.upsertState(`${this.eventsChannelId}.doorbell`, COMMON_EVENTS_DOORBELL, false); }, 5000); + setTimeout(() => { + this._doorbellEventActive = false; + }, 25000); this.conditionalRecording(EventState.ReactingOnDoorbell, value.ding.image_uuid); }