Skip to content

Commit

Permalink
#548 Debounce Doorbell Presses
Browse files Browse the repository at this point in the history
  • Loading branch information
theimo1221 committed Aug 6, 2023
1 parent cd4c342 commit 6489f20
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 0 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down
10 changes: 10 additions & 0 deletions src/lib/ownRingCamera.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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);
}

Expand Down

0 comments on commit 6489f20

Please sign in to comment.