Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

No response in homekit #16

Closed
dariusrosendahl opened this issue Oct 24, 2020 · 21 comments
Closed

No response in homekit #16

dariusrosendahl opened this issue Oct 24, 2020 · 21 comments

Comments

@dariusrosendahl
Copy link

Hi there,

First of all, thank you for creating this plugin!

The plugin worked fine for a few weeks. Had some problems and got new wifi (TP-Link M9 mesh router) so I decided to do a complete reinstall of the raspberry pi.

Homebridge can find it but the Home app just keeps saying "No Response".

I tried:

  • Restarting homebridge
  • Resetting the blinds to factory default
  • Turning off bluetooth on phone
  • Setting "hap_interaction_timeout":"0"

I turned on debug mode, this are all the entries the plugin gives me, can you help me where to look?

[10/24/2020, 6:58:49 PM] [am43-blinds] Stopped searching for AM43 Blinds, found 0 devices
[10/24/2020, 6:59:10 PM] [am43-blinds] Started scanning for AM43 blinds, stopping in 5 seconds
[10/24/2020, 6:59:10 PM] [am43-blinds] Started scan for missing devices
[10/24/2020, 6:59:11 PM] [am43-blinds] Found known AM43 Motor: 02:bb:95:80:85:d8 (02:bb:95:80:85:d8)
[10/24/2020, 6:59:15 PM] [am43-blinds] Stopped searching for AM43 Blinds, found 1 devices
[10/24/2020, 6:59:16 PM] [am43-blinds] Requesting position update
[10/24/2020, 6:59:16 PM] [am43-blinds] Reporting position: 100
[10/24/2020, 6:59:16 PM] [am43-blinds] Reporting target position: 100
[10/24/2020, 6:59:16 PM] [am43-blinds] Reporting direction: 2

And my config:

{
  "platform": "am43-blinds",
  "allowed_devices": [
    "02:bb:95:80:85:d8"
  ]
},

Screenshot of home app:
IMG_0310

Would really love to get this plugin to work so I can buy 5 more of these devices 😇

@renssies
Copy link
Owner

renssies commented Oct 24, 2020

Do you have more devices on the same instance of Homebridge, and do those work?

@dariusrosendahl
Copy link
Author

dariusrosendahl commented Oct 24, 2020 via email

@renssies
Copy link
Owner

I'm not sure if you noticed but the plugin was updated just earlier today, so please update it and try running homebridge with -D so homebridge -D as the command. That should add a lot more debug messages to the log.

@dariusrosendahl
Copy link
Author

dariusrosendahl commented Oct 24, 2020

Ah great.

New output:

[10/24/2020, 9:27:00 PM] [am43-blinds] Stopped searching for AM43 Blinds, found 1 devices
2020-10-24T19:27:02.142Z AM43 02:bb:95:80:85:d8 (02:bb:95:80:85:d8): Device connected: 02bb958085d8
2020-10-24T19:27:02.223Z AM43 02:bb:95:80:85:d8 (02:bb:95:80:85:d8): Device disconnected: 02bb958085d8

Apparently it automatically disconnects... when I press a button (both in the Home app or in the homebridge UI) the same thing:

2020-10-24T19:29:13.357Z AM43 02:bb:95:80:85:d8 (02:bb:95:80:85:d8): Device connected: 02bb958085d8
2020-10-24T19:29:13.402Z AM43 02:bb:95:80:85:d8 (02:bb:95:80:85:d8): Device disconnected: 02bb958085d8

Also, the device is always open according to Homebridge UI. Even though it's closed now.

@dariusrosendahl
Copy link
Author

dariusrosendahl commented Oct 24, 2020

Oh, I suddenly get the following error, it's weird because it's saying it's coming from the Sonos ZP plugin but it reads the error in the homebridge-am43-blinds folder:

[10/24/2020, 9:35:55 PM] [ZP] error: 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:62:5)
    at processTimers (internal/timers.js:494:9)

Also, when I start up the server I see another error before the device connected disconnected:

[10/24/2020, 9:41:01 PM] [Config] [HapClient] [192.168.68.106:51166 (0E:93:9B:15:16:B6)] Failed to set value for AM43 Blind Motor.
[10/24/2020, 9:41:01 PM] [Config] [HapClient] [192.168.68.106:51166 (0E:93:9B:15:16:B6)] Failed to set value for AM43 Blind Motor.
[10/24/2020, 9:41:01 PM] [Config] [HapClient] [192.168.68.106:51166 (0E:93:9B:15:16:B6)] Failed to set value for AM43 Blind Motor.
[10/24/2020, 9:41:01 PM] [Config] [HapClient] [192.168.68.106:51166 (0E:93:9B:15:16:B6)] Failed to set value for AM43 Blind Motor.
[10/24/2020, 9:41:01 PM] [Config] [HapClient] [192.168.68.106:51166 (0E:93:9B:15:16:B6)] Failed to set value for AM43 Blind Motor.

