Closed himbeles closed 3 years ago
Thanks for providing this PR!
Binding this at once for all handlers is not working for me. The plugin throws these errors as soon as a handler gets called.
This plugin threw an error from the characteristic 'On': Unhandled error thrown inside read handler for characteristic: Cannot read property 'eco' of undefined. See https://git.io/JtMGR for more info.
[5/10/2021, 7:12:54 PM] [homebridge-neato] TypeError: Cannot read property 'eco' of undefined
at On.getEco [as getHandler] (/Users/arne/Projekte/homebridge/homebridge-neato/src/accessories/NeatoVacuumRobot.ts:469:23)
at On.<anonymous> (/usr/local/lib/node_modules/homebridge/node_modules/hap-nodejs/src/lib/Characteristic.ts:1450:32)
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 On.Characteristic.handleGetRequest (/usr/local/lib/node_modules/homebridge/node_modules/hap-nodejs/dist/lib/Characteristic.js:656:24)
at Bridge.<anonymous> (/usr/local/lib/node_modules/homebridge/node_modules/hap-nodejs/src/lib/Accessory.ts:1508:27)
at step (/usr/local/lib/node_modules/homebridge/node_modules/tslib/tslib.js:143:27)
I re-added the binding on each handler
Add localization as in #65, but for the TS variant of the plugin:
In this context, I have restructured the plugin a bit to be a bit more modular. Note that I have unified
getSwitchService
andgetOccupancyService
into oneregisterService
function with an optional list of added characteristic handlers as an argument. Getting theServices
is now done viathis.accessory.getServiceById(serviceType, serviceName)
instead ofthis.accessory.getService(displayName)
to not rely on the display name for service identification.