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

Device becomes unresponsive #20

Closed
dinki opened this issue Apr 21, 2023 · 12 comments
Closed

Device becomes unresponsive #20

dinki opened this issue Apr 21, 2023 · 12 comments

Comments

@dinki
Copy link

dinki commented Apr 21, 2023

Hi there. First let me thank you for the work you have put into this integration. I found a cheap LED set on Temu and was excited to get it to work with your integration. Everything appeared to be working but it seems that after a while it stops being responsive. A restart oF HA brings it back to a working state for some unknown amount of time but after a while it stops working again. I have found that if I use the gatttool I can again interact with the device though it is slow to respond initially. I do not see any errors in my HA logs.

For reference, this is the device I am using:

gapplication gatttool
bash-5.1# gatttool -I
[ ][LE]> connect be:96:19:00:1e:d3
Attempting to connect to be:96:19:00:1e:d3
Connection successful
[be:96:19:00:1e:d3][LE]> primary
attr handle: 0x0001, end grp handle: 0x0007 uuid: 00001800-0000-1000-8000-00805f9b34fb
attr handle: 0x0008, end grp handle: 0x000b uuid: 00001801-0000-1000-8000-00805f9b34fb
attr handle: 0x000c, end grp handle: 0xffff uuid: 0000fff0-0000-1000-8000-00805f9b34fb
[be:96:19:00:1e:d3][LE]> Characteristics
handle: 0x0002, char properties: 0x02, char value handle: 0x0003, uuid: 00002a00-0000-1000-8000-00805f9b34fb
handle: 0x0004, char properties: 0x02, char value handle: 0x0005, uuid: 00002a01-0000-1000-8000-00805f9b34fb
handle: 0x0006, char properties: 0x02, char value handle: 0x0007, uuid: 00002a04-0000-1000-8000-00805f9b34fb
handle: 0x0009, char properties: 0x20, char value handle: 0x000a, uuid: 00002a05-0000-1000-8000-00805f9b34fb
handle: 0x000d, char properties: 0x06, char value handle: 0x000e, uuid: 0000fff3-0000-1000-8000-00805f9b34fb
handle: 0x000f, char properties: 0x10, char value handle: 0x0010, uuid: 0000fff4-0000-1000-8000-00805f9b34fb

Any idea on what may be causing the device to become unresponsive?

Is there any chance you could post a sample of what it would take to turn the strip on/off using gatttool interactive? I'd like to see if I can do it from there without problem to try and troubleshoot further.

Any help you can provide is most appreciated!

@dave-code-ruiz
Copy link
Owner

Use debug log to see more information of posible errors. i need device discover information that show in debug logs

In configuration.yaml:

logger:
  default: info
  logs:
    custom_components.elkbledom: debug

The integration connect to strip and in some time disconnect, when you send comand to strip integration connect again, you can see this information in debug log.

If other element connect to the strip, the strip is blocked from connecting and HA cannot connect again to it, you can see this information in debug log when this happens.

Post what happens in the debug log in these cases

@dave-code-ruiz
Copy link
Owner

I need too led strip name,

You can scan BT device with BTScan.py in my repository exec: sudo python3 BTScan.py

And it show in my case:

Complete Local Name = ELK-BLEDOM

@dinki
Copy link
Author

dinki commented Apr 24, 2023

Thanks for the help with the logging. Here it is working right after start up:

2023-04-24 06:53:38.809 INFO (MainThread) [homeassistant.setup] Setting up elkbledom
2023-04-24 06:53:38.809 INFO (MainThread) [homeassistant.setup] Setup of domain elkbledom took 0.0 seconds
2023-04-24 06:53:38.957 DEBUG (MainThread) [custom_components.elkbledom.elkbledom] Model information for device ELK-BLEDOM : ModelNo 0, Turn on cmd [126, 0, 4, 240, 0, 1, 255, 0, 239], Turn off cmd [126, 0, 4, 0, 0, 0, 255, 0, 239]
2023-04-24 06:53:40.691 INFO (MainThread) [homeassistant.components.light] Setting up light.elkbledom
2023-04-24 06:53:40.702 DEBUG (MainThread) [custom_components.elkbledom.elkbledom] ELK-BLEDOM : Connecting; RSSI: -56
2023-04-24 06:53:42.558 DEBUG (MainThread) [custom_components.elkbledom.elkbledom] ELK-BLEDOM : Connected; RSSI: -56
2023-04-24 06:53:42.559 DEBUG (MainThread) [custom_components.elkbledom.elkbledom] ELK-BLEDOM : Subscribe to notifications; RSSI: -56
2023-04-24 06:54:39.598 DEBUG (MainThread) [custom_components.elkbledom.light] Params turn on: {}
2023-04-24 06:54:39.598 DEBUG (MainThread) [custom_components.elkbledom.elkbledom] 7e 00 04 f0 00 01 ff 00 ef
2023-04-24 06:54:41.406 DEBUG (MainThread) [custom_components.elkbledom.elkbledom] 7e 00 04 00 00 00 ff 00 ef

and here is what happens after some wait time:

2023-04-24 11:10:33.454 DEBUG (MainThread) [custom_components.elkbledom.light] Params turn on: {}
2023-04-24 11:10:33.455 DEBUG (MainThread) [custom_components.elkbledom.elkbledom] ELK-BLEDOM : Connecting; RSSI: -56
2023-04-24 11:10:58.109 DEBUG (MainThread) [custom_components.elkbledom.elkbledom] ELK-BLEDOM : Disconnected from device; RSSI: -56
2023-04-24 11:11:10.097 DEBUG (MainThread) [custom_components.elkbledom.elkbledom] ELK-BLEDOM : Connected; RSSI: -56
2023-04-24 11:11:10.097 DEBUG (MainThread) [custom_components.elkbledom.elkbledom] ELK-BLEDOM : Subscribe to notifications; RSSI: -56
2023-04-24 11:11:10.098 DEBUG (MainThread) [custom_components.elkbledom.elkbledom] 7e 00 04 f0 00 01 ff 00 ef

Note that I am surprised that this is now working but the delay is large. See the timestamps above. Seems like it takes about 40 seconds from the request for on to the time it actually turns on.

It seems like all of this is a delay in the connection. Like the device is asleep and takes a considerable amount of time to wake. Once it is active I can turn the light on/off close to immediately.

I stand corrected. I tried later and this is what I see:

2023-04-24 12:47:16.360 DEBUG (MainThread) [custom_components.elkbledom.light] Params turn on: {}
2023-04-24 12:47:16.361 DEBUG (MainThread) [custom_components.elkbledom.elkbledom] ELK-BLEDOM : Connecting; RSSI: -56
2023-04-24 12:47:52.371 DEBUG (MainThread) [custom_components.elkbledom.elkbledom] ELK-BLEDOM : <class 'bleak_retry_connector.BleakOutOfConnectionSlotsError'> error calling <function BLEDOMInstance.turn_on at 0x7f4efc9ad2d0>, retrying (0/2)...: ELK-BLEDOM - BE:96:19:00:1E:D3: Failed to connect: No backend with an available connection slot that can reach address BE:96:19:00:1E:D3 was found: The proxy/adapter is out of connection slots; Add additional proxies near this device
File "/config/custom_components/elkbledom/elkbledom.py", line 91, in _async_wrap_retry_bluetooth_connection_error
File "/config/custom_components/elkbledom/elkbledom.py", line 211, in turn_on
File "/config/custom_components/elkbledom/elkbledom.py", line 149, in _write
File "/config/custom_components/elkbledom/elkbledom.py", line 306, in _ensure_connected
2023-04-24 12:47:52.371 DEBUG (MainThread) [custom_components.elkbledom.elkbledom] ELK-BLEDOM : Connecting; RSSI: -56
2023-04-24 12:48:28.382 DEBUG (MainThread) [custom_components.elkbledom.elkbledom] ELK-BLEDOM : <class 'bleak_retry_connector.BleakOutOfConnectionSlotsError'> error calling <function BLEDOMInstance.turn_on at 0x7f4efc9ad2d0>, retrying (1/2)...: ELK-BLEDOM - BE:96:19:00:1E:D3: Failed to connect: No backend with an available connection slot that can reach address BE:96:19:00:1E:D3 was found: The proxy/adapter is out of connection slots; Add additional proxies near this device
File "/config/custom_components/elkbledom/elkbledom.py", line 91, in _async_wrap_retry_bluetooth_connection_error
File "/config/custom_components/elkbledom/elkbledom.py", line 211, in turn_on
File "/config/custom_components/elkbledom/elkbledom.py", line 149, in _write
File "/config/custom_components/elkbledom/elkbledom.py", line 306, in _ensure_connected
2023-04-24 12:48:28.382 DEBUG (MainThread) [custom_components.elkbledom.elkbledom] ELK-BLEDOM : Connecting; RSSI: -56
2023-04-24 12:49:04.393 DEBUG (MainThread) [custom_components.elkbledom.elkbledom] ELK-BLEDOM : <class 'bleak_retry_connector.BleakOutOfConnectionSlotsError'> error calling <function BLEDOMInstance.turn_on at 0x7f4efc9ad2d0>, reach max attempts (2/2): ELK-BLEDOM - BE:96:19:00:1E:D3: Failed to connect: No backend with an available connection slot that can reach address BE:96:19:00:1E:D3 was found: The proxy/adapter is out of connection slots; Add additional proxies near this device
File "/config/custom_components/elkbledom/elkbledom.py", line 91, in _async_wrap_retry_bluetooth_connection_error
File "/config/custom_components/elkbledom/elkbledom.py", line 211, in turn_on
File "/config/custom_components/elkbledom/elkbledom.py", line 149, in _write
File "/config/custom_components/elkbledom/elkbledom.py", line 306, in _ensure_connected
File "/config/custom_components/elkbledom/light.py", line 136, in async_turn_on
File "/config/custom_components/elkbledom/elkbledom.py", line 91, in _async_wrap_retry_bluetooth_connection_error
File "/config/custom_components/elkbledom/elkbledom.py", line 211, in turn_on
File "/config/custom_components/elkbledom/elkbledom.py", line 149, in _write
File "/config/custom_components/elkbledom/elkbledom.py", line 306, in _ensure_connected

also I tried running the BTScan.py and it gave errors as bluepy was not installed on my system. I tried installing using pip3 and received these errors:

root@omv6:/sharedfolders/appdata/HomeAssistant# pip3 install bluepy
Collecting bluepy
Downloading bluepy-1.3.0.tar.gz (217 kB)
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 217.9/217.9 kB 3.3 MB/s eta 0:00:00
Preparing metadata (setup.py) ... done
Building wheels for collected packages: bluepy
Building wheel for bluepy (setup.py) ... error
error: subprocess-exited-with-error

× python setup.py bdist_wheel did not run successfully.
│ exit code: 1
╰─> [6 lines of output]
running bdist_wheel
running build
running build_py
Working dir is /tmp/pip-install-vqjoosal/bluepy_2c321c49953443f89b33a45401d004bf
execute make -C ./bluepy clean
error: [Errno 2] No such file or directory: 'make'
[end of output]

note: This error originates from a subprocess, and is likely not a problem with pip.
ERROR: Failed building wheel for bluepy
Running setup.py clean for bluepy
Failed to build bluepy
ERROR: Could not build wheels for bluepy, which is required to install pyproject.toml-based projects

Unfortunately I'm technically challenged when it comes to this sort of stuff and I was not able to figure out how to get it installed so I cannot run the script. Any ideas on that?

Thanks for your help on troubleshooting!

@dave-code-ruiz
Copy link
Owner

dave-code-ruiz commented Apr 25, 2023

Ok , your error is "<class 'bleak_retry_connector.BleakOutOfConnectionSlotsError'> error calling <function BLEDOMInstance.turn_on at 0x7f4efc9ad2d0>, reach max attempts (2/2): ELK-BLEDOM - BE:96:19:00:1E:D3: Failed to connect: No backend with an available connection slot that can reach address BE:96:19:00:1E:D3 was found: The proxy/adapter is out of connection slots; Add additional proxies near this device"

No backend with an available connection slot that can reach address BE:96:19:00:1E:D3, If other element connect to the strip, the strip is blocked from connecting and HA cannot connect again to it.

the rest of the behavior of the led strip is normal, it is necessary to disconnect it when it is not in use and reconnect is slow

You dont need now BTScan.py, your name is the same ELK-BLEDOM

@dinki
Copy link
Author

dinki commented Apr 25, 2023

Could you possibly tell me how to turn the lights on/off using the gatttool tool? I'd like to test a few things.

@dave-code-ruiz
Copy link
Owner

You can use gatttool to try with:

sudo gatttool -i hci0 -b be:59:7a:00:08:xx --char-write-req -a 0x0009 -n 7e0004f00001ff00ef # POWERON
sudo gatttool -i hci0 -b be:59:7a:00:08:xx --char-write-req -a 0x0009 -n 7e00050300ff0000ef # POWEROFF

or

sudo gatttool -b be:59:7a:00:08:xx --char-write-req -a 0x0009 -n 7e0004f00001ff00ef # POWER ON
sudo gatttool -b be:59:7a:00:08:xx --char-write-req -a 0x0009 -n 7e000503ff000000ef # RED
sudo gatttool -b be:59:7a:00:08:xx --char-write-req -a 0x0009 -n 7e0005030000ff00ef # BLUE
sudo gatttool -b be:59:7a:00:08:xx --char-write-req -a 0x0009 -n 7e00050300ff0000ef # GREEN
sudo gatttool -b be:59:7a:00:08:xx --char-write-req -a 0x0009 -n 7e0004000000ff00ef # POWER OFF

@dave-code-ruiz
Copy link
Owner

if you use gatttool and HA it is normal HA shows this error:

"The proxy/adapter is out of connection slots"

I am changing the integration so that the timeout can be configured and the option to choose zero to never disconnect

dave-code-ruiz added a commit that referenced this issue Apr 26, 2023
- Change integration configuration, create param timeout in seconds to disconnect led strip, if zero never disconnect. #20
- Change turn on and turn off commands to MELK strip #11
@dave-code-ruiz
Copy link
Owner

Now , with version 1.0.3 you never disconnect HA and Led Strip, and in config integration , you can set timeout in seconds to disconnect it

Try and close issue if works for you

@dinki
Copy link
Author

dinki commented Apr 26, 2023

I cannot thank you enough for your help with this. So far, I have waited two hours between attempts to turn on/off and it has worked without issue and is immediate. I will try again after waiting over night and if it works I'll happily close the ticket with full resolution of the issue.

@dave-code-ruiz
Copy link
Owner

dave-code-ruiz commented Apr 27, 2023

you can thanks me buying me a coffee, jeje, I'm glad to know it's resolved, when you can, close the issue

@dinki
Copy link
Author

dinki commented Apr 27, 2023

you can thanks me buying me a coffee, jeje, I'm glad to know it's resolved, when you can, close the issue

Seems to be working great! Thank you! Do you have Paypal? If so, can you get me the email somehow?

@dinki dinki closed this as completed Apr 27, 2023
@dave-code-ruiz
Copy link
Owner

dave-code-ruiz commented Apr 28, 2023

Donate

Buy Me A Coffee

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

2 participants