homebridge-plugins / homebridge-roomba2

Homebridge plugin to connect iRobot Roomba devices with Homebridge/HomeKit.
MIT License
146 stars 17 forks source link

Unhandled error thrown inside read handler for characteristic #34

Closed khad closed 3 years ago

khad commented 3 years ago

Expected Behavior

Make sure you catch and handle any potential exception that may be thrown while processing GET or SET handlers: https://github.com/homebridge/homebridge/wiki/Characteristic-Warnings#this-plugin-threw-an-error-from-the-characteristic

Current Behavior

They don't appear to be handled. :)

Steps to Reproduce (for bugs)

I turned off Keep Alive because it kept showing device as unresponsive in the Home app, which solved the problem in the Home app but created this error in the logs. Everything seems to be working well other than these errors in the logs.

Versions

Configuration

{
            "name": "Roomba",
            "model": "i7+",
            "blid": "XXXXXXXXX",
            "robotpwd": "XXXXXXXXXXX",
            "ipaddress": "192.168.X.X",
            "autoRefreshEnabled": true,
            "keepAliveEnabled": false,
            "dockContactSensor": true,
            "runningContactSensor": false,
            "binContactSensor": true,
            "cacheTTL": 30,
            "accessory": "Roomba2"
        },

Homebridge Log / Command Output

[3/1/2021, 5:25:59 PM] [Roomba] Running status requested
[3/1/2021, 5:25:59 PM] [Roomba] Using expired status
[3/1/2021, 5:25:59 PM] [homebridge-roomba2] This plugin threw an error from the characteristic 'On': Unhandled error thrown inside read handler for characteristic: This callback function has already been called by someone else; it can only be called one time.. See https://git.io/JtMGR for more info.
[3/1/2021, 5:25:59 PM] [Roomba] Battery status requested
[3/1/2021, 5:25:59 PM] [Roomba] Using expired status
[3/1/2021, 5:25:59 PM] [homebridge-roomba2] This plugin threw an error from the characteristic 'Status Low Battery': Unhandled error thrown inside read handler for characteristic: This callback function has already been called by someone else; it can only be called one time.. See https://git.io/JtMGR for more info.
[3/1/2021, 5:25:59 PM] [Roomba] Using expired status
[3/1/2021, 5:25:59 PM] [Roomba] Battery level requested
[3/1/2021, 5:25:59 PM] [homebridge-roomba2] This plugin threw an error from the characteristic 'Battery Level': Unhandled error thrown inside read handler for characteristic: This callback function has already been called by someone else; it can only be called one time.. See https://git.io/JtMGR for more info.
[3/1/2021, 5:25:59 PM] [Roomba] Using expired status
[3/1/2021, 5:25:59 PM] [Roomba] Charging status requested
[3/1/2021, 5:25:59 PM] [homebridge-roomba2] This plugin threw an error from the characteristic 'Charging State': Unhandled error thrown inside read handler for characteristic: This callback function has already been called by someone else; it can only be called one time.. See https://git.io/JtMGR for more info.
[3/1/2021, 5:25:59 PM] [Roomba] Docked status requested
[3/1/2021, 5:25:59 PM] [Roomba] Using expired status
[3/1/2021, 5:25:59 PM] [homebridge-roomba2] This plugin threw an error from the characteristic 'Contact Sensor State': Unhandled error thrown inside read handler for characteristic: This callback function has already been called by someone else; it can only be called one time.. See https://git.io/JtMGR for more info.
[3/1/2021, 5:25:59 PM] [Roomba] Using expired status
[3/1/2021, 5:25:59 PM] [Roomba] Bin status requested
[3/1/2021, 5:25:59 PM] [homebridge-roomba2] This plugin threw an error from the characteristic 'Contact Sensor State': Unhandled error thrown inside read handler for characteristic: This callback function has already been called by someone else; it can only be called one time.. See https://git.io/JtMGR for more info.
khad commented 3 years ago

Debug logging

