-
Notifications
You must be signed in to change notification settings - Fork 0
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
Continues losing connection. #1
Comments
Same problem, Raspberry Pi 3 bluetooth: 2021-03-23 16:33:11 ERROR (MainThread) [magicswitchbot] MagicSwitchbot communication failed. We won't try again. |
Yesterday I had a similar issue, but now it is running quite stable for me: I think there are several problems here:
That's the theory, but as I can see at your logs, if the device does not connect after 3 attempts, it stops trying and continues at the next minute. Things to consider and that I have to fix:
Definitely I have to implement some alternate strategy for the disconnection check. I'll make some tests and publish a fix as soon as possible. |
@ec-blaster thanks for response. I'm not so experienced with creating plugins, but just as an idea, is it possible to not keep connection active for the whole time? So whenever there is click action - you will establish connection and send request. At least in my case I need to change the state pretty rarely (few times per day). |
In my case (and I think that also for @jampem) the connection does restore over time, I don't have to restart HA. So for the second question, I'm not too experienced either, neither with HA development nor Python development. My first attempt was in fact connecting every time I needed to access the switch, but in my tests, the connection time (including the time you need to get all the acknolewgments and the connection token) was taking too long to do it at the moment you needed. It could take up to 7-8 seconds to activate the switch, and I thought that would not be normal... |
Some thoughts while I am searching for a solution:
Anyway I am rethinking the way the library connects, in next releases I hope to fix it. |
I did disconnect Magic from my iPhone and as I said "the old SwitchBot" works ok. Also tried external bluetooth stick. |
Please check the v0.0.3 release. I hope it solves some of your connection problems... |
At the moment it works perfectly ec-blaster!! Very good job!! Thank you very much!! |
Raspberry 3 internal bluetooth, working little better but still some problems, I will try external bluetooth dongle soon: |
Hi, @jampem, thanks for your feedback. From what I can read at your logs, it seems like you have a quite unstable connection to the Magic Switchbot device. Your raspberry starts connecting but, in about 6 or 7 seconds max, the device falls the connection. Maybe with an USB BT dongle things get better... I don't know. In my experience, I got to connect a BT dongle with an extension cable, so that the dongle was as near as possible. I have a pair of walls in between though. Anyway I can see an uncontrolled exception in my code, and it would be helpful if you could provide another log with DEBUG level set. Thanks |
To @jampem: You can test now release v0.0.4. It has better exception catching. At least your logs will be cleaner and clearer, I hope |
Hi, Sorry the last message was from external bluetooth dongle. Here is RB3 internal and the 0.04 ver. And RB3 and switch are less than a meter apart: 2021-03-30 11:14:57 ERROR (MainThread) [magicswitchbot] MagicSwitchbot[34:14:B5:4A:2E:07] Couldn't connect to device (Failed to connect to peripheral 34:14:B5:4A:2E:07, addr type: public) |
From your logs and bluetoothctl output, I can see that you have constant disconnection issues with the device. Does it work OK from the official app? Doesn't it disconnect? Another thing you can try is to reset the device. I had to do it once: just press the button for about 3-5 seconds until the red led is steady. Then press it again for another 3-5 seconds until the led is blinking. |
It works fine with official app. Also SwitchBot (the old original, battery operated) works ok with Home Assistant's internal bluetooth. I will try with another RBPi3 during Easter. Here is log from external bluetooth dongle: 2021-03-31 22:47:38 INFO (MainThread) [magicswitchbot] MagicSwitchbot[34:14:B5:4A:2E:07] Connected with hci1. |
You can check newer releases, they control better the exceptions, but the underlying problem is a bad connectivity issue. |
Hi @ec-blaster, first of all, many thanks for this great plugin, you did a great job!
I faced a bug, maybe you will be able to help me here?
Precondition:
Connected successfully, everything works fine, MagicSwitchBot is close to my Home Assistant server.
Scenario:
Problem:
Each minute device lose connection, staying unavailable for 1 minute and getting back online for the next minute. And it's repeating each 2 minutes, you can check screenshot of history attached. In my case I need reboot home assistant to restore normal connection.
I believe each time when device is losing connection we will have the same behaviour, and it will never get back to stable connection. Is it common issue, or something specific to my environment?
The text was updated successfully, but these errors were encountered: