samemory / homebridge-eufy-security

Work in progress
Apache License 2.0
98 stars 14 forks source link

Exception thrown when activating wired Doorbell #34

Closed csrui closed 3 years ago

csrui commented 3 years ago

Describe The Bug: Unhandled errors are being thrown due to functions not being available.

To Reproduce: After a clean installation of both home bridge and eufy security plugin I activated the eufy Wired Doorbell.

Expected behavior: Not sure, never used it before but no errors would be expected :)

Logs:

[6/14/2021, 1:15:06 PM] Homebridge v1.3.4 (Homebridge 5DE1) is running on port 53300.
[6/14/2021, 1:15:09 PM] [EufySecurity] Adding new accessory: Doorbell
(node:2138) UnhandledPromiseRejectionWarning: TypeError: this.eufyDevice.hasBattery is not a function
    at new SecurityDoorbellCameraAccessory (/homebridge/node_modules/homebridge-eufy-security/src/securityDoorbellCameraAccessory.ts:106:24)
    at EufySecurityPlatform.register_accessory (/homebridge/node_modules/homebridge-eufy-security/src/platform.ts:290:9)
    at EufySecurityPlatform.discoverDevices (/homebridge/node_modules/homebridge-eufy-security/src/platform.ts:233:16)
    at processTicksAndRejections (internal/process/task_queues.js:95:5)
    at HomebridgeAPI.<anonymous> (/homebridge/node_modules/homebridge-eufy-security/src/platform.ts:108:7)
(Use `node --trace-warnings ...` to show where the warning was created)
(node:2138) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). To terminate the node process on unhandled promise rejection, use the CLI flag `--unhandled-rejections=strict` (see https://nodejs.org/api/cli.html#cli_unhandled_rejections_mode). (rejection id: 1)
(node:2138) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.
[6/14/2021, 1:15:22 PM] [EufySecurity] Doorbell Triggered GET MotionDetected
[6/14/2021, 1:15:22 PM] [EufySecurity] Doorbell Handle Motion Sensor:  --  false

Plugin Config:

{
    "username": "notehere@cloud.org",
    "password": "noneofyourbusiness",
    "hkHome": 1,
    "hkAway": 0,
    "hkNight": 2,
    "hkOff": 63,
    "platform": "EufySecurity"
}

Environment:

csrui commented 3 years ago

As a follow up I now confirm that the doorbell was rang and I received no notification on HomeKit or any log entry on homebridge.

schliemann commented 3 years ago

Check should be changed to ensure that device supports hasBattery:

if(this.eufyDevice.hasBattery && this.eufyDevice.hasBattery())

On line:

https://github.com/samemory/homebridge-eufy-security/blob/8fbddb722acb838586a4fcd4a2567ac8c9b32df6/src/securityDoorbellCameraAccessory.ts#L106

lenoxys commented 3 years ago

ok I've pushed the modification

lenoxys commented 3 years ago

41

schliemann commented 3 years ago

Please test again with the newest version of the plugin.

github-actions[bot] commented 3 years ago

This issue is stale because it has been open 30 days with no activity. Remove stale label or comment or this will be closed in 5 days.

github-actions[bot] commented 3 years ago

This issue was closed because it has been stalled for 5 days with no activity.