[3/1/2021, 6:17:45 PM] [Roomba] Docked status requested
[3/1/2021, 6:17:45 PM] [Roomba] Battery status requested
[3/1/2021, 6:17:45 PM] [Roomba] Bin status requested
[3/1/2021, 6:17:48 PM] [Roomba] Running status requested
[3/1/2021, 6:17:48 PM] [Roomba] Received status: {"running":0,"charging":1,"batteryLevel":100,"batteryStatus":0,"binFull":false,"binStatus":0} -- error: undefined
[3/1/2021, 6:18:05 PM] [Roomba] status expired
[3/1/2021, 6:18:05 PM] [Roomba] Connected to Roomba
[3/1/2021, 6:18:06 PM] [Roomba] Roomba[{"running":0,"charging":1,"batteryLevel":100,"batteryStatus":0,"binFull":false,"binStatus":0}]
[3/1/2021, 6:18:37 PM] [Roomba] status expired
[3/1/2021, 6:18:38 PM] [Roomba] Connected to Roomba
[3/1/2021, 6:18:38 PM] [Roomba] Bin status requested
[3/1/2021, 6:18:38 PM] [Roomba] Using expired status
[3/1/2021, 6:18:38 PM] [homebridge-roomba2] This plugin threw an error from the characteristic 'Contact Sensor State': Unhandled error thrown inside read handler for characteristic: This callback function has already been called by someone else; it can only be called one time.. See https://git.io/JtMGR for more info.
[3/1/2021, 6:18:38 PM] [homebridge-roomba2] Error: This callback function has already been called by someone else; it can only be called one time.
    at /usr/local/lib/node_modules/homebridge/node_modules/hap-nodejs/src/lib/util/once.ts:6:13
    at /homebridge/node_modules/homebridge-roomba2/index.js:225:17
    at roombaAccessory.getStatus (/homebridge/node_modules/homebridge-roomba2/index.js:274:16)
    at roombaAccessory.getFilterStatus (/homebridge/node_modules/homebridge-roomba2/index.js:223:15)
    at ContactSensorState.emit (events.js:315:20)
    at /usr/local/lib/node_modules/homebridge/node_modules/hap-nodejs/src/lib/Characteristic.ts:1493:14
    at new Promise (<anonymous>)
    at ContactSensorState.<anonymous> (/usr/local/lib/node_modules/homebridge/node_modules/hap-nodejs/src/lib/Characteristic.ts:1491:12)
    at step (/usr/local/lib/node_modules/homebridge/node_modules/tslib/tslib.js:143:27)
    at Object.next (/usr/local/lib/node_modules/homebridge/node_modules/tslib/tslib.js:124:57)
    at /usr/local/lib/node_modules/homebridge/node_modules/tslib/tslib.js:117:75
    at new Promise (<anonymous>)
    at Object.__awaiter (/usr/local/lib/node_modules/homebridge/node_modules/tslib/tslib.js:113:16)
    at ContactSensorState.Characteristic.handleGetRequest (/usr/local/lib/node_modules/homebridge/node_modules/hap-nodejs/dist/lib/Characteristic.js:648:24)
    at Bridge.<anonymous> (/usr/local/lib/node_modules/homebridge/node_modules/hap-nodejs/src/lib/Accessory.ts:1507:27)
    at step (/usr/local/lib/node_modules/homebridge/node_modules/tslib/tslib.js:143:27)
    at Object.next (/usr/local/lib/node_modules/homebridge/node_modules/tslib/tslib.js:124:57)
    at /usr/local/lib/node_modules/homebridge/node_modules/tslib/tslib.js:117:75
    at new Promise (<anonymous>)
    at Object.__awaiter (/usr/local/lib/node_modules/homebridge/node_modules/tslib/tslib.js:113:16)
    at Bridge.Accessory.handleCharacteristicRead (/usr/local/lib/node_modules/homebridge/node_modules/hap-nodejs/dist/lib/Accessory.js:1273:24)
    at _loop_1 (/usr/local/lib/node_modules/homebridge/node_modules/hap-nodejs/src/lib/Accessory.ts:1449:12)
[3/1/2021, 6:18:38 PM] [Roomba] Battery status requested
[3/1/2021, 6:18:38 PM] [Roomba] Using expired status
[3/1/2021, 6:18:38 PM] [homebridge-roomba2] This plugin threw an error from the characteristic 'Status Low Battery': Unhandled error thrown inside read handler for characteristic: This callback function has already been called by someone else; it can only be called one time.. See https://git.io/JtMGR for more info.
[3/1/2021, 6:18:38 PM] [homebridge-roomba2] Error: This callback function has already been called by someone else; it can only be called one time.
    at /usr/local/lib/node_modules/homebridge/node_modules/hap-nodejs/src/lib/util/once.ts:6:13
    at /homebridge/node_modules/homebridge-roomba2/index.js:237:17
    at roombaAccessory.getStatus (/homebridge/node_modules/homebridge-roomba2/index.js:274:16)
    at roombaAccessory.getLowBatteryStatus (/homebridge/node_modules/homebridge-roomba2/index.js:235:14)
    at StatusLowBattery.emit (events.js:315:20)
    at /usr/local/lib/node_modules/homebridge/node_modules/hap-nodejs/src/lib/Characteristic.ts:1493:14
    at new Promise (<anonymous>)
    at StatusLowBattery.<anonymous> (/usr/local/lib/node_modules/homebridge/node_modules/hap-nodejs/src/lib/Characteristic.ts:1491:12)
    at step (/usr/local/lib/node_modules/homebridge/node_modules/tslib/tslib.js:143:27)
    at Object.next (/usr/local/lib/node_modules/homebridge/node_modules/tslib/tslib.js:124:57)
    at /usr/local/lib/node_modules/homebridge/node_modules/tslib/tslib.js:117:75
    at new Promise (<anonymous>)
    at Object.__awaiter (/usr/local/lib/node_modules/homebridge/node_modules/tslib/tslib.js:113:16)
    at StatusLowBattery.Characteristic.handleGetRequest (/usr/local/lib/node_modules/homebridge/node_modules/hap-nodejs/dist/lib/Characteristic.js:648:24)
    at Bridge.<anonymous> (/usr/local/lib/node_modules/homebridge/node_modules/hap-nodejs/src/lib/Accessory.ts:1507:27)
    at step (/usr/local/lib/node_modules/homebridge/node_modules/tslib/tslib.js:143:27)
    at Object.next (/usr/local/lib/node_modules/homebridge/node_modules/tslib/tslib.js:124:57)
    at /usr/local/lib/node_modules/homebridge/node_modules/tslib/tslib.js:117:75
    at new Promise (<anonymous>)
    at Object.__awaiter (/usr/local/lib/node_modules/homebridge/node_modules/tslib/tslib.js:113:16)
    at Bridge.Accessory.handleCharacteristicRead (/usr/local/lib/node_modules/homebridge/node_modules/hap-nodejs/dist/lib/Accessory.js:1273:24)
    at _loop_1 (/usr/local/lib/node_modules/homebridge/node_modules/hap-nodejs/src/lib/Accessory.ts:1449:12)
[3/1/2021, 6:18:38 PM] [Roomba] Docked status requested
[3/1/2021, 6:18:38 PM] [Roomba] Using expired status
[3/1/2021, 6:18:38 PM] [homebridge-roomba2] This plugin threw an error from the characteristic 'Contact Sensor State': Unhandled error thrown inside read handler for characteristic: This callback function has already been called by someone else; it can only be called one time.. See https://git.io/JtMGR for more info.
[3/1/2021, 6:18:38 PM] [homebridge-roomba2] Error: This callback function has already been called by someone else; it can only be called one time.
    at /usr/local/lib/node_modules/homebridge/node_modules/hap-nodejs/src/lib/util/once.ts:6:13
    at /homebridge/node_modules/homebridge-roomba2/index.js:200:17
    at roombaAccessory.getStatus (/homebridge/node_modules/homebridge-roomba2/index.js:274:16)
    at roombaAccessory.getDockedState (/homebridge/node_modules/homebridge-roomba2/index.js:198:14)
    at ContactSensorState.emit (events.js:315:20)
    at /usr/local/lib/node_modules/homebridge/node_modules/hap-nodejs/src/lib/Characteristic.ts:1493:14
    at new Promise (<anonymous>)
    at ContactSensorState.<anonymous> (/usr/local/lib/node_modules/homebridge/node_modules/hap-nodejs/src/lib/Characteristic.ts:1491:12)
    at step (/usr/local/lib/node_modules/homebridge/node_modules/tslib/tslib.js:143:27)
    at Object.next (/usr/local/lib/node_modules/homebridge/node_modules/tslib/tslib.js:124:57)
    at /usr/local/lib/node_modules/homebridge/node_modules/tslib/tslib.js:117:75
    at new Promise (<anonymous>)
    at Object.__awaiter (/usr/local/lib/node_modules/homebridge/node_modules/tslib/tslib.js:113:16)
    at ContactSensorState.Characteristic.handleGetRequest (/usr/local/lib/node_modules/homebridge/node_modules/hap-nodejs/dist/lib/Characteristic.js:648:24)
    at Bridge.<anonymous> (/usr/local/lib/node_modules/homebridge/node_modules/hap-nodejs/src/lib/Accessory.ts:1507:27)
    at step (/usr/local/lib/node_modules/homebridge/node_modules/tslib/tslib.js:143:27)
    at Object.next (/usr/local/lib/node_modules/homebridge/node_modules/tslib/tslib.js:124:57)
    at /usr/local/lib/node_modules/homebridge/node_modules/tslib/tslib.js:117:75
    at new Promise (<anonymous>)
    at Object.__awaiter (/usr/local/lib/node_modules/homebridge/node_modules/tslib/tslib.js:113:16)
    at Bridge.Accessory.handleCharacteristicRead (/usr/local/lib/node_modules/homebridge/node_modules/hap-nodejs/dist/lib/Accessory.js:1273:24)
    at _loop_1 (/usr/local/lib/node_modules/homebridge/node_modules/hap-nodejs/src/lib/Accessory.ts:1449:12)
