Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Debounce does not work #54

Open
NikolayKash opened this issue Feb 3, 2022 · 1 comment
Open

Debounce does not work #54

NikolayKash opened this issue Feb 3, 2022 · 1 comment

Comments

@NikolayKash
Copy link
Contributor

NikolayKash commented Feb 3, 2022

I noticed that there are too many of the same events posted

I checked this code and it always skips return.

if (currentMotionStates[onvifDeviceId] === motionState) {

I changed it a bit like

if (currentMotionStates[onvifDeviceId] !== undefined) { if (currentMotionStates[onvifDeviceId].IsMotion == motionState.IsMotion) { return; } }

and now an update is sent only when the state is changed.

@Kepro
Copy link

Kepro commented Nov 30, 2022

no need nested conditions

    if (currentMotionStates[onvifDeviceId] !== undefined && currentMotionStates[onvifDeviceId].IsMotion === motionState.IsMotion) {
      return;
    }

or even

    if (currentMotionStates[onvifDeviceId] && currentMotionStates[onvifDeviceId].IsMotion === motionState.IsMotion) {
      return;
    }

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants