Closed bpelech closed 3 years ago
Update:
TypeError: Cannot read property 'writeAsync' of null
at AM43Device.sendCommandAsync (/usr/lib/node_modules/homebridge-am43-blinds/lib/AM43Device.js:325:44)
at AM43Device.updatePositionAsync (/usr/lib/node_modules/homebridge-am43-blinds/lib/AM43Device.js:281:16)
at Characteristic.
TypeError: Cannot read property 'writeAsync' of null
at AM43Device.sendCommandAsync (/usr/lib/node_modules/homebridge-am43-blinds/lib/AM43Device.js:325:44)
at AM43Device.updatePositionAsync (/usr/lib/node_modules/homebridge-am43-blinds/lib/AM43Device.js:281:16)
at Characteristic.
TypeError: Cannot read property 'writeAsync' of null
at AM43Device.sendCommandAsync (/usr/lib/node_modules/homebridge-am43-blinds/lib/AM43Device.js:325:44)
at AM43Device.updateBatteryStatusAsync (/usr/lib/node_modules/homebridge-am43-blinds/lib/AM43Device.js:287:16)
at Characteristic.
TypeError: Cannot read property 'writeAsync' of null
at AM43Device.sendCommandAsync (/usr/lib/node_modules/homebridge-am43-blinds/lib/AM43Device.js:325:44)
at AM43Device.updateBatteryStatusAsync (/usr/lib/node_modules/homebridge-am43-blinds/lib/AM43Device.js:287:16)
at Characteristic.
[9/11/2020, 8:44:33 PM] Got SIGTERM, shutting down Homebridge... [9/11/2020, 8:44:33 PM] [am43-blinds] Homebridge is shutting down, disconnecting AM43 motors and saving state
This looks like an error that can occur when it can discover but not connect to the motor. Try to make sure the blinds engine app is closed on all devices (swipe up). The motor only supports 1 device connected.
Thanks for the tip. Unfortunately blinds engine app is for sure closed and not making this problem.
There might be another issue somewhere on my side. As I mentioned in the "overcoming 5 min shutdown" issue post - I am connecting to the BT devices via remote Raspbery PI. I'm using this RPI as a USB over IP device (homebridge is running inside the VM on a freenas server and somewhere on the LAN sits RPI with BT usb dongle which is exposed over IP to the homebridge server - see more info here if you are interested: https://derushadigital.com/other%20projects/2019/02/19/RPi-USBIP-ZWave.html)
Today I was messing around with the bluetooth libraries (because of the bt xiaomi hygrothermograph I got recently) and I might broke something for the blinds motor. I'll investigate this further and get back once I'll solve it.
Thanks!
I forgot to comment on this issue: I did an update yesterday that could possibly fix this as well.
Plugin still keeps crashing the whole homebridge. To be sure, I reinstalled the plugin, but unfortunately, it keeps crashing. This is a bummer, since I possible found the solution to overcome that 5 min autostop.
Output in the console:
TypeError: Cannot read property 'writeAsync' of null
at AM43Device.sendCommandAsync (/usr/lib/node_modules/homebridge-am43-blinds/lib/AM43Device.js:332:44)
at AM43Device.updatePositionAsync (/usr/lib/node_modules/homebridge-am43-blinds/lib/AM43Device.js:288:16)
at Characteristic.
TypeError: Cannot read property 'writeAsync' of null
at AM43Device.sendCommandAsync (/usr/lib/node_modules/homebridge-am43-blinds/lib/AM43Device.js:332:44)
at AM43Device.updatePositionAsync (/usr/lib/node_modules/homebridge-am43-blinds/lib/AM43Device.js:288:16)
at Characteristic.
[10/5/2020, 5:25:36 PM] Got SIGTERM, shutting down Homebridge...
FYI for anyone interested on that 5 min limit - I intend to use combination of:
First that came to my mind is having a fake switches to open and close and those switches will set timer that will virtually keep pressing up or down for pre-set period of time. Motor seems to behave in a way that if it is already in the up/down limit position it ignores up/down commands.
Interestingly it looks like it always crash during scanning for the Xiaomi hygrotermograph. Not sure if it's related (probably it is), but the TypeError and HB restart always pops up after "[Temperature & Humidity] Start scanning.". Always. How can scanning for other BT device affect this plugin?
Console output: [10/5/2020, 5:36:28 PM] [Temperature & Humidity] Start scanning. TypeError: Cannot read property 'writeAsync' of null at AM43Device.sendCommandAsync (/usr/lib/node_modules/homebridge-am43-blinds/lib/AM43Device.js:332:44) at AM43Device.updatePositionAsync (/usr/lib/node_modules/homebridge-am43-blinds/lib/AM43Device.js:288:16) at PlatformAccessory.accessory.updateInformation (/usr/lib/node_modules/homebridge-am43-blinds/lib/AM43Platform.js:281:29) at poll (/usr/lib/node_modules/homebridge-am43-blinds/node_modules/poll/dist/cjs/poll.js:16:9)
TypeError: Cannot read property 'writeAsync' of null at AM43Device.sendCommandAsync (/usr/lib/node_modules/homebridge-am43-blinds/lib/AM43Device.js:332:44) at AM43Device.updatePositionAsync (/usr/lib/node_modules/homebridge-am43-blinds/lib/AM43Device.js:288:16) at PlatformAccessory.accessory.updateInformation (/usr/lib/node_modules/homebridge-am43-blinds/lib/AM43Platform.js:281:29) at poll (/usr/lib/node_modules/homebridge-am43-blinds/node_modules/poll/dist/cjs/poll.js:16:9)
[10/5/2020, 5:41:18 PM] Got SIGTERM, shutting down Homebridge...
I do not have the Xiaomi hygrothermograph.
Could you download the nRF Connect app on an iPhone (or Android) and see if there are UUIDs of Services or characteristics that are the same between the Xiaomi hygrothermograph and the blinds engine?
@renssies I started an experimental branch a couple of weeks back where I tried to look into these things at https://github.com/neil-morrison44/homebridge-am43-blinds/tree/nm/slats_experiment
There's some stuff that's probably worth PRing into here but it wasn't the "fix everything" solution I was looking for (nor did I actually experiment with slats...)
I found out that sometimes noble will "connect" to a device then immediately disconnect, or the connect timesout, or immediately fails - so I redid the logic around connecting within the AM43Device.js to take multiple attempts, this is the part most likely to fix issues even though it wasn't the "silver bullet" I hoped it would be (it could be that it's close though) https://github.com/neil-morrison44/homebridge-am43-blinds/blob/nm/slats_experiment/lib/AM43Device.js#L242
The Device gets passed the log from the homebridge platform & prepends the device name (really helps when debugging multiple motors)
Devices use their (Blind Engine assigned) names as their homebridge names, not 100% sure about this though, makes it easier if there's 2 motors in a room / on a window.
I rejigged the initial discovery logic, there was 1 time where it tried scanning before the bluetooth part was actually ready so it should wait on that, (don't think this particularly fixed anything, but it didn't seem to break anything either) https://github.com/neil-morrison44/homebridge-am43-blinds/blob/nm/slats_experiment/lib/AM43Platform.js#L117
There's a lot of variables / files moved around and renamed, most of this was exploratory & only worth bringing over if you think anything's been made clearer
Almost forgot this one, but it's the one fix that definitely should be cleaned up & PR'd https://github.com/neil-morrison44/homebridge-am43-blinds/blob/nm/slats_experiment/lib/AM43Device.js#L169, I noticed the AM43 sometimes if you ask for target position 73
(or whatever) it'll go to 72
and think that's good enough - on the current master branch this would cause the position to be updated every second until either device disconnected or a new target was set. So I keep track of the last few positions then whenever they haven't changed in a while I assume the AM43 motor's figured it's close enough to the target and pretend it's reached it.
Have a look, see what you think - on the whole it's not much of an improvement stability-wise to what I was getting on the master branch on the Raspberry Pi 3. (Also only tested on the Raspberry Pi 3).
@neil-morrison44 Sorry for the late reply, I'm working on something with a rather tight deadline but I finally have some time off.
Like I'm said I'm not that good at JavaScript/Node so every change that others think is an improvement I will accept.
As long as the user doesn't have to reconfigure anything I'm happy to merge it into main
if you create a PR with the changes.
If you're not comfortable with that I could also make a develop
branch and merge it into that instead.
Hi @renssies , sorry for late reply.
After a while I decided to throw away the setup I had and just went with pure Homebridge on rpi. Both your and homebridge-mi-hygrothermograph plugins works fine and out of the box.
However, the log is flooded with these:
(node:639) UnhandledPromiseRejectionWarning: TypeError: Cannot read property 'writeAsync' of null at AM43Device.sendCommandAsync (/usr/local/lib/node_modules/homebridge-am43-blinds/lib/AM43Device.js:343:44) at AM43Device.updateBatteryStatusAsync (/usr/local/lib/node_modules/homebridge-am43-blinds/lib/AM43Device.js:305:16) at Characteristic.<anonymous> (/usr/local/lib/node_modules/homebridge-am43-blinds/lib/AM43Platform.js:421:30) at Characteristic.emit (events.js:315:20) at Characteristic.EventEmitter.emit (/usr/local/lib/node_modules/homebridge/node_modules/hap-nodejs/src/lib/EventEmitter.ts:42:22) at Characteristic._this.getValue (/usr/local/lib/node_modules/homebridge/node_modules/hap-nodejs/src/lib/Characteristic.ts:489:12) at /usr/local/lib/node_modules/homebridge/node_modules/hap-nodejs/src/lib/Accessory.ts:1217:22 at Array.forEach (<anonymous>) at Bridge.Accessory._this._handleGetCharacteristics (/usr/local/lib/node_modules/homebridge/node_modules/hap-nodejs/src/lib/Accessory.ts:1145:10) at HAPServer.emit (events.js:315:20) (node:639) 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: 84)
FYI I'm using:
Hmm, this is once again something I can't reproduce on my end.
However, I did see an issue from Neil (#20) that might be related to this. I will wait until Neil knows more
I've not actually seen the 'writeAsync' of null
issue since the "possible fix for fe51 error" commit went in, was getting it a lot before then - now, at least for me, it appears to be trying to reconnect before writing (even if that connection ends up failing)
Hi guys, I'm back at the beginning. As I mentioned before, I changed the setup and I'm running pure homebridge on raspbery pi with BT dongle plugged directly to rpi. What's happening now is quite the same as it did at the beginning (see my first post). But now on a different setup.
Now, everytime when homekit (or homberidge) loads the status from the plugin, it crashes the homekit.
Once I open homekit, or loads accessories in homebridge there is this error in the logs and HB crashes:
TypeError: Cannot read property 'writeAsync' of null at AM43Device.sendCommandAsync (/usr/local/lib/node_modules/homebridge-am43-blinds/lib/AM43Device.js:343:44) at AM43Device.updateBatteryStatusAsync (/usr/local/lib/node_modules/homebridge-am43-blinds/lib/AM43Device.js:305:16) at Characteristic.<anonymous> (/usr/local/lib/node_modules/homebridge-am43-blinds/lib/AM43Platform.js:421:30) at Characteristic.emit (events.js:315:20) at Characteristic.EventEmitter.emit (/usr/local/lib/node_modules/homebridge/node_modules/hap-nodejs/src/lib/EventEmitter.ts:42:22) at Characteristic._this.getValue (/usr/local/lib/node_modules/homebridge/node_modules/hap-nodejs/src/lib/Characteristic.ts:489:12) at /usr/local/lib/node_modules/homebridge/node_modules/hap-nodejs/src/lib/Accessory.ts:1217:22 at Array.forEach (<anonymous>) at Bridge.Accessory._this._handleGetCharacteristics (/usr/local/lib/node_modules/homebridge/node_modules/hap-nodejs/src/lib/Accessory.ts:1145:10) at HAPServer.emit (events.js:315:20) TypeError: Cannot read property 'writeAsync' of null at AM43Device.sendCommandAsync (/usr/local/lib/node_modules/homebridge-am43-blinds/lib/AM43Device.js:343:44) at AM43Device.updateBatteryStatusAsync (/usr/local/lib/node_modules/homebridge-am43-blinds/lib/AM43Device.js:305:16) at Characteristic.<anonymous> (/usr/local/lib/node_modules/homebridge-am43-blinds/lib/AM43Platform.js:421:30) at Characteristic.emit (events.js:315:20) at Characteristic.EventEmitter.emit (/usr/local/lib/node_modules/homebridge/node_modules/hap-nodejs/src/lib/EventEmitter.ts:42:22) at Characteristic._this.getValue (/usr/local/lib/node_modules/homebridge/node_modules/hap-nodejs/src/lib/Characteristic.ts:489:12) at /usr/local/lib/node_modules/homebridge/node_modules/hap-nodejs/src/lib/Accessory.ts:1217:22 at Array.forEach (<anonymous>) at Bridge.Accessory._this._handleGetCharacteristics (/usr/local/lib/node_modules/homebridge/node_modules/hap-nodejs/src/lib/Accessory.ts:1145:10) at HAPServer.emit (events.js:315:20) [14/11/2020, 22:40:34] Got SIGTERM, shutting down Homebridge...
I have to stop using the plugin unfortunately, since it's making my whole HB unstable and unusable.
@renssies if you need something from me to help you debug the issue, just let me know. I'll do my best to help.
Since this issue seems to happen for more people I've created a new issue with some more information to help me find the root of this issue: https://github.com/renssies/homebridge-am43-blinds/issues/21.
@bpelech in the issue you can find some things to help me find the root of this issue.
I will be closing this issue to keep everything tidy.
When I go into the accessories view in the HB web view after few seconds the server is hit by this error end then it restarts: TypeError: Cannot read property 'writeAsync' of null at AM43Device.sendCommandAsync (/usr/lib/node_modules/homebridge-am43-blinds/lib/AM43Device.js:325:44) at AM43Device.updatePositionAsync (/usr/lib/node_modules/homebridge-am43-blinds/lib/AM43Device.js:281:16) at AM43Device.prepareAsync (/usr/lib/node_modules/homebridge-am43-blinds/lib/AM43Device.js:196:16) at Noble. (/usr/lib/node_modules/homebridge-am43-blinds/lib/AM43Platform.js:136:16)
TypeError: Cannot read property 'writeAsync' of null at AM43Device.sendCommandAsync (/usr/lib/node_modules/homebridge-am43-blinds/lib/AM43Device.js:325:44) at AM43Device.updatePositionAsync (/usr/lib/node_modules/homebridge-am43-blinds/lib/AM43Device.js:281:16) at AM43Device.prepareAsync (/usr/lib/node_modules/homebridge-am43-blinds/lib/AM43Device.js:196:16) at Noble. (/usr/lib/node_modules/homebridge-am43-blinds/lib/AM43Platform.js:136:16)
[9/11/2020, 8:28:13 PM] Got SIGTERM, shutting down Homebridge... [9/11/2020, 8:28:13 PM] [am43-blinds] Homebridge is shutting down, disconnecting AM43 motors and saving state