[3/1/2021, 6:18:38 PM] [Roomba] Roomba[{"running":0,"charging":1,"batteryLevel":100,"batteryStatus":0,"binFull":false,"binStatus":0}]
[3/1/2021, 6:19:09 PM] [Roomba] status expired
[3/1/2021, 6:19:09 PM] [Roomba] Connected to Roomba
[3/1/2021, 6:19:10 PM] [Roomba] Roomba[{"running":0,"charging":1,"batteryLevel":100,"batteryStatus":0,"binFull":false,"binStatus":0}]
Casuallynoted commented 3 years ago

I seem to be having the exact same issue with mine. Not sure what's causing it.

aaronjamt commented 3 years ago

Not sure if you're still having the issue but I found that replacing getCharacteristic(...).onGet( with getCharacteristic(...).on('get', and onSet with on('set', fixed it for me. Was Googling this error, found the solution, but found this question too and wanted to contribute if anyone still cares.

EddieDSuza commented 3 years ago

Not sure if you're still having the issue but I found that replacing getCharacteristic(...).onGet( with getCharacteristic(...).on('get', and onSet with on('set', fixed it for me. Was Googling this error, found the solution, but found this question too and wanted to contribute if anyone still cares.

Where exactly were the changes made ?

aaronjamt commented 3 years ago

Not sure if you're still having the issue but I found that replacing getCharacteristic(...).onGet( with getCharacteristic(...).on('get', and onSet with on('set', fixed it for me. Was Googling this error, found the solution, but found this question too and wanted to contribute if anyone still cares.

Where exactly were the changes made ?

I completely forgot about this lol Just checked and it was in index.js but it looks like that might have already been patched.

Edit: I don't see onSet or onGet on any of the versions of that file. It's been so long that I don't remember. Maybe try the reverse (on('get', ... -> onGet(... and on('set', ... -> onSet(...)?

khad commented 3 years ago

Not seeing this with the following configuration:

        {
            "name": "Roomba",
            "model": "i7+",
            "blid": "xxxxxxxxxxxxxxx",
            "robotpwd": "xxxxxxxxxxxxx",
            "ipaddress": "192.168.x.x",
            "autoRefreshEnabled": true,
            "keepAliveEnabled": true,
            "dockContactSensor": true,
            "runningContactSensor": false,
            "binContactSensor": false,
            "cacheTTL": 60,
            "accessory": "Roomba2"
        }

Not sure if anyone else is still seeing the problem(s), but from my perspective this issue can be closed as "can't reproduce".

cc @karlvr

karlvr commented 3 years ago

@khad Thanks for following up on this. I resolved it in #49

joeshub commented 2 years ago

Not seeing this with the following configuration:

  • Homebridge: 1.3.4
  • mDNS Advertiser: Bonjour HAP
  • Roomba2: 1.2.2
        {
            "name": "Roomba",
            "model": "i7+",
            "blid": "xxxxxxxxxxxxxxx",
            "robotpwd": "xxxxxxxxxxxxx",
            "ipaddress": "192.168.x.x",
            "autoRefreshEnabled": true,
            "keepAliveEnabled": true,
            "dockContactSensor": true,
            "runningContactSensor": false,
            "binContactSensor": false,
            "cacheTTL": 60,
            "accessory": "Roomba2"
        }

Not sure if anyone else is still seeing the problem(s), but from my perspective this issue can be closed as "can't reproduce".

cc @karlvr

adding that cacheTTL seems to have fixed my issue