renssies / homebridge-am43-blinds

A homebridge plugin to control the AM43 based blind motors in HomeKit
MIT License
18 stars 6 forks source link

Plugin crashes or "TypeError: Cannot read property 'writeAsync' of undefined" floods homebridge log #21

Open renssies opened 4 years ago

renssies commented 4 years ago

There is a big issue that is occurring on some systems where the plugin crashes (and takes the rest of homebridge offline) or floods the log with the same error message.

This issue is driving me insane because my nodejs skills aren't the best and for some reason, I can't reproduce the issue on 2 of my systems.

So in this issue, I want to collect as much data as possible to help me, or others to fix the issue. Help is very much welcome!

For testing please use a direct version of this plugin. For this use npm uninstall -g homebridge-am43-blinds; npm install -g https://github.com/renssies/homebridge-am43-blinds

When reporting this issue please include the following details:

gielk commented 3 years ago

- Your version of Homebridge (Command: homebridge -V) 1.1.6 - You version of NodeJS (Command: node -v) v10.17.0 just updated to v12.19.0 but this is not a solution for me. - What machine you are running Homebridge on (For example, a Raspberry Pi 4, or iMac 2019) Raspberry Pi model 3B - If you are using a built-in Bluetooth or external Bluetooth dongle. Built-in - An approximation of how far the blinds motor is from the homebridge machine/Bluetooth transmitter. 4 or 5 Meters - A "DEBUG" log of the plugin, see https://github.com/renssies/homebridge-am43-blinds#debugging [12/15/2020, 5:28:53 PM] [am43-blinds] setting target position: 10 AM43 Blind (02:69:e4:ee:05:eb): Device connected: 0269e4ee05eb +0ms AM43 Blind (02:69:e4:ee:05:eb): Device disconnected: 0269e4ee05eb +55ms

and also sometimes I get this message

(node:28688) MaxListenersExceededWarning: Possible EventEmitter memory leak detected. 11 write listeners added to [Characteristic]. Use emitter.setMaxListeners() to increase limit

gielk commented 3 years ago

It seems to me that the following config works best for me.

{ "allowed_devices": [ "02:69:e4:ee:05:eb" ], "scanning_timeout": 20, "hap_interaction_timeout": 0, "poll_interval": 5, "platform": "am43-blinds" }

When I start homebridge I immediately test whether the ARM responds with a Notification. If he responds immediately by giving back a status ( --------Notification--------) of how many % the curtain is closed, he continues to work.

Sometimes I don't get a response/notidications from the ARM-43-Blind, I only see that it is sending --------Command--------then it doesn't seem to work and I restart homebridge immediately and often it works quickly again.

If it doesn't work I see in the log; AM43 Blind (02: 69: e4: ee: 05: eb): Device connected: 0269e4ee05eb + 0ms AM43 Blind (02: 69: e4: ee: 05: eb): Device disconnected: 0269e4ee05eb + 55ms

gielk commented 3 years ago

Oke the problem was that the motor is too far away. I just added 2 more motors. And these are closer to my Raspberry Pi and now there are any problems. AWESOME WORK. Maybe I need to add a Bluetooth dongle for better reach.

neil-morrison44 commented 3 years ago

I had my homebridge updated to v1.2.x for a while and this issue went away - however I ran into the issues with v1.2.x where every homebridge device became unresponsive fairly regularly so I've downgraded back to homebridge v1.1.x & the issue's returned.

Not sure why the homebridge version would matter when the issue appears to be very much Bluetooth connection related but even automations that were connecting to & opening the blinds days after they were last manually controlled were working fine in homebridge v1.2.x.

I'm waiting for a stable v1.2.x before I have another look at improving anything