renssies / homebridge-am43-blinds

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

Incorrect status / "Updating" in Homekit #34

Open womby1 opened 3 years ago

womby1 commented 3 years ago

Hey renssies,

first of all thanks a lot for this great plug-in!

I've followed your tutorial to install factually everything works fine. The only bug I encounter is that the status of the motor blinds is not reported back to homekit somehow. After clicking the button in the home app the blinds start to move, then the blind icon switches to a loading wheel and says "updating". Same when I ask Siri through homepod to close the blinds, the blinds start to move, but then siri says "sorry, I did not hear back from your device".

Any idea how to fix that?

renssies commented 3 years ago

Can you share the logs from Homebridge, it sounds like something is going wrong in your specific case.

womby1 commented 3 years ago

Sure thing. When booting homebridge on the Pi I getthis:

[26/5/2021, 7:23:27 pm] [am43-blinds] Stopped searching for AM43 Blinds, found 1 devices (node:1900) UnhandledPromiseRejectionWarning: TypeError: Cannot read property 'writeAsync' of null at AM43Device.sendCommandAsync (/usr/lib/node_modules/homebridge-am43-blinds/lib/AM43Device.js:343:44) at AM43Device.updatePositionAsync (/usr/lib/node_modules/homebridge-am43-blinds/lib/AM43Device.js:299:16) at AM43Device.prepareAsync (/usr/lib/node_modules/homebridge-am43-blinds/lib/AM43Device.js:204:16) at Noble.<anonymous> (/usr/lib/node_modules/homebridge-am43-blinds/lib/AM43Platform.js:136:16) at runNextTicks (internal/process/task_queues.js:58:5) at processTimers (internal/timers.js:494:9) (Usenode --trace-warnings ...to show where the warning was created) (node:1900) 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: 3) (node:1900) [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.

renssies commented 3 years ago

I'm assuming you are using the built-in Bluetooth of the Raspberry Pi and you followed the instructions as mentioned here: https://github.com/renssies/homebridge-am43-blinds#installation

If so, then it might be a range issue. The Raspberry Pi's built-in Bluetooth has a terrible range. Try installing a USB Bluetooth 4.0 adapter in the Pi and disabling the built-in Bluetooth. You can see this issue for compatible adapters: https://github.com/renssies/homebridge-am43-blinds/issues/29#issuecomment-798449516

womby1 commented 3 years ago

Thanks!

I placed it next to the blind using a power bank, but it did not really help it seems

d finite number and received "undefined" (undefined). See https://git.io/JtMGR for more info. (node:3482) UnhandledPromiseRejectionWarning: TypeError: Cannot read property 'on' of undefined at AM43Device.setBlindsControlCharacteristic (/usr/lib/node_modules/homebridge-am43-blinds/lib/AM43Device.js:91:38) at AM43Device.connectAsync (/usr/lib/node_modules/homebridge-am43-blinds/lib/AM43Device.js:223:10) at AM43Device.prepareAsync (/usr/lib/node_modules/homebridge-am43-blinds/lib/AM43Device.js:202:7) (node:3482) 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: 12) (node:3482) UnhandledPromiseRejectionWarning: TypeError: Cannot read property 'on' of undefined at AM43Device.setBlindsControlCharacteristic (/usr/lib/node_modules/homebridge-am43-blinds/lib/AM43Device.js:91:38) at AM43Device.connectAsync (/usr/lib/node_modules/homebridge-am43-blinds/lib/AM43Device.js:223:10) at AM43Device.sendCommandAsync (/usr/lib/node_modules/homebridge-am43-blinds/lib/AM43Device.js:320:7) at AM43Device.updatePositionAsync (/usr/lib/node_modules/homebridge-am43-blinds/lib/AM43Device.js:299:5) (node:3482) 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: 13) (node:3482) UnhandledPromiseRejectionWarning: TypeError: Cannot read property 'on' of undefined at AM43Device.setBlindsControlCharacteristic (/usr/lib/node_modules/homebridge-am43-blinds/lib/AM43Device.js:91:38) at AM43Device.connectAsync (/usr/lib/node_modules/homebridge-am43-blinds/lib/AM43Device.js:223:10) at AM43Device.sendCommandAsync (/usr/lib/node_modules/homebridge-am43-blinds/lib/AM43Device.js:320:7) at AM43Device.updateBatteryStatusAsync (/usr/lib/node_modules/homebridge-am43-blinds/lib/AM43Device.js:305:5) (node:3482) 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: 14)

womby1 commented 3 years ago

image

womby1 commented 3 years ago

I will reinstall homebridge to see if it helps, and also ordered a bluetooth dongle. Will keep you posted!

neil-morrison44 commented 3 years ago

I get similar issues, it usually recovers though so I've not been too worried about it. I've seen the blind position as reported by HomeKit jump around backwards and forwards like there's some sort of out of order issue in dealing with the messages from the blinds. Haven't really looked into it since it remains stable & usable, if a bit jittery in the HomeKit status.

womby1 commented 3 years ago

Have now completely reinstalled my Pi, homebridge and this plugin, using a new bluetooth USB dongle (CSR8510 chipset, which is plug and play).

On first sight, it seems that the updating issue in homebridge is resolved now. Yet, the plugin throws a couple of errors into the log:

`[01/06/2021, 18:24:29] [am43-blinds] Stopped searching for AM43 Blinds, found 1 devices (node:1946) 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.updatePositionAsync (/usr/local/lib/node_modules/homebridge-am43-blinds/lib/AM43Device.js:299:16) at CurrentPosition. (/usr/local/lib/node_modules/homebridge-am43-blinds/lib/AM43Platform.js:461:32) at CurrentPosition.emit (events.js:376:20) at /usr/local/lib/node_modules/homebridge/node_modules/hap-nodejs/dist/lib/Characteristic.js:733:43 at new Promise (:null:null) at CurrentPosition. (/usr/local/lib/node_modules/homebridge/node_modules/hap-nodejs/dist/lib/Characteristic.js:731:47) 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 (:null:null) at Object.awaiter (/usr/local/lib/node_modules/homebridge/node_modules/tslib/tslib.js:113:16) at CurrentPosition.Characteristic.handleGetRequest (/usr/local/lib/node_modules/homebridge/node_modules/hap-nodejs/dist/lib/Characteristic.js:656:24) at Bridge. (/usr/local/lib/node_modules/homebridge/node_modules/hap-nodejs/dist/lib/Accessory.js:1298:54) 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 (:null:null) 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:1275:24) at _loop_1 (/usr/local/lib/node_modules/homebridge/node_modules/hap-nodejs/dist/lib/Accessory.js:1235:20) at Bridge.Accessory.handleGetCharacteristics (/usr/local/lib/node_modules/homebridge/node_modules/hap-nodejs/dist/lib/Accessory.js:1263:17) at HAPServer.emit (events.js:376:20) at HAPServer.handleCharacteristics (/usr/local/lib/node_modules/homebridge/node_modules/hap-nodejs/dist/lib/HAPServer.js:718:18) at IncomingMessage. (/usr/local/lib/node_modules/homebridge/node_modules/hap-nodejs/dist/lib/HAPServer.js:286:21) at IncomingMessage.emit (events.js:388:22) at endReadableNT (internal/streams/readable.js:1336:12) at processTicksAndRejections (internal/process/task_queues.js:82:21)

(Use node --trace-warnings ... to show where the warning was created) (node:1946) 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: 10) (node:1946) [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.`

womby1 commented 3 years ago

Ok, so changing hap_interaction_timeout to 0 solved for me the "not responding issue", however battery drains very fast.

Just for my understanding: If I put said variable to say 60 seconds, what happens after? How will the connection be re-established?

renssies commented 3 years ago

hap_interaction_timeout is suppose to mean that X seconds after you interacted with the accessory it disconnects the bluetooth connection.

So let's say hap_interaction_timeout is 60, that means that after opening or closing the blind with HomeKit it disconnects after 60 seconds. As soon as you interact with it again it should attempt to reconnect and send the open/close command.

However it is a tiny bit buggy and I'm missing the skills to improve it.