@renssies
Copy link
Owner

Looks like you are experiencing the same issue as #7 and #8. The bad part is that I'm unable to reproduce that bug myself and we have yet to find the cause (and a solution).

It can occur when the motor is still connected to the blind engine app, but since you turned off Bluetooth I feel that's not the issue.

Do you use any other Bluetooth HomeKit or Homebridge accessories?

@dariusrosendahl
Copy link
Author

dariusrosendahl commented Oct 24, 2020

Hmm..that's a shame.
I thought it might be because of https://www.npmjs.com/package/homebridge-zp since it referenced the error there. Unfortunately, no luck. My other plugins are the following, but I don't believe any of them are using bluetooth:

Screenshot 2020-10-24 at 21 51 33

For the sake of testing I removed the native 'blinds engine` app. Didn't do anything... I don't think that's it.

Also tried sudo setcap cap_net_raw+eip $(eval readlink -f $(which node)) without any luck.

@dariusrosendahl
Copy link
Author

dariusrosendahl commented Oct 24, 2020

Maybe it's because me and #7 and #8 are on a RBP4? Which would still be weird since it used to work great...

@renssies
Copy link
Owner

Since you are a bit of a web developer. Do you mind to attempt to change a line in the plugin on your machine? You will need to find the plugin in the global modules folder on your machine, this depends on how you've installed node and NPM.

The line is 319 in AM43Device.js. Change it from this

if (!this.isConnected) {

To this

if (!this.isConnected || this.blindsControlCharacteristic == null) {

That should rediscover the blindsControlCharacteristic if it's unavailable before trying to write it.

@renssies
Copy link
Owner

Also, I saw you added that you tried to do sudo setcap cap_net_raw+eip $(eval readlink -f $(which node)). Did that generate an error? When done successfully it shouldn't show anything.

@dariusrosendahl
Copy link
Author

Also, I saw you added that you tried to do sudo setcap cap_net_raw+eip $(eval readlink -f $(which node)). Did that generate an error? When done successfully it shouldn't show anything.

No, the errors (in homebridge logs) were before I tried that. Setting the permissions seems to be working fine and doesn't give any response.

@dariusrosendahl
Copy link
Author

dariusrosendahl commented Oct 24, 2020

Since you are a bit of a web developer. Do you mind to attempt to change a line in the plugin on your machine? You will need to find the plugin in the global modules folder on your machine, this depends on how you've installed node and NPM.

Just bit haha. I work everyday in Typescript/Javascript but making Homebridge plugins or working with Bluetooth is new to me.

The line is 319 in AM43Device.js. Change it from this

if (!this.isConnected) {

To this

if (!this.isConnected || this.blindsControlCharacteristic == null) {

That should rediscover the blindsControlCharacteristic if it's unavailable before trying to write it.

I changed the line. Right now it's been scanning for 2 minutes for devices...seems it can't find any now:

[10/24/2020, 10:26:33 PM] [am43-blinds] Started scanning for AM43 blinds, stopping in 5 seconds
[10/24/2020, 10:26:38 PM] [am43-blinds] Stopped searching for AM43 Blinds, found 0 devices

Those 2 lines keep repeating.

Ah the error I was talking about is when shutting down homebridge. Doesn't seem to be related:

[10/24/2020, 10:25:42 PM] [am43-blinds] Homebridge is shutting down, disconnecting AM43 motors and saving state
[10/24/2020, 10:25:42 PM] [Config] [HapClient] [192.168.68.106:51166 (0E:93:9B:15:16:B6)] Failed to set value for AM43 Blind Motor.
[10/24/2020, 10:25:42 PM] [Config] [HapClient] [192.168.68.106:51166 (0E:93:9B:15:16:B6)] Failed to set value for AM43 Blind Motor.

UPDATE Seems to find it after clicking on open/close blinds in the accessoires tab. Then it disconnects again:

[10/24/2020, 10:33:07 PM] [am43-blinds] Found known AM43 Motor: 02:bb:95:80:85:d8 (02:bb:95:80:85:d8)
[10/24/2020, 10:33:08 PM] [am43-blinds] Stopped searching for AM43 Blinds, found 1 devices
2020-10-24T20:33:17.200Z AM43 02:bb:95:80:85:d8 (02:bb:95:80:85:d8): Device connected: 02bb958085d8
2020-10-24T20:33:17.233Z AM43 02:bb:95:80:85:d8 (02:bb:95:80:85:d8): Device disconnected: 02bb958085d8

@renssies
Copy link
Owner

UPDATE Seems to find it after clicking on open/close blinds in the accessoires tab. Then it disconnects again:

Hmm, just to check, you still have "hap_interaction_timeout":"0" in the config?

@dariusrosendahl
Copy link
Author

dariusrosendahl commented Oct 24, 2020

I actually had it as a number, not a string.I tried to be creative apparently :P

Changing it didn't make a difference though.

@renssies
Copy link
Owner

Hmm, then the motor is getting disconnected by something outside the plugin, and I have no idea what. Maybe it could be a range issue? Try moving the motor closer to the Pi.

Btw. a string should still have been parsed to a number :)

@dariusrosendahl
Copy link
Author

dariusrosendahl commented Oct 24, 2020

Btw. a string should still have been parsed to a number :)

TIL ... :)

Hmm, then the motor is getting disconnected by something outside the plugin, and I have no idea what. Maybe it could be a range issue? Try moving the motor closer to the Pi.

Ok....apparently it's range.... when setting it next to the Pi it works right away. Setting it 4 meters further it stops working. My kitchen is 8 meters away (no walls). Why did it work a few weeks/months ago though .... It's not like you switched to another bluetooth library or something right?

@renssies
Copy link
Owner

renssies commented Oct 24, 2020

It could be that a Pi firmware update reduced the power of the Bluetooth. Have a look online to see if people have similar issues.

If that still doesn't work you could try an external Bluetooth adapter (that is compatible with Pi). The Noble library should automatically switch to an external Bluetooth adapter

Correction: On Linux (including the Raspberry Pi) you have to manually switch the device: https://github.com/abandonware/noble#multiple-adapters-linux-specific

@dariusrosendahl
Copy link
Author

dariusrosendahl commented Oct 24, 2020

It could be that a Pi firmware update reduced the power of the Bluetooth. Have a look online to see if people have similar issues.

If that still doesn't work you could try an external Bluetooth adapter (that is compatible with Pi). The Noble library should automatically switch to an external Bluetooth adapter

Correction: On Linux (including the Raspberry Pi) you have to manually switch the device: https://github.com/abandonware/noble#multiple-adapters-linux-specific

Thanks, I ordered the only one they have on CoolBlue so should be able to try it tomorrow :)

Really hope it works though. Could really see the connection improvement by setting it 1-2 meters away from the Pi. Would be nice to have a pair of automated blinds upstairs in the bedroom too.

Also, what's still weird is that the plugin says it's connected and then disconnected. The native app just keeps loading. Perhaps you could build in some sort of check of you get more then just the name to make sure there aren't more issues like this popping up?

@dariusrosendahl
Copy link
Author

Update. It works! Thank you! I bought this one, but I'm sure any 4.0 dongle will work: https://www.coolblue.nl/product/236284/trust-bluetooth-4-0-usb-adapter.html

It's easier then the link you provided. Steps for the next person:

  1. sudo geany /boot/config.txt

  2. Add dtoverlay=disable-bt to the bottom.

  3. Plug your dongle in

  4. Restart the Pi

  5. 🎉 Tada

@renssies
Copy link
Owner

Nice, I will add that to the troubleshooting section!

@gielk
Copy link

gielk commented Jan 15, 2021

Update. It works! Thank you! I bought this one, but I'm sure any 4.0 dongle will work: https://www.coolblue.nl/product/236284/trust-bluetooth-4-0-usb-adapter.html

It's easier then the link you provided. Steps for the next person:

  1. sudo geany /boot/config.txt
  2. Add dtoverlay=disable-bt to the bottom.
  3. Plug your dongle in
  4. Restart the Pi
  5. 🎉 Tada

This has solved all the problems for me. I now have a stable connection with the curtains and the curtains that were further away now work fine. Previously I sometimes had to restart homebridge during startup because it was not connected to one of the curtains. This has now been resolved. After this change, they now also work faster.

I bought another through AliExpress Baseus Usb Bluetooth Adapter Dongle here is the link
€3,19
https://nl.aliexpress.com/item/32952692648.html

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants