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

Support for newer type #11

Open
infernix opened this issue Dec 18, 2022 · 45 comments
Open

Support for newer type #11

infernix opened this issue Dec 18, 2022 · 45 comments

Comments

@infernix
Copy link

infernix commented Dec 18, 2022

Hi,

I've got some strips that report as MELK (found device: BE:16:71:00:18:91 0 MELK-OA10 ) instead of ELK and they use the DuoCo StripX app from the play store. By default they don't seem to work. For what I can tell, it looks as if these are looking for some initial (auth?) packet before they accept commands.

After I send char-write-cmd 0x0009 7e0783 and then 7e0404 I got them to work. From then on they seem happy to accept all existing commands.

gattool reports:

[BE:16:71:00:18:91][LE]> primary 
attr handle: 0x0001, end grp handle: 0x0003 uuid: 00001800-0000-1000-8000-00805f9b34fb
attr handle: 0x0004, end grp handle: 0x0009 uuid: 0000fff0-0000-1000-8000-00805f9b34fb
[BE:16:71:00:18:91][LE]> characteristics 
handle: 0x0002, char properties: 0x12, char value handle: 0x0003, uuid: 00002a00-0000-1000-8000-00805f9b34fb
handle: 0x0005, char properties: 0x10, char value handle: 0x0006, uuid: 0000fff4-0000-1000-8000-00805f9b34fb
handle: 0x0008, char properties: 0x06, char value handle: 0x0009, uuid: 0000fff3-0000-1000-8000-00805f9b34fb

Here's the base64-encoded btsnoop log:

YnRzbm9vcAAAAAABAAAD6gAAAAwAAAAMAAAAAQAAAAAA4s3Mx5T8fAIKIAcAAwAEAALIAAAAAAwA
AAAMAAAAAAAAAAAA4s3Mx5UQTAIKAAcAAwAEAAPIAAAAABcAAAAPAAAAAQAAAAAA4s3Mx5XnHQIK
IBIADgAEABEGAQADAAAAAA4AAAAOAAAAAQAAAAAA4s3Mx5bSFwIKIAkABQAEAAEQCgAKAAAADgAA
AA4AAAABAAAAAADizczHmDCWAgogCQAFAAQAAQgBAAoAAAAOAAAADgAAAAEAAAAAAOLNzMeafMAC
CiAJAAUABAABCAMACgAAAA4AAAAOAAAAAQAAAAAA4s3Mx5tv3gIKIAkABQAEAAEIBAAKAAAAGQAA
AA8AAAABAAAAAADizczHm6kTAgogFAAQAAQACQcFABAGAAAADgAAAA4AAAABAAAAAADizczHm+NX
AgogCQAFAAQAAQgJAAoAAAAOAAAADgAAAAAAAAAAAOLNzMeb5OwCCgAJAAUABAAEBwAHAAAAAA8A
AAAPAAAAAQAAAAAA4s3Mx5w7gQIKIAoABgAEAAUBBwACKQAAAAwAAAAMAAAAAAAAAAAA4s3Mx6Gw
jwIKAAcAAwAEAAoJAAAAABoAAAAPAAAAAQAAAAAA4s3Mx6K3YAIKIBUAEQAEAAt+BATwAAAAABUA
AAAPAAAAAAAAAAAA4s3Mx6MSlQIKABAADAAEAFIJAH4HgwAAAA8AAAAPAAAAAAAAAAAA4s3Mx6vg
qQIKAAoABgAFABMCAgAAAAAAABUAAAAPAAAAAAAAAAAA4s3Mx7JSjAIKABAADAAEAFIJAH4EBAAA
ABUAAAAPAAAAAAAAAAAA4s3Mx7162wIKABAADAAEAFIJAH4EBAAAABUAAAAPAAAAAAAAAAAA4s3M
x8g/HAIKABAADAAEAFIJAH4EBA==

(save as melk.txt, then cat melk.txt | base64 -d > melk.log and open that in wireshark)

Any ideas what more you would need to support these?

@dave-code-ruiz
Copy link
Owner

dave-code-ruiz commented Dec 27, 2022

thanks, i try to develop integration for your strip, i need time, and i sent you some changes to try it , because i can't test it

dave-code-ruiz added a commit that referenced this issue Dec 28, 2022
- Support for new devices in #10 and #11
- Configure reset white for #12
@dave-code-ruiz
Copy link
Owner

Please, try to test the code in main repository in:

34813b2

I think you can integrate in HA your strip and do operations "turn on" and "turn off"

If you have any problem, please, report here

thanks

@dave-code-ruiz
Copy link
Owner

I create new release 1.0.0 , you can try is and test your led strip.

please report results here

Thanks

@infernix
Copy link
Author

infernix commented Dec 29, 2022

It's detecting them, but when adding:

2022-12-29 12:17:49.453 ERROR (MainThread) [aiohttp.server] Error handling request
Traceback (most recent call last):
  File "/usr/local/lib/python3.10/site-packages/aiohttp/web_protocol.py", line 435, in _handle_request
    resp = await request_handler(request)
  File "/usr/local/lib/python3.10/site-packages/aiohttp/web_app.py", line 504, in _handle
    resp = await handler(request)
  File "/usr/local/lib/python3.10/site-packages/aiohttp/web_middlewares.py", line 117, in impl
    return await handler(request)
  File "/usr/src/homeassistant/homeassistant/components/http/security_filter.py", line 60, in security_filter_middleware
    return await handler(request)
  File "/usr/src/homeassistant/homeassistant/components/http/forwarded.py", line 222, in forwarded_middleware
    return await handler(request)
  File "/usr/src/homeassistant/homeassistant/components/http/request_context.py", line 28, in request_context_middleware
    return await handler(request)
  File "/usr/src/homeassistant/homeassistant/components/http/ban.py", line 81, in ban_middleware
    return await handler(request)
  File "/usr/src/homeassistant/homeassistant/components/http/auth.py", line 236, in auth_middleware
    return await handler(request)
  File "/usr/src/homeassistant/homeassistant/components/http/view.py", line 136, in handle
    result = await result
  File "/usr/src/homeassistant/homeassistant/components/config/config_entries.py", line 180, in post
    return await super().post(request, flow_id)
  File "/usr/src/homeassistant/homeassistant/components/http/data_validator.py", line 73, in wrapper
    result = await method(view, request, data, *args, **kwargs)
  File "/usr/src/homeassistant/homeassistant/helpers/data_entry_flow.py", line 110, in post
    result = await self._flow_mgr.async_configure(flow_id, data)
  File "/usr/src/homeassistant/homeassistant/data_entry_flow.py", line 281, in async_configure
    result = await self._async_handle_step(
  File "/usr/src/homeassistant/homeassistant/data_entry_flow.py", line 368, in _async_handle_step
    result: FlowResult = await getattr(flow, method)(user_input)
  File "/config/custom_components/elkbledom/config_flow.py", line 96, in async_step_user
    return await self.async_step_validate()
  File "/config/custom_components/elkbledom/config_flow.py", line 137, in async_step_validate
    error = await self.toggle_light()
  File "/config/custom_components/elkbledom/config_flow.py", line 171, in toggle_light
    self._instance = BLEDOMInstance(self.mac, False, self.hass)
  File "/config/custom_components/elkbledom/elkbledom.py", line 133, in __init__
    self._model = self._detect_model()
  File "/config/custom_components/elkbledom/elkbledom.py", line 138, in _detect_model
    if self._device.name.lower().startswith(name.lower()):
AttributeError: 'NoneType' object has no attribute 'name'

They show up as MELK-OA10 33 and MELK-OA10 F1. I'm on HA 2022.12 FWIW.

@dave-code-ruiz
Copy link
Owner

dave-code-ruiz commented Dec 29, 2022

Update version 1.0.1 and try in HomeAssistant 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

@dave-code-ruiz
Copy link
Owner

I need know too if you use "manual mac" or HA discover the strip Mac and show its name.

Thanks

@infernix
Copy link
Author

I used discovery. There's not much more logged with that enabled:

2022-12-29 15:34:52.008 DEBUG (MainThread) [custom_components.elkbledom.config_flow] Discovered bluetooth devices, step bluetooth, : <home_assistant_bluetooth.models.BluetoothServiceInfoBleak object at 0x7fddf39b0ec0>
2022-12-29 15:34:52.009 DEBUG (MainThread) [custom_components.elkbledom.config_flow] Discovered bluetooth devices, step bluetooth confirm, : None
2022-12-29 15:34:52.009 DEBUG (MainThread) [custom_components.elkbledom.config_flow] Discovered supported devices: MELK-OA10   33 - BE:16:9E:00:02:33
2022-12-29 15:48:44.321 DEBUG (MainThread) [custom_components.elkbledom.config_flow] Discovered bluetooth devices, step bluetooth, : <home_assistant_bluetooth.models.BluetoothServiceInfoBleak object at 0x7fddf0e99c40>
2022-12-29 22:52:31.928 DEBUG (MainThread) [custom_components.elkbledom.config_flow] Discovered supported devices: MELK-OA10   33 - BE:16:9E:00:02:33

Then when trying to add, same backtrace as before.

@dave-code-ruiz
Copy link
Owner

You have old version of elkbledom integration, please update it to last version 1.0.1 and remember restart Home Assistant first to test it again.

Thanks

@infernix
Copy link
Author

So I updated and the error goes away, but it doesn't turn on and off. I'll try to figure out the correct startup sequence once i have some more time, I must've missed something.

@dave-code-ruiz
Copy link
Owner

Please, can you send me in separate , init command sequence, turn on command and turn off command, it is posible i confuce it.

@sasukebinbin
Copy link

Hi I have the almost same model and behave same as it show up as MELK-OA10 F0 and successfully add in HA. But cannot turn on and off.

@dave-code-ruiz
Copy link
Owner

I cannot try or discover strip information i have not a strip to try.

I only need you send me in separate, init command (if is needed) , turn on command and turn off command.

You can google search this information and try it with your led strip, if works for you post it here and i change integration to work

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

Hi I have the almost same model and behave same as it show up as MELK-OA10 F0 and successfully add in HA. But cannot turn on and off.

Please, test with new turn on and turn off commands in version 1.0.3 and post results, thnks

dave-code-ruiz added a commit that referenced this issue Apr 27, 2023
@dave-code-ruiz
Copy link
Owner

Please, test too with new init command in version 1.0.5 and post results, thnks

@sasukebinbin
Copy link

sasukebinbin commented Apr 28, 2023

After update to 1.0.5, It still can auto discover the light, but unable to add it with unknown error.
Logs shows

Logger: aiohttp.server
Source: custom_components/elkbledom/config_flow.py:171
Integration: ElkBLEDOM (documentation, issues)
First occurred: 09:09:35 (5 occurrences)
Last logged: 09:14:01

Error handling request
Traceback (most recent call last):
  File "/usr/local/lib/python3.10/site-packages/aiohttp/web_protocol.py", line 433, in _handle_request
    resp = await request_handler(request)
  File "/usr/local/lib/python3.10/site-packages/aiohttp/web_app.py", line 504, in _handle
    resp = await handler(request)
  File "/usr/local/lib/python3.10/site-packages/aiohttp/web_middlewares.py", line 117, in impl
    return await handler(request)
  File "/usr/src/homeassistant/homeassistant/components/http/security_filter.py", line 85, in security_filter_middleware
    return await handler(request)
  File "/usr/src/homeassistant/homeassistant/components/http/forwarded.py", line 227, in forwarded_middleware
    return await handler(request)
  File "/usr/src/homeassistant/homeassistant/components/http/request_context.py", line 28, in request_context_middleware
    return await handler(request)
  File "/usr/src/homeassistant/homeassistant/components/http/ban.py", line 80, in ban_middleware
    return await handler(request)
  File "/usr/src/homeassistant/homeassistant/components/http/auth.py", line 235, in auth_middleware
    return await handler(request)
  File "/usr/src/homeassistant/homeassistant/components/http/view.py", line 146, in handle
    result = await result
  File "/usr/src/homeassistant/homeassistant/components/config/config_entries.py", line 180, in post
    return await super().post(request, flow_id)
  File "/usr/src/homeassistant/homeassistant/components/http/data_validator.py", line 72, in wrapper
    result = await method(view, request, data, *args, **kwargs)
  File "/usr/src/homeassistant/homeassistant/helpers/data_entry_flow.py", line 110, in post
    result = await self._flow_mgr.async_configure(flow_id, data)
  File "/usr/src/homeassistant/homeassistant/data_entry_flow.py", line 271, in async_configure
    result = await self._async_handle_step(
  File "/usr/src/homeassistant/homeassistant/data_entry_flow.py", line 367, in _async_handle_step
    result: FlowResult = await getattr(flow, method)(user_input)
  File "/config/custom_components/elkbledom/config_flow.py", line 96, in async_step_user
    return await self.async_step_validate()
  File "/config/custom_components/elkbledom/config_flow.py", line 137, in async_step_validate
    error = await self.toggle_light()
  File "/config/custom_components/elkbledom/config_flow.py", line 171, in toggle_light
    self._instance = BLEDOMInstance(self.mac, False, self.hass)
TypeError: BLEDOMInstance.__init__() missing 1 required positional argument: 'hass'

@dave-code-ruiz
Copy link
Owner

After update to 1.0.5, It still can auto discover the light, but unable to add it with unknown error. Logs shows

Logger: aiohttp.server
Source: custom_components/elkbledom/config_flow.py:171
Integration: ElkBLEDOM (documentation, issues)
First occurred: 09:09:35 (5 occurrences)
Last logged: 09:14:01

Error handling request
Traceback (most recent call last):
  File "/usr/local/lib/python3.10/site-packages/aiohttp/web_protocol.py", line 433, in _handle_request
    resp = await request_handler(request)
  File "/usr/local/lib/python3.10/site-packages/aiohttp/web_app.py", line 504, in _handle
    resp = await handler(request)
  File "/usr/local/lib/python3.10/site-packages/aiohttp/web_middlewares.py", line 117, in impl
    return await handler(request)
  File "/usr/src/homeassistant/homeassistant/components/http/security_filter.py", line 85, in security_filter_middleware
    return await handler(request)
  File "/usr/src/homeassistant/homeassistant/components/http/forwarded.py", line 227, in forwarded_middleware
    return await handler(request)
  File "/usr/src/homeassistant/homeassistant/components/http/request_context.py", line 28, in request_context_middleware
    return await handler(request)
  File "/usr/src/homeassistant/homeassistant/components/http/ban.py", line 80, in ban_middleware
    return await handler(request)
  File "/usr/src/homeassistant/homeassistant/components/http/auth.py", line 235, in auth_middleware
    return await handler(request)
  File "/usr/src/homeassistant/homeassistant/components/http/view.py", line 146, in handle
    result = await result
  File "/usr/src/homeassistant/homeassistant/components/config/config_entries.py", line 180, in post
    return await super().post(request, flow_id)
  File "/usr/src/homeassistant/homeassistant/components/http/data_validator.py", line 72, in wrapper
    result = await method(view, request, data, *args, **kwargs)
  File "/usr/src/homeassistant/homeassistant/helpers/data_entry_flow.py", line 110, in post
    result = await self._flow_mgr.async_configure(flow_id, data)
  File "/usr/src/homeassistant/homeassistant/data_entry_flow.py", line 271, in async_configure
    result = await self._async_handle_step(
  File "/usr/src/homeassistant/homeassistant/data_entry_flow.py", line 367, in _async_handle_step
    result: FlowResult = await getattr(flow, method)(user_input)
  File "/config/custom_components/elkbledom/config_flow.py", line 96, in async_step_user
    return await self.async_step_validate()
  File "/config/custom_components/elkbledom/config_flow.py", line 137, in async_step_validate
    error = await self.toggle_light()
  File "/config/custom_components/elkbledom/config_flow.py", line 171, in toggle_light
    self._instance = BLEDOMInstance(self.mac, False, self.hass)
TypeError: BLEDOMInstance.__init__() missing 1 required positional argument: 'hass'

Issue solved in version 1.0.6,

Sorry, my mistake

@sasukebinbin
Copy link

No issue to add now. But still unable to control.
It can control by this remote or duoCo StripX.app.
I have only Mac and iPhone, not sure how can I help to test or provide any info.
If can please let me know.
F29CC09D-FE1F-4E4B-932B-989109A1C8D3_1_102_o

@nikolmedo
Copy link

I have the same lights as @sasukebinbin, it runs with the same app and control.
I have Windows and Android, how can I help develop compatibility with this device?

@dave-code-ruiz
Copy link
Owner

dave-code-ruiz commented Apr 28, 2023

You can use gatttool to try discover your init, turn on/off command with:

@infernix detect you need use init commands -n 7e0783 and then -n 7e0404 and before you can turn on off

sudo gatttool -i hci0 -b be:59:7a:00:08:xx --char-write-req -a 0x0009 -n 7e00040100000000ef # POWERON
sudo gatttool -i hci0 -b be:59:7a:00:08:xx --char-write-req -a 0x0009 -n 7e0004000000ff00ef # 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

@nikolmedo
Copy link

I tested all the commands using gatttools and it works locally, but when I tried to add it to HA I got the following error:

2023-04-28 19:11:41.150 DEBUG (MainThread) [custom_components.elkbledom.config_flow] Discovered bluetooth devices, step bluetooth, : BE:16:0D:00:02:04 , MELK-OA10 04
2023-04-28 19:11:41.151 DEBUG (MainThread) [custom_components.elkbledom.config_flow] Discovered bluetooth devices, step bluetooth confirm, : None
2023-04-28 19:11:41.155 DEBUG (MainThread) [custom_components.elkbledom.config_flow] Discovered supported devices: MELK-OA10 04 - BE:16:0D:00:02:04
2023-04-28 19:11:41.276 DEBUG (MainThread) [custom_components.elkbledom.config_flow] Discovered bluetooth devices, step bluetooth, : BE:16:A9:00:00:91 , MELK-OA10 91
2023-04-28 19:11:41.277 DEBUG (MainThread) [custom_components.elkbledom.config_flow] Discovered bluetooth devices, step bluetooth confirm, : None
2023-04-28 19:11:41.280 DEBUG (MainThread) [custom_components.elkbledom.config_flow] Discovered supported devices: MELK-OA10 91 - BE:16:A9:00:00:91
2023-04-28 19:13:18.731 DEBUG (MainThread) [custom_components.elkbledom.config_flow] Discovered supported devices: MELK-OA10 91 - BE:16:A9:00:00:91
2023-04-28 19:13:34.489 DEBUG (MainThread) [custom_components.elkbledom.elkbledom] Model information for device MELK-OA10 91 : ModelNo 2, 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-28 19:13:34.517 DEBUG (MainThread) [custom_components.elkbledom.elkbledom] MELK-OA10 91: Connecting; RSSI: -91
2023-04-28 19:13:37.745 DEBUG (MainThread) [custom_components.elkbledom.config_flow] Discovered bluetooth devices, step bluetooth, : BE:16:A9:00:00:91 , MELK-OA10 91
2023-04-28 19:13:37.754 DEBUG (MainThread) [custom_components.elkbledom.elkbledom] MELK-OA10 91: Connected; RSSI: -83
2023-04-28 19:13:37.755 DEBUG (MainThread) [custom_components.elkbledom.elkbledom] MELK-OA10 91: Disconnected from device in 120 seconds; RSSI: -83
2023-04-28 19:13:37.756 DEBUG (MainThread) [custom_components.elkbledom.elkbledom] MELK-OA10 91: Subscribe to notifications; RSSI: -83
2023-04-28 19:14:07.823 ERROR (MainThread) [custom_components.elkbledom.elkbledom] Error getting status: [org.bluez.Error.Failed] Operation failed with ATT error: 0x0e (Unlikely Error)
2023-04-28 19:14:07.950 DEBUG (MainThread) [custom_components.elkbledom.elkbledom] Traceback (most recent call last):
File "/config/custom_components/elkbledom/elkbledom.py", line 279, in update
await self._ensure_connected()
File "/config/custom_components/elkbledom/elkbledom.py", line 341, in _ensure_connected
await client.start_notify(self._read_uuid, self._notification_handler)
File "/usr/local/lib/python3.10/site-packages/bleak/__init__.py", line 717, in start_notify
await self._backend.start_notify(characteristic, wrapped_callback, **kwargs)
File "/usr/local/lib/python3.10/site-packages/bleak/backends/bluezdbus/client.py", line 943, in start_notify
assert_reply(reply)
File "/usr/local/lib/python3.10/site-packages/bleak/backends/bluezdbus/utils.py", line 22, in assert_reply
raise BleakDBusError(reply.error_name, reply.body)
bleak.exc.BleakDBusError: [org.bluez.Error.Failed] Operation failed with ATT error: 0x0e (Unlikely Error)
2023-04-28 19:14:07.952 DEBUG (MainThread) [custom_components.elkbledom.elkbledom] MELK-OA10 : Disconnected from device in 120 seconds; RSSI: -83
2023-04-28 19:14:07.968 DEBUG (MainThread) [custom_components.elkbledom.elkbledom] 7e 00 04 f0 00 01 ff 00 ef
2023-04-28 19:14:07.983 DEBUG (MainThread) [custom_components.elkbledom.elkbledom] MELK-OA10 : <class 'bleak.exc.BleakDBusError'> error calling <function BLEDOMInstance.turn_on at 0x7f688eadd0>, backing off 0.25s, retrying (0/2)...
Traceback (most recent call last):
File "/config/custom_components/elkbledom/elkbledom.py", line 106, in _async_wrap_retry_bluetooth_connection_error
return await func(self, *args, **kwargs)
File "/config/custom_components/elkbledom/elkbledom.py", line 227, in turn_on
await self._write(self._turn_on_cmd)
File "/config/custom_components/elkbledom/elkbledom.py", line 166, in _write
await self._write_while_connected(data)
File "/config/custom_components/elkbledom/elkbledom.py", line 170, in _write_while_connected
await self._client.write_gatt_char(self._write_uuid, data, False)
File "/usr/local/lib/python3.10/site-packages/bleak/__init__.py", line 659, in write_gatt_char
await self._backend.write_gatt_char(char_specifier, data, response)
File "/usr/local/lib/python3.10/site-packages/bleak/backends/bluezdbus/client.py", line 859, in write_gatt_char
assert_reply(reply)
File "/usr/local/lib/python3.10/site-packages/bleak/backends/bluezdbus/utils.py", line 22, in assert_reply
raise BleakDBusError(reply.error_name, reply.body)
bleak.exc.BleakDBusError: [org.bluez.Error.Failed] Not connected
2023-04-28 19:14:08.236 DEBUG (MainThread) [custom_components.elkbledom.elkbledom] MELK-OA10 : Disconnected from device in 120 seconds; RSSI: -83
2023-04-28 19:14:08.237 DEBUG (MainThread) [custom_components.elkbledom.elkbledom] 7e 00 04 f0 00 01 ff 00 ef
2023-04-28 19:14:08.242 DEBUG (MainThread) [custom_components.elkbledom.elkbledom] MELK-OA10 : <class 'bleak.exc.BleakDBusError'> error calling <function BLEDOMInstance.turn_on at 0x7f688eadd0>, backing off 0.25s, retrying (1/2)...
Traceback (most recent call last):
File "/config/custom_components/elkbledom/elkbledom.py", line 106, in _async_wrap_retry_bluetooth_connection_error
return await func(self, *args, **kwargs)
File "/config/custom_components/elkbledom/elkbledom.py", line 227, in turn_on
await self._write(self._turn_on_cmd)
File "/config/custom_components/elkbledom/elkbledom.py", line 166, in _write
await self._write_while_connected(data)
File "/config/custom_components/elkbledom/elkbledom.py", line 170, in _write_while_connected
await self._client.write_gatt_char(self._write_uuid, data, False)
File "/usr/local/lib/python3.10/site-packages/bleak/__init__.py", line 659, in write_gatt_char
await self._backend.write_gatt_char(char_specifier, data, response)
File "/usr/local/lib/python3.10/site-packages/bleak/backends/bluezdbus/client.py", line 859, in write_gatt_char
assert_reply(reply)
File "/usr/local/lib/python3.10/site-packages/bleak/backends/bluezdbus/utils.py", line 22, in assert_reply
raise BleakDBusError(reply.error_name, reply.body)
bleak.exc.BleakDBusError: [org.bluez.Error.Failed] Not connected
2023-04-28 19:14:08.496 DEBUG (MainThread) [custom_components.elkbledom.elkbledom] MELK-OA10 : Disconnected from device in 120 seconds; RSSI: -83
2023-04-28 19:14:08.497 DEBUG (MainThread) [custom_components.elkbledom.elkbledom] 7e 00 04 f0 00 01 ff 00 ef
2023-04-28 19:14:08.502 DEBUG (MainThread) [custom_components.elkbledom.elkbledom] MELK-OA10 : <class 'bleak.exc.BleakDBusError'> error calling <function BLEDOMInstance.turn_on at 0x7f688eadd0>, reach max attempts (2/2)
Traceback (most recent call last):
File "/config/custom_components/elkbledom/elkbledom.py", line 106, in _async_wrap_retry_bluetooth_connection_error
return await func(self, *args, **kwargs)
File "/config/custom_components/elkbledom/elkbledom.py", line 227, in turn_on
await self._write(self._turn_on_cmd)
File "/config/custom_components/elkbledom/elkbledom.py", line 166, in _write
await self._write_while_connected(data)
File "/config/custom_components/elkbledom/elkbledom.py", line 170, in _write_while_connected
await self._client.write_gatt_char(self._write_uuid, data, False)
File "/usr/local/lib/python3.10/site-packages/bleak/__init__.py", line 659, in write_gatt_char
await self._backend.write_gatt_char(char_specifier, data, response)
File "/usr/local/lib/python3.10/site-packages/bleak/backends/bluezdbus/client.py", line 859, in write_gatt_char
assert_reply(reply)
File "/usr/local/lib/python3.10/site-packages/bleak/backends/bluezdbus/utils.py", line 22, in assert_reply
raise BleakDBusError(reply.error_name, reply.body)
bleak.exc.BleakDBusError: [org.bluez.Error.Failed] Not connected
2023-04-28 19:14:08.507 DEBUG (MainThread) [custom_components.elkbledom.elkbledom] MELK-OA10 : Stop
2023-04-28 19:14:08.515 ERROR (MainThread) [aiohttp.server] Error handling request
Traceback (most recent call last):
File "/usr/local/lib/python3.10/site-packages/aiohttp/web_protocol.py", line 433, in _handle_request
resp = await request_handler(request)
File "/usr/local/lib/python3.10/site-packages/aiohttp/web_app.py", line 504, in _handle
resp = await handler(request)
File "/usr/local/lib/python3.10/site-packages/aiohttp/web_middlewares.py", line 117, in impl
return await handler(request)
File "/usr/src/homeassistant/homeassistant/components/http/security_filter.py", line 85, in security_filter_middleware
return await handler(request)
File "/usr/src/homeassistant/homeassistant/components/http/forwarded.py", line 94, in forwarded_middleware
return await handler(request)
File "/usr/src/homeassistant/homeassistant/components/http/request_context.py", line 28, in request_context_middleware
return await handler(request)
File "/usr/src/homeassistant/homeassistant/components/http/ban.py", line 80, in ban_middleware
return await handler(request)
File "/usr/src/homeassistant/homeassistant/components/http/auth.py", line 235, in auth_middleware
return await handler(request)
File "/usr/src/homeassistant/homeassistant/components/http/view.py", line 146, in handle
result = await result
File "/usr/src/homeassistant/homeassistant/components/config/config_entries.py", line 180, in post
return await super().post(request, flow_id)
File "/usr/src/homeassistant/homeassistant/components/http/data_validator.py", line 72, in wrapper
result = await method(view, request, data, *args, **kwargs)
File "/usr/src/homeassistant/homeassistant/helpers/data_entry_flow.py", line 110, in post
result = await self._flow_mgr.async_configure(flow_id, data)
File "/usr/src/homeassistant/homeassistant/data_entry_flow.py", line 271, in async_configure
result = await self._async_handle_step(
File "/usr/src/homeassistant/homeassistant/data_entry_flow.py", line 367, in _async_handle_step
result: FlowResult = await getattr(flow, method)(user_input)
File "/config/custom_components/elkbledom/config_flow.py", line 96, in async_step_user
return await self.async_step_validate()
File "/config/custom_components/elkbledom/config_flow.py", line 137, in async_step_validate
error = await self.toggle_light()
File "/config/custom_components/elkbledom/config_flow.py", line 187, in toggle_light
await self._instance.stop()
File "/config/custom_components/elkbledom/elkbledom.py", line 397, in stop
await self._execute_disconnect()
File "/config/custom_components/elkbledom/elkbledom.py", line 418, in _execute_disconnect
await client.stop_notify(read_char)
File "/usr/local/lib/python3.10/site-packages/bleak/__init__.py", line 735, in stop_notify
await self._backend.stop_notify(char_specifier)
File "/usr/local/lib/python3.10/site-packages/bleak/backends/bluezdbus/client.py", line 975, in stop_notify
assert_reply(reply)
File "/usr/local/lib/python3.10/site-packages/bleak/backends/bluezdbus/utils.py", line 22, in assert_reply
raise BleakDBusError(reply.error_name, reply.body)
bleak.exc.BleakDBusError: [org.bluez.Error.Failed] No notify session started
2023-04-28 19:14:09.850 DEBUG (MainThread) [custom_components.elkbledom.elkbledom] MELK-OA10 : Disconnected from device; RSSI: -83

@dave-code-ruiz
Copy link
Owner

Ok, first, if you tested all the commands using gatttools and it works locally, please, send me how to with all commands you set in gatttool, it is very helpful for me. It is very difficult to develop code without having the led strip to test.

The error you post is in init command, it is the first led strip that needs a init command.

I created an error handler for the init command and change turn on command in elkbledom.py file, you need to do this to try it:

- replace your custom_components/elkbledom/elkbledom.py file with my file https://github.com/dave-code-ruiz/elkbledom/blob/main/custom_components/elkbledom/elkbledom.py
- go to "developer tools" - check configuration
- if "Configuration will not prevent Home Assistant from starting!" click restart and then "Restart Homeassistant"

When homeassistant restart you can test it, send me DEBUG log

@nikolmedo
Copy link

Running this sequence, I was able to turn off and turn on my light strip:

bash-5.1# gatttool -I
[                 ][LE]> connect be:16:a9:00:00:91
Attempting to connect to be:16:a9:00:00:91
Connection successful
[be:16:a9:00:00:91][LE]> primary
attr handle: 0x0001, end grp handle: 0x0003 uuid: 00001800-0000-1000-8000-00805f9b34fb
attr handle: 0x0004, end grp handle: 0x0009 uuid: 0000fff0-0000-1000-8000-00805f9b34fb
[be:16:a9:00:00:91][LE]> characteristics
handle: 0x0002, char properties: 0x12, char value handle: 0x0003, uuid: 00002a00-0000-1000-8000-00805f9b34fb
handle: 0x0005, char properties: 0x10, char value handle: 0x0006, uuid: 0000fff4-0000-1000-8000-00805f9b34fb
handle: 0x0008, char properties: 0x06, char value handle: 0x0009, uuid: 0000fff3-0000-1000-8000-00805f9b34fb
[be:16:a9:00:00:91][LE]> char-write-cmd 0x0009 7e0004000000ff00ef
[be:16:a9:00:00:91][LE]> char-write-cmd 0x0009 7e00040100000000ef
[be:16:a9:00:00:91][LE]> char-write-cmd 0x0009 7e000503ff000000ef
[be:16:a9:00:00:91][LE]> char-write-cmd 0x0009 7e0005030000ff00ef
[be:16:a9:00:00:91][LE]> char-write-cmd 0x0009 7e00050300ff0000ef
[be:16:a9:00:00:91][LE]> char-write-cmd 0x0009 7e0004000000ff00ef

Now, I'll update the file that you sent me and check the logs in HA to see what is failing.

Thanks for your help and support!

@nikolmedo
Copy link

I have two devices and I tried it on both, this is the log:

2023-05-03 13:35:44.851 DEBUG (MainThread) [custom_components.elkbledom.config_flow] Discovered bluetooth devices, step bluetooth, : BE:16:0D:00:02:04 , MELK-OA10   04
2023-05-03 13:35:44.852 DEBUG (MainThread) [custom_components.elkbledom.config_flow] Discovered bluetooth devices, step bluetooth confirm, : None
2023-05-03 13:35:44.862 DEBUG (MainThread) [custom_components.elkbledom.config_flow] Discovered supported devices: MELK-OA10   04 - BE:16:0D:00:02:04
2023-05-03 13:35:45.061 DEBUG (MainThread) [custom_components.elkbledom.config_flow] Discovered bluetooth devices, step bluetooth, : BE:16:A9:00:00:91 , MELK-OA10   91
2023-05-03 13:35:45.063 DEBUG (MainThread) [custom_components.elkbledom.config_flow] Discovered bluetooth devices, step bluetooth confirm, : None
2023-05-03 13:35:45.065 DEBUG (MainThread) [custom_components.elkbledom.config_flow] Discovered supported devices: MELK-OA10   91 - BE:16:A9:00:00:91
2023-05-03 13:36:31.083 DEBUG (MainThread) [custom_components.elkbledom.config_flow] Discovered supported devices: MELK-OA10   91 - BE:16:A9:00:00:91
2023-05-03 13:37:57.716 DEBUG (MainThread) [custom_components.elkbledom.elkbledom] Model information for device MELK-OA10   91 : ModelNo 2, Turn on cmd [126, 0, 4, 1, 0, 0, 0, 0, 239], Turn off cmd [126, 0, 4, 0, 0, 0, 255, 0, 239]
2023-05-03 13:37:57.730 DEBUG (MainThread) [custom_components.elkbledom.elkbledom] MELK-OA10   91: Connecting; RSSI: -77
2023-05-03 13:38:01.086 DEBUG (MainThread) [custom_components.elkbledom.config_flow] Discovered bluetooth devices, step bluetooth, : BE:16:A9:00:00:91 , MELK-OA10   91
2023-05-03 13:38:01.093 DEBUG (MainThread) [custom_components.elkbledom.elkbledom] MELK-OA10   91: Connected; RSSI: -77
2023-05-03 13:38:01.094 DEBUG (MainThread) [custom_components.elkbledom.elkbledom] MELK-OA10   91: Disconnected from device in 120 seconds; RSSI: -77
2023-05-03 13:38:01.095 DEBUG (MainThread) [custom_components.elkbledom.elkbledom] MELK-OA10   91: Subscribe to notifications; RSSI: -77
2023-05-03 13:38:31.117 ERROR (MainThread) [custom_components.elkbledom.elkbledom] Error getting status: [org.bluez.Error.Failed] Operation failed with ATT error: 0x0e (Unlikely Error)
2023-05-03 13:38:31.253 DEBUG (MainThread) [custom_components.elkbledom.elkbledom] Traceback (most recent call last):
  File "/config/custom_components/elkbledom/elkbledom.py", line 279, in update
    await self._ensure_connected()
  File "/config/custom_components/elkbledom/elkbledom.py", line 341, in _ensure_connected
    await client.start_notify(self._read_uuid, self._notification_handler)
  File "/usr/local/lib/python3.10/site-packages/bleak/__init__.py", line 717, in start_notify
    await self._backend.start_notify(characteristic, wrapped_callback, **kwargs)
  File "/usr/local/lib/python3.10/site-packages/bleak/backends/bluezdbus/client.py", line 943, in start_notify
    assert_reply(reply)
  File "/usr/local/lib/python3.10/site-packages/bleak/backends/bluezdbus/utils.py", line 22, in assert_reply
    raise BleakDBusError(reply.error_name, reply.body)
bleak.exc.BleakDBusError: [org.bluez.Error.Failed] Operation failed with ATT error: 0x0e (Unlikely Error)

2023-05-03 13:38:31.254 DEBUG (MainThread) [custom_components.elkbledom.elkbledom] MELK-OA10          : Disconnected from device in 120 seconds; RSSI: -77
2023-05-03 13:38:31.255 DEBUG (MainThread) [custom_components.elkbledom.elkbledom]  7e 00 04 01 00 00 00 00 ef
2023-05-03 13:38:31.269 DEBUG (MainThread) [custom_components.elkbledom.elkbledom] MELK-OA10          : <class 'bleak.exc.BleakDBusError'> error calling <function BLEDOMInstance.turn_on at 0x7f8b816950>, backing off 0.25s, retrying (0/2)...
Traceback (most recent call last):
  File "/config/custom_components/elkbledom/elkbledom.py", line 106, in _async_wrap_retry_bluetooth_connection_error
    return await func(self, *args, **kwargs)
  File "/config/custom_components/elkbledom/elkbledom.py", line 227, in turn_on
    await self._write(self._turn_on_cmd)
  File "/config/custom_components/elkbledom/elkbledom.py", line 166, in _write
    await self._write_while_connected(data)
  File "/config/custom_components/elkbledom/elkbledom.py", line 170, in _write_while_connected
    await self._client.write_gatt_char(self._write_uuid, data, False)
  File "/usr/local/lib/python3.10/site-packages/bleak/__init__.py", line 659, in write_gatt_char
    await self._backend.write_gatt_char(char_specifier, data, response)
  File "/usr/local/lib/python3.10/site-packages/bleak/backends/bluezdbus/client.py", line 859, in write_gatt_char
    assert_reply(reply)
  File "/usr/local/lib/python3.10/site-packages/bleak/backends/bluezdbus/utils.py", line 22, in assert_reply
    raise BleakDBusError(reply.error_name, reply.body)
bleak.exc.BleakDBusError: [org.bluez.Error.Failed] Not connected
2023-05-03 13:38:31.523 DEBUG (MainThread) [custom_components.elkbledom.elkbledom] MELK-OA10          : Disconnected from device in 120 seconds; RSSI: -77
2023-05-03 13:38:31.525 DEBUG (MainThread) [custom_components.elkbledom.elkbledom]  7e 00 04 01 00 00 00 00 ef
2023-05-03 13:38:31.534 DEBUG (MainThread) [custom_components.elkbledom.elkbledom] MELK-OA10          : <class 'bleak.exc.BleakDBusError'> error calling <function BLEDOMInstance.turn_on at 0x7f8b816950>, backing off 0.25s, retrying (1/2)...
Traceback (most recent call last):
  File "/config/custom_components/elkbledom/elkbledom.py", line 106, in _async_wrap_retry_bluetooth_connection_error
    return await func(self, *args, **kwargs)
  File "/config/custom_components/elkbledom/elkbledom.py", line 227, in turn_on
    await self._write(self._turn_on_cmd)
  File "/config/custom_components/elkbledom/elkbledom.py", line 166, in _write
    await self._write_while_connected(data)
  File "/config/custom_components/elkbledom/elkbledom.py", line 170, in _write_while_connected
    await self._client.write_gatt_char(self._write_uuid, data, False)
  File "/usr/local/lib/python3.10/site-packages/bleak/__init__.py", line 659, in write_gatt_char
    await self._backend.write_gatt_char(char_specifier, data, response)
  File "/usr/local/lib/python3.10/site-packages/bleak/backends/bluezdbus/client.py", line 859, in write_gatt_char
    assert_reply(reply)
  File "/usr/local/lib/python3.10/site-packages/bleak/backends/bluezdbus/utils.py", line 22, in assert_reply
    raise BleakDBusError(reply.error_name, reply.body)
bleak.exc.BleakDBusError: [org.bluez.Error.Failed] Not connected
2023-05-03 13:38:31.787 DEBUG (MainThread) [custom_components.elkbledom.elkbledom] MELK-OA10          : Disconnected from device in 120 seconds; RSSI: -77
2023-05-03 13:38:31.788 DEBUG (MainThread) [custom_components.elkbledom.elkbledom]  7e 00 04 01 00 00 00 00 ef
2023-05-03 13:38:31.795 DEBUG (MainThread) [custom_components.elkbledom.elkbledom] MELK-OA10          : <class 'bleak.exc.BleakDBusError'> error calling <function BLEDOMInstance.turn_on at 0x7f8b816950>, reach max attempts (2/2)
Traceback (most recent call last):
  File "/config/custom_components/elkbledom/elkbledom.py", line 106, in _async_wrap_retry_bluetooth_connection_error
    return await func(self, *args, **kwargs)
  File "/config/custom_components/elkbledom/elkbledom.py", line 227, in turn_on
    await self._write(self._turn_on_cmd)
  File "/config/custom_components/elkbledom/elkbledom.py", line 166, in _write
    await self._write_while_connected(data)
  File "/config/custom_components/elkbledom/elkbledom.py", line 170, in _write_while_connected
    await self._client.write_gatt_char(self._write_uuid, data, False)
  File "/usr/local/lib/python3.10/site-packages/bleak/__init__.py", line 659, in write_gatt_char
    await self._backend.write_gatt_char(char_specifier, data, response)
  File "/usr/local/lib/python3.10/site-packages/bleak/backends/bluezdbus/client.py", line 859, in write_gatt_char
    assert_reply(reply)
  File "/usr/local/lib/python3.10/site-packages/bleak/backends/bluezdbus/utils.py", line 22, in assert_reply
    raise BleakDBusError(reply.error_name, reply.body)
bleak.exc.BleakDBusError: [org.bluez.Error.Failed] Not connected
2023-05-03 13:38:31.797 DEBUG (MainThread) [custom_components.elkbledom.elkbledom] MELK-OA10          : Stop
2023-05-03 13:38:31.804 ERROR (MainThread) [aiohttp.server] Error handling request
Traceback (most recent call last):
  File "/usr/local/lib/python3.10/site-packages/aiohttp/web_protocol.py", line 433, in _handle_request
    resp = await request_handler(request)
  File "/usr/local/lib/python3.10/site-packages/aiohttp/web_app.py", line 504, in _handle
    resp = await handler(request)
  File "/usr/local/lib/python3.10/site-packages/aiohttp/web_middlewares.py", line 117, in impl
    return await handler(request)
  File "/usr/src/homeassistant/homeassistant/components/http/security_filter.py", line 85, in security_filter_middleware
    return await handler(request)
  File "/usr/src/homeassistant/homeassistant/components/http/forwarded.py", line 94, in forwarded_middleware
    return await handler(request)
  File "/usr/src/homeassistant/homeassistant/components/http/request_context.py", line 28, in request_context_middleware
    return await handler(request)
  File "/usr/src/homeassistant/homeassistant/components/http/ban.py", line 80, in ban_middleware
    return await handler(request)
  File "/usr/src/homeassistant/homeassistant/components/http/auth.py", line 235, in auth_middleware
    return await handler(request)
  File "/usr/src/homeassistant/homeassistant/components/http/view.py", line 146, in handle
    result = await result
  File "/usr/src/homeassistant/homeassistant/components/config/config_entries.py", line 180, in post
    return await super().post(request, flow_id)
  File "/usr/src/homeassistant/homeassistant/components/http/data_validator.py", line 72, in wrapper
    result = await method(view, request, data, *args, **kwargs)
  File "/usr/src/homeassistant/homeassistant/helpers/data_entry_flow.py", line 110, in post
    result = await self._flow_mgr.async_configure(flow_id, data)
  File "/usr/src/homeassistant/homeassistant/data_entry_flow.py", line 271, in async_configure
    result = await self._async_handle_step(
  File "/usr/src/homeassistant/homeassistant/data_entry_flow.py", line 367, in _async_handle_step
    result: FlowResult = await getattr(flow, method)(user_input)
  File "/config/custom_components/elkbledom/config_flow.py", line 96, in async_step_user
    return await self.async_step_validate()
  File "/config/custom_components/elkbledom/config_flow.py", line 137, in async_step_validate
    error = await self.toggle_light()
  File "/config/custom_components/elkbledom/config_flow.py", line 187, in toggle_light
    await self._instance.stop()
  File "/config/custom_components/elkbledom/elkbledom.py", line 405, in stop
    await self._execute_disconnect()
  File "/config/custom_components/elkbledom/elkbledom.py", line 426, in _execute_disconnect
    await client.stop_notify(read_char)
  File "/usr/local/lib/python3.10/site-packages/bleak/__init__.py", line 735, in stop_notify
    await self._backend.stop_notify(char_specifier)
  File "/usr/local/lib/python3.10/site-packages/bleak/backends/bluezdbus/client.py", line 975, in stop_notify
    assert_reply(reply)
  File "/usr/local/lib/python3.10/site-packages/bleak/backends/bluezdbus/utils.py", line 22, in assert_reply
    raise BleakDBusError(reply.error_name, reply.body)
bleak.exc.BleakDBusError: [org.bluez.Error.Failed] No notify session started
2023-05-03 13:38:33.290 DEBUG (MainThread) [custom_components.elkbledom.elkbledom] MELK-OA10          : Disconnected from device; RSSI: -77
2023-05-03 13:39:04.133 DEBUG (MainThread) [custom_components.elkbledom.elkbledom] MELK-OA10   91: Connecting; RSSI: -84
2023-05-03 13:39:04.968 DEBUG (MainThread) [custom_components.elkbledom.elkbledom] MELK-OA10   91: Connected; RSSI: -84
2023-05-03 13:39:04.970 DEBUG (MainThread) [custom_components.elkbledom.elkbledom] MELK-OA10   91: Disconnected from device in 120 seconds; RSSI: -84
2023-05-03 13:39:04.970 DEBUG (MainThread) [custom_components.elkbledom.elkbledom] MELK-OA10   91: Subscribe to notifications; RSSI: -84
2023-05-03 13:39:35.165 ERROR (MainThread) [custom_components.elkbledom.elkbledom] Error getting status: [org.bluez.Error.Failed] Operation failed with ATT error: 0x0e (Unlikely Error)
2023-05-03 13:39:35.175 DEBUG (MainThread) [custom_components.elkbledom.elkbledom] Traceback (most recent call last):
  File "/config/custom_components/elkbledom/elkbledom.py", line 279, in update
    await self._ensure_connected()
  File "/config/custom_components/elkbledom/elkbledom.py", line 341, in _ensure_connected
    await client.start_notify(self._read_uuid, self._notification_handler)
  File "/usr/local/lib/python3.10/site-packages/bleak/__init__.py", line 717, in start_notify
    await self._backend.start_notify(characteristic, wrapped_callback, **kwargs)
  File "/usr/local/lib/python3.10/site-packages/bleak/backends/bluezdbus/client.py", line 943, in start_notify
    assert_reply(reply)
  File "/usr/local/lib/python3.10/site-packages/bleak/backends/bluezdbus/utils.py", line 22, in assert_reply
    raise BleakDBusError(reply.error_name, reply.body)
bleak.exc.BleakDBusError: [org.bluez.Error.Failed] Operation failed with ATT error: 0x0e (Unlikely Error)

2023-05-03 13:39:35.176 DEBUG (MainThread) [custom_components.elkbledom.elkbledom] MELK-OA10          : Disconnected from device in 120 seconds; RSSI: -84
2023-05-03 13:39:35.176 DEBUG (MainThread) [custom_components.elkbledom.elkbledom]  7e 00 04 01 00 00 00 00 ef
2023-05-03 13:39:35.202 DEBUG (MainThread) [custom_components.elkbledom.elkbledom] MELK-OA10          : <class 'bleak.exc.BleakDBusError'> error calling <function BLEDOMInstance.turn_on at 0x7f8b816950>, backing off 0.25s, retrying (0/2)...
Traceback (most recent call last):
  File "/config/custom_components/elkbledom/elkbledom.py", line 106, in _async_wrap_retry_bluetooth_connection_error
    return await func(self, *args, **kwargs)
  File "/config/custom_components/elkbledom/elkbledom.py", line 227, in turn_on
    await self._write(self._turn_on_cmd)
  File "/config/custom_components/elkbledom/elkbledom.py", line 166, in _write
    await self._write_while_connected(data)
  File "/config/custom_components/elkbledom/elkbledom.py", line 170, in _write_while_connected
    await self._client.write_gatt_char(self._write_uuid, data, False)
  File "/usr/local/lib/python3.10/site-packages/bleak/__init__.py", line 659, in write_gatt_char
    await self._backend.write_gatt_char(char_specifier, data, response)
  File "/usr/local/lib/python3.10/site-packages/bleak/backends/bluezdbus/client.py", line 859, in write_gatt_char
    assert_reply(reply)
  File "/usr/local/lib/python3.10/site-packages/bleak/backends/bluezdbus/utils.py", line 22, in assert_reply
    raise BleakDBusError(reply.error_name, reply.body)
bleak.exc.BleakDBusError: [org.bluez.Error.Failed] Not connected
2023-05-03 13:39:35.457 DEBUG (MainThread) [custom_components.elkbledom.elkbledom] MELK-OA10          : Disconnected from device in 120 seconds; RSSI: -84
2023-05-03 13:39:35.458 DEBUG (MainThread) [custom_components.elkbledom.elkbledom]  7e 00 04 01 00 00 00 00 ef
2023-05-03 13:39:35.466 DEBUG (MainThread) [custom_components.elkbledom.elkbledom] MELK-OA10          : <class 'bleak.exc.BleakDBusError'> error calling <function BLEDOMInstance.turn_on at 0x7f8b816950>, backing off 0.25s, retrying (1/2)...
Traceback (most recent call last):
  File "/config/custom_components/elkbledom/elkbledom.py", line 106, in _async_wrap_retry_bluetooth_connection_error
    return await func(self, *args, **kwargs)
  File "/config/custom_components/elkbledom/elkbledom.py", line 227, in turn_on
    await self._write(self._turn_on_cmd)
  File "/config/custom_components/elkbledom/elkbledom.py", line 166, in _write
    await self._write_while_connected(data)
  File "/config/custom_components/elkbledom/elkbledom.py", line 170, in _write_while_connected
    await self._client.write_gatt_char(self._write_uuid, data, False)
  File "/usr/local/lib/python3.10/site-packages/bleak/__init__.py", line 659, in write_gatt_char
    await self._backend.write_gatt_char(char_specifier, data, response)
  File "/usr/local/lib/python3.10/site-packages/bleak/backends/bluezdbus/client.py", line 859, in write_gatt_char
    assert_reply(reply)
  File "/usr/local/lib/python3.10/site-packages/bleak/backends/bluezdbus/utils.py", line 22, in assert_reply
    raise BleakDBusError(reply.error_name, reply.body)
bleak.exc.BleakDBusError: [org.bluez.Error.Failed] Not connected
2023-05-03 13:39:35.721 DEBUG (MainThread) [custom_components.elkbledom.elkbledom] MELK-OA10          : Disconnected from device in 120 seconds; RSSI: -84
2023-05-03 13:39:35.722 DEBUG (MainThread) [custom_components.elkbledom.elkbledom]  7e 00 04 01 00 00 00 00 ef
2023-05-03 13:39:35.729 DEBUG (MainThread) [custom_components.elkbledom.elkbledom] MELK-OA10          : <class 'bleak.exc.BleakDBusError'> error calling <function BLEDOMInstance.turn_on at 0x7f8b816950>, reach max attempts (2/2)
Traceback (most recent call last):
  File "/config/custom_components/elkbledom/elkbledom.py", line 106, in _async_wrap_retry_bluetooth_connection_error
    return await func(self, *args, **kwargs)
  File "/config/custom_components/elkbledom/elkbledom.py", line 227, in turn_on
    await self._write(self._turn_on_cmd)
  File "/config/custom_components/elkbledom/elkbledom.py", line 166, in _write
    await self._write_while_connected(data)
  File "/config/custom_components/elkbledom/elkbledom.py", line 170, in _write_while_connected
    await self._client.write_gatt_char(self._write_uuid, data, False)
  File "/usr/local/lib/python3.10/site-packages/bleak/__init__.py", line 659, in write_gatt_char
    await self._backend.write_gatt_char(char_specifier, data, response)
  File "/usr/local/lib/python3.10/site-packages/bleak/backends/bluezdbus/client.py", line 859, in write_gatt_char
    assert_reply(reply)
  File "/usr/local/lib/python3.10/site-packages/bleak/backends/bluezdbus/utils.py", line 22, in assert_reply
    raise BleakDBusError(reply.error_name, reply.body)
bleak.exc.BleakDBusError: [org.bluez.Error.Failed] Not connected
2023-05-03 13:39:35.731 DEBUG (MainThread) [custom_components.elkbledom.elkbledom] MELK-OA10          : Stop
2023-05-03 13:39:35.739 ERROR (MainThread) [aiohttp.server] Error handling request
Traceback (most recent call last):
  File "/usr/local/lib/python3.10/site-packages/aiohttp/web_protocol.py", line 433, in _handle_request
    resp = await request_handler(request)
  File "/usr/local/lib/python3.10/site-packages/aiohttp/web_app.py", line 504, in _handle
    resp = await handler(request)
  File "/usr/local/lib/python3.10/site-packages/aiohttp/web_middlewares.py", line 117, in impl
    return await handler(request)
  File "/usr/src/homeassistant/homeassistant/components/http/security_filter.py", line 85, in security_filter_middleware
    return await handler(request)
  File "/usr/src/homeassistant/homeassistant/components/http/forwarded.py", line 94, in forwarded_middleware
    return await handler(request)
  File "/usr/src/homeassistant/homeassistant/components/http/request_context.py", line 28, in request_context_middleware
    return await handler(request)
  File "/usr/src/homeassistant/homeassistant/components/http/ban.py", line 80, in ban_middleware
    return await handler(request)
  File "/usr/src/homeassistant/homeassistant/components/http/auth.py", line 235, in auth_middleware
    return await handler(request)
  File "/usr/src/homeassistant/homeassistant/components/http/view.py", line 146, in handle
    result = await result
  File "/usr/src/homeassistant/homeassistant/components/config/config_entries.py", line 180, in post
    return await super().post(request, flow_id)
  File "/usr/src/homeassistant/homeassistant/components/http/data_validator.py", line 72, in wrapper
    result = await method(view, request, data, *args, **kwargs)
  File "/usr/src/homeassistant/homeassistant/helpers/data_entry_flow.py", line 110, in post
    result = await self._flow_mgr.async_configure(flow_id, data)
  File "/usr/src/homeassistant/homeassistant/data_entry_flow.py", line 271, in async_configure
    result = await self._async_handle_step(
  File "/usr/src/homeassistant/homeassistant/data_entry_flow.py", line 367, in _async_handle_step
    result: FlowResult = await getattr(flow, method)(user_input)
  File "/config/custom_components/elkbledom/config_flow.py", line 96, in async_step_user
    return await self.async_step_validate()
  File "/config/custom_components/elkbledom/config_flow.py", line 137, in async_step_validate
    error = await self.toggle_light()
  File "/config/custom_components/elkbledom/config_flow.py", line 187, in toggle_light
    await self._instance.stop()
  File "/config/custom_components/elkbledom/elkbledom.py", line 405, in stop
    await self._execute_disconnect()
  File "/config/custom_components/elkbledom/elkbledom.py", line 426, in _execute_disconnect
    await client.stop_notify(read_char)
  File "/usr/local/lib/python3.10/site-packages/bleak/__init__.py", line 735, in stop_notify
    await self._backend.stop_notify(char_specifier)
  File "/usr/local/lib/python3.10/site-packages/bleak/backends/bluezdbus/client.py", line 975, in stop_notify
    assert_reply(reply)
  File "/usr/local/lib/python3.10/site-packages/bleak/backends/bluezdbus/utils.py", line 22, in assert_reply
    raise BleakDBusError(reply.error_name, reply.body)
bleak.exc.BleakDBusError: [org.bluez.Error.Failed] No notify session started
2023-05-03 13:39:37.221 DEBUG (MainThread) [custom_components.elkbledom.elkbledom] MELK-OA10          : Disconnected from device; RSSI: -84

@dave-code-ruiz
Copy link
Owner

Ok, I see you have a problem with start_notify i now not call it, not is needed, you need to do this to try it:

- replace your custom_components/elkbledom/elkbledom.py file with my file https://github.com/dave-code-ruiz/elkbledom/blob/main/custom_components/elkbledom/elkbledom.py
- go to "developer tools" - check configuration
- if "Configuration will not prevent Home Assistant from starting!" click restart and then "Restart Homeassistant"

When homeassistant restart you can test it, send me DEBUG log

@nikolmedo
Copy link

This is the new log:


2023-05-03 23:55:52.651 DEBUG (MainThread) [custom_components.elkbledom.config_flow] Discovered bluetooth devices, step bluetooth, : BE:16:0D:00:02:04 , MELK-OA10   04
2023-05-03 23:55:52.652 DEBUG (MainThread) [custom_components.elkbledom.config_flow] Discovered bluetooth devices, step bluetooth confirm, : None
2023-05-03 23:55:52.659 DEBUG (MainThread) [custom_components.elkbledom.config_flow] Discovered supported devices: MELK-OA10   04 - BE:16:0D:00:02:04
2023-05-03 23:55:52.672 DEBUG (MainThread) [custom_components.elkbledom.config_flow] Discovered bluetooth devices, step bluetooth, : BE:16:A9:00:00:91 , MELK-OA10   91
2023-05-03 23:55:52.672 DEBUG (MainThread) [custom_components.elkbledom.config_flow] Discovered bluetooth devices, step bluetooth confirm, : None
2023-05-03 23:55:52.675 DEBUG (MainThread) [custom_components.elkbledom.config_flow] Discovered supported devices: MELK-OA10   91 - BE:16:A9:00:00:91
2023-05-03 23:56:15.621 DEBUG (MainThread) [custom_components.elkbledom.elkbledom] Model information for device MELK-OA10   91 : ModelNo 2, Turn on cmd [126, 0, 4, 1, 0, 0, 0, 0, 239], Turn off cmd [126, 0, 4, 0, 0, 0, 255, 0, 239]
2023-05-03 23:56:15.665 DEBUG (MainThread) [custom_components.elkbledom.elkbledom] MELK-OA10   91: Connecting; RSSI: -80
2023-05-03 23:56:19.804 DEBUG (MainThread) [custom_components.elkbledom.config_flow] Discovered bluetooth devices, step bluetooth, : BE:16:A9:00:00:91 , MELK-OA10   91
2023-05-03 23:56:19.829 DEBUG (MainThread) [custom_components.elkbledom.elkbledom] MELK-OA10   91: Connected; RSSI: -80
2023-05-03 23:56:19.830 DEBUG (MainThread) [custom_components.elkbledom.elkbledom] MELK-OA10   91: Disconnected from device in 120 seconds; RSSI: -80
2023-05-03 23:56:19.830 DEBUG (MainThread) [custom_components.elkbledom.elkbledom] MELK-OA10   91: Subscribe to notifications; RSSI: -80
2023-05-03 23:56:50.040 ERROR (MainThread) [custom_components.elkbledom.elkbledom] Error getting status: [org.bluez.Error.Failed] Operation failed with ATT error: 0x0e (Unlikely Error)
2023-05-03 23:56:50.421 DEBUG (MainThread) [custom_components.elkbledom.elkbledom] Traceback (most recent call last):
  File "/config/custom_components/elkbledom/elkbledom.py", line 279, in update
    await self._ensure_connected()
  File "/config/custom_components/elkbledom/elkbledom.py", line 342, in _ensure_connected
    await client.start_notify(self._read_uuid, self._notification_handler)
  File "/usr/local/lib/python3.10/site-packages/bleak/__init__.py", line 717, in start_notify
    await self._backend.start_notify(characteristic, wrapped_callback, **kwargs)
  File "/usr/local/lib/python3.10/site-packages/bleak/backends/bluezdbus/client.py", line 1003, in start_notify
    assert_reply(reply)
  File "/usr/local/lib/python3.10/site-packages/bleak/backends/bluezdbus/utils.py", line 22, in assert_reply
    raise BleakDBusError(reply.error_name, reply.body)
bleak.exc.BleakDBusError: [org.bluez.Error.Failed] Operation failed with ATT error: 0x0e (Unlikely Error)

2023-05-03 23:56:50.423 DEBUG (MainThread) [custom_components.elkbledom.elkbledom] MELK-OA10          : Disconnected from device in 120 seconds; RSSI: -80
2023-05-03 23:56:50.424 DEBUG (MainThread) [custom_components.elkbledom.elkbledom]  7e 00 04 01 00 00 00 00 ef
2023-05-03 23:56:50.448 DEBUG (MainThread) [custom_components.elkbledom.elkbledom] MELK-OA10          : <class 'bleak.exc.BleakDBusError'> error calling <function BLEDOMInstance.turn_on at 0x7f5dd03b50>, backing off 0.25s, retrying (0/2)...
Traceback (most recent call last):
  File "/config/custom_components/elkbledom/elkbledom.py", line 106, in _async_wrap_retry_bluetooth_connection_error
    return await func(self, *args, **kwargs)
  File "/config/custom_components/elkbledom/elkbledom.py", line 227, in turn_on
    await self._write(self._turn_on_cmd)
  File "/config/custom_components/elkbledom/elkbledom.py", line 166, in _write
    await self._write_while_connected(data)
  File "/config/custom_components/elkbledom/elkbledom.py", line 170, in _write_while_connected
    await self._client.write_gatt_char(self._write_uuid, data, False)
  File "/usr/local/lib/python3.10/site-packages/bleak/__init__.py", line 659, in write_gatt_char
    await self._backend.write_gatt_char(char_specifier, data, response)
  File "/usr/local/lib/python3.10/site-packages/bleak/backends/bluezdbus/client.py", line 905, in write_gatt_char
    assert_reply(reply)
  File "/usr/local/lib/python3.10/site-packages/bleak/backends/bluezdbus/utils.py", line 22, in assert_reply
    raise BleakDBusError(reply.error_name, reply.body)
bleak.exc.BleakDBusError: [org.bluez.Error.Failed] Not connected
2023-05-03 23:56:50.702 DEBUG (MainThread) [custom_components.elkbledom.elkbledom] MELK-OA10          : Disconnected from device in 120 seconds; RSSI: -80
2023-05-03 23:56:50.702 DEBUG (MainThread) [custom_components.elkbledom.elkbledom]  7e 00 04 01 00 00 00 00 ef
2023-05-03 23:56:50.800 DEBUG (MainThread) [custom_components.elkbledom.elkbledom] MELK-OA10          : <class 'bleak.exc.BleakDBusError'> error calling <function BLEDOMInstance.turn_on at 0x7f5dd03b50>, backing off 0.25s, retrying (1/2)...
Traceback (most recent call last):
  File "/config/custom_components/elkbledom/elkbledom.py", line 106, in _async_wrap_retry_bluetooth_connection_error
    return await func(self, *args, **kwargs)
  File "/config/custom_components/elkbledom/elkbledom.py", line 227, in turn_on
    await self._write(self._turn_on_cmd)
  File "/config/custom_components/elkbledom/elkbledom.py", line 166, in _write
    await self._write_while_connected(data)
  File "/config/custom_components/elkbledom/elkbledom.py", line 170, in _write_while_connected
    await self._client.write_gatt_char(self._write_uuid, data, False)
  File "/usr/local/lib/python3.10/site-packages/bleak/__init__.py", line 659, in write_gatt_char
    await self._backend.write_gatt_char(char_specifier, data, response)
  File "/usr/local/lib/python3.10/site-packages/bleak/backends/bluezdbus/client.py", line 905, in write_gatt_char
    assert_reply(reply)
  File "/usr/local/lib/python3.10/site-packages/bleak/backends/bluezdbus/utils.py", line 22, in assert_reply
    raise BleakDBusError(reply.error_name, reply.body)
bleak.exc.BleakDBusError: [org.bluez.Error.Failed] Not connected
2023-05-03 23:56:51.054 DEBUG (MainThread) [custom_components.elkbledom.elkbledom] MELK-OA10          : Disconnected from device in 120 seconds; RSSI: -80
2023-05-03 23:56:51.055 DEBUG (MainThread) [custom_components.elkbledom.elkbledom]  7e 00 04 01 00 00 00 00 ef
2023-05-03 23:56:51.068 DEBUG (MainThread) [custom_components.elkbledom.elkbledom] MELK-OA10          : <class 'bleak.exc.BleakDBusError'> error calling <function BLEDOMInstance.turn_on at 0x7f5dd03b50>, reach max attempts (2/2)
Traceback (most recent call last):
  File "/config/custom_components/elkbledom/elkbledom.py", line 106, in _async_wrap_retry_bluetooth_connection_error
    return await func(self, *args, **kwargs)
  File "/config/custom_components/elkbledom/elkbledom.py", line 227, in turn_on
    await self._write(self._turn_on_cmd)
  File "/config/custom_components/elkbledom/elkbledom.py", line 166, in _write
    await self._write_while_connected(data)
  File "/config/custom_components/elkbledom/elkbledom.py", line 170, in _write_while_connected
    await self._client.write_gatt_char(self._write_uuid, data, False)
  File "/usr/local/lib/python3.10/site-packages/bleak/__init__.py", line 659, in write_gatt_char
    await self._backend.write_gatt_char(char_specifier, data, response)
  File "/usr/local/lib/python3.10/site-packages/bleak/backends/bluezdbus/client.py", line 905, in write_gatt_char
    assert_reply(reply)
  File "/usr/local/lib/python3.10/site-packages/bleak/backends/bluezdbus/utils.py", line 22, in assert_reply
    raise BleakDBusError(reply.error_name, reply.body)
bleak.exc.BleakDBusError: [org.bluez.Error.Failed] Not connected
2023-05-03 23:56:51.073 DEBUG (MainThread) [custom_components.elkbledom.elkbledom] MELK-OA10          : Stop
2023-05-03 23:56:51.088 ERROR (MainThread) [aiohttp.server] Error handling request
Traceback (most recent call last):
  File "/usr/local/lib/python3.10/site-packages/aiohttp/web_protocol.py", line 433, in _handle_request
    resp = await request_handler(request)
  File "/usr/local/lib/python3.10/site-packages/aiohttp/web_app.py", line 504, in _handle
    resp = await handler(request)
  File "/usr/local/lib/python3.10/site-packages/aiohttp/web_middlewares.py", line 117, in impl
    return await handler(request)
  File "/usr/src/homeassistant/homeassistant/components/http/security_filter.py", line 85, in security_filter_middleware
    return await handler(request)
  File "/usr/src/homeassistant/homeassistant/components/http/forwarded.py", line 100, in forwarded_middleware
    return await handler(request)
  File "/usr/src/homeassistant/homeassistant/components/http/request_context.py", line 28, in request_context_middleware
    return await handler(request)
  File "/usr/src/homeassistant/homeassistant/components/http/ban.py", line 80, in ban_middleware
    return await handler(request)
  File "/usr/src/homeassistant/homeassistant/components/http/auth.py", line 235, in auth_middleware
    return await handler(request)
  File "/usr/src/homeassistant/homeassistant/components/http/view.py", line 146, in handle
    result = await result
  File "/usr/src/homeassistant/homeassistant/components/config/config_entries.py", line 180, in post
    return await super().post(request, flow_id)
  File "/usr/src/homeassistant/homeassistant/components/http/data_validator.py", line 72, in wrapper
    result = await method(view, request, data, *args, **kwargs)
  File "/usr/src/homeassistant/homeassistant/helpers/data_entry_flow.py", line 110, in post
    result = await self._flow_mgr.async_configure(flow_id, data)
  File "/usr/src/homeassistant/homeassistant/data_entry_flow.py", line 271, in async_configure
    result = await self._async_handle_step(
  File "/usr/src/homeassistant/homeassistant/data_entry_flow.py", line 367, in _async_handle_step
    result: FlowResult = await getattr(flow, method)(user_input)
  File "/config/custom_components/elkbledom/config_flow.py", line 96, in async_step_user
    return await self.async_step_validate()
  File "/config/custom_components/elkbledom/config_flow.py", line 137, in async_step_validate
    error = await self.toggle_light()
  File "/config/custom_components/elkbledom/config_flow.py", line 187, in toggle_light
    await self._instance.stop()
  File "/config/custom_components/elkbledom/elkbledom.py", line 387, in stop
    await self._execute_disconnect()
  File "/config/custom_components/elkbledom/elkbledom.py", line 408, in _execute_disconnect
    await client.stop_notify(read_char)
  File "/usr/local/lib/python3.10/site-packages/bleak/__init__.py", line 735, in stop_notify
    await self._backend.stop_notify(char_specifier)
  File "/usr/local/lib/python3.10/site-packages/bleak/backends/bluezdbus/client.py", line 1035, in stop_notify
    assert_reply(reply)
  File "/usr/local/lib/python3.10/site-packages/bleak/backends/bluezdbus/utils.py", line 22, in assert_reply
    raise BleakDBusError(reply.error_name, reply.body)
bleak.exc.BleakDBusError: [org.bluez.Error.Failed] No notify session started
2023-05-03 23:56:53.098 DEBUG (MainThread) [custom_components.elkbledom.elkbledom] MELK-OA10          : Disconnected from device; RSSI: -80
2023-05-03 23:57:18.760 DEBUG (MainThread) [custom_components.elkbledom.elkbledom] MELK-OA10   91: Connecting; RSSI: -79
2023-05-03 23:57:20.618 DEBUG (MainThread) [custom_components.elkbledom.elkbledom] MELK-OA10   91: Connected; RSSI: -79
2023-05-03 23:57:20.620 DEBUG (MainThread) [custom_components.elkbledom.elkbledom] MELK-OA10   91: Disconnected from device in 120 seconds; RSSI: -79
2023-05-03 23:57:20.621 DEBUG (MainThread) [custom_components.elkbledom.elkbledom] MELK-OA10   91: Subscribe to notifications; RSSI: -79
2023-05-03 23:57:50.811 ERROR (MainThread) [custom_components.elkbledom.elkbledom] Error getting status: [org.bluez.Error.Failed] Operation failed with ATT error: 0x0e (Unlikely Error)
2023-05-03 23:57:50.888 DEBUG (MainThread) [custom_components.elkbledom.elkbledom] Traceback (most recent call last):
  File "/config/custom_components/elkbledom/elkbledom.py", line 279, in update
    await self._ensure_connected()
  File "/config/custom_components/elkbledom/elkbledom.py", line 342, in _ensure_connected
    await client.start_notify(self._read_uuid, self._notification_handler)
  File "/usr/local/lib/python3.10/site-packages/bleak/__init__.py", line 717, in start_notify
    await self._backend.start_notify(characteristic, wrapped_callback, **kwargs)
  File "/usr/local/lib/python3.10/site-packages/bleak/backends/bluezdbus/client.py", line 1003, in start_notify
    assert_reply(reply)
  File "/usr/local/lib/python3.10/site-packages/bleak/backends/bluezdbus/utils.py", line 22, in assert_reply
    raise BleakDBusError(reply.error_name, reply.body)
bleak.exc.BleakDBusError: [org.bluez.Error.Failed] Operation failed with ATT error: 0x0e (Unlikely Error)

2023-05-03 23:57:50.889 DEBUG (MainThread) [custom_components.elkbledom.elkbledom] MELK-OA10          : Disconnected from device in 120 seconds; RSSI: -79
2023-05-03 23:57:50.890 DEBUG (MainThread) [custom_components.elkbledom.elkbledom]  7e 00 04 01 00 00 00 00 ef
2023-05-03 23:57:50.897 DEBUG (MainThread) [custom_components.elkbledom.elkbledom] MELK-OA10          : <class 'bleak.exc.BleakDBusError'> error calling <function BLEDOMInstance.turn_on at 0x7f5dd03b50>, backing off 0.25s, retrying (0/2)...
Traceback (most recent call last):
  File "/config/custom_components/elkbledom/elkbledom.py", line 106, in _async_wrap_retry_bluetooth_connection_error
    return await func(self, *args, **kwargs)
  File "/config/custom_components/elkbledom/elkbledom.py", line 227, in turn_on
    await self._write(self._turn_on_cmd)
  File "/config/custom_components/elkbledom/elkbledom.py", line 166, in _write
    await self._write_while_connected(data)
  File "/config/custom_components/elkbledom/elkbledom.py", line 170, in _write_while_connected
    await self._client.write_gatt_char(self._write_uuid, data, False)
  File "/usr/local/lib/python3.10/site-packages/bleak/__init__.py", line 659, in write_gatt_char
    await self._backend.write_gatt_char(char_specifier, data, response)
  File "/usr/local/lib/python3.10/site-packages/bleak/backends/bluezdbus/client.py", line 905, in write_gatt_char
    assert_reply(reply)
  File "/usr/local/lib/python3.10/site-packages/bleak/backends/bluezdbus/utils.py", line 22, in assert_reply
    raise BleakDBusError(reply.error_name, reply.body)
bleak.exc.BleakDBusError: [org.bluez.Error.Failed] Not connected
2023-05-03 23:57:51.152 DEBUG (MainThread) [custom_components.elkbledom.elkbledom] MELK-OA10          : Disconnected from device in 120 seconds; RSSI: -79
2023-05-03 23:57:51.153 DEBUG (MainThread) [custom_components.elkbledom.elkbledom]  7e 00 04 01 00 00 00 00 ef
2023-05-03 23:57:51.161 DEBUG (MainThread) [custom_components.elkbledom.elkbledom] MELK-OA10          : <class 'bleak.exc.BleakDBusError'> error calling <function BLEDOMInstance.turn_on at 0x7f5dd03b50>, backing off 0.25s, retrying (1/2)...
Traceback (most recent call last):
  File "/config/custom_components/elkbledom/elkbledom.py", line 106, in _async_wrap_retry_bluetooth_connection_error
    return await func(self, *args, **kwargs)
  File "/config/custom_components/elkbledom/elkbledom.py", line 227, in turn_on
    await self._write(self._turn_on_cmd)
  File "/config/custom_components/elkbledom/elkbledom.py", line 166, in _write
    await self._write_while_connected(data)
  File "/config/custom_components/elkbledom/elkbledom.py", line 170, in _write_while_connected
    await self._client.write_gatt_char(self._write_uuid, data, False)
  File "/usr/local/lib/python3.10/site-packages/bleak/__init__.py", line 659, in write_gatt_char
    await self._backend.write_gatt_char(char_specifier, data, response)
  File "/usr/local/lib/python3.10/site-packages/bleak/backends/bluezdbus/client.py", line 905, in write_gatt_char
    assert_reply(reply)
  File "/usr/local/lib/python3.10/site-packages/bleak/backends/bluezdbus/utils.py", line 22, in assert_reply
    raise BleakDBusError(reply.error_name, reply.body)
bleak.exc.BleakDBusError: [org.bluez.Error.Failed] Not connected
2023-05-03 23:57:51.417 DEBUG (MainThread) [custom_components.elkbledom.elkbledom] MELK-OA10          : Disconnected from device in 120 seconds; RSSI: -79
2023-05-03 23:57:51.418 DEBUG (MainThread) [custom_components.elkbledom.elkbledom]  7e 00 04 01 00 00 00 00 ef
2023-05-03 23:57:51.426 DEBUG (MainThread) [custom_components.elkbledom.elkbledom] MELK-OA10          : <class 'bleak.exc.BleakDBusError'> error calling <function BLEDOMInstance.turn_on at 0x7f5dd03b50>, reach max attempts (2/2)
Traceback (most recent call last):
  File "/config/custom_components/elkbledom/elkbledom.py", line 106, in _async_wrap_retry_bluetooth_connection_error
    return await func(self, *args, **kwargs)
  File "/config/custom_components/elkbledom/elkbledom.py", line 227, in turn_on
    await self._write(self._turn_on_cmd)
  File "/config/custom_components/elkbledom/elkbledom.py", line 166, in _write
    await self._write_while_connected(data)
  File "/config/custom_components/elkbledom/elkbledom.py", line 170, in _write_while_connected
    await self._client.write_gatt_char(self._write_uuid, data, False)
  File "/usr/local/lib/python3.10/site-packages/bleak/__init__.py", line 659, in write_gatt_char
    await self._backend.write_gatt_char(char_specifier, data, response)
  File "/usr/local/lib/python3.10/site-packages/bleak/backends/bluezdbus/client.py", line 905, in write_gatt_char
    assert_reply(reply)
  File "/usr/local/lib/python3.10/site-packages/bleak/backends/bluezdbus/utils.py", line 22, in assert_reply
    raise BleakDBusError(reply.error_name, reply.body)
bleak.exc.BleakDBusError: [org.bluez.Error.Failed] Not connected
2023-05-03 23:57:51.429 DEBUG (MainThread) [custom_components.elkbledom.elkbledom] MELK-OA10          : Stop
2023-05-03 23:57:51.436 ERROR (MainThread) [aiohttp.server] Error handling request
Traceback (most recent call last):
  File "/usr/local/lib/python3.10/site-packages/aiohttp/web_protocol.py", line 433, in _handle_request
    resp = await request_handler(request)
  File "/usr/local/lib/python3.10/site-packages/aiohttp/web_app.py", line 504, in _handle
    resp = await handler(request)
  File "/usr/local/lib/python3.10/site-packages/aiohttp/web_middlewares.py", line 117, in impl
    return await handler(request)
  File "/usr/src/homeassistant/homeassistant/components/http/security_filter.py", line 85, in security_filter_middleware
    return await handler(request)
  File "/usr/src/homeassistant/homeassistant/components/http/forwarded.py", line 100, in forwarded_middleware
    return await handler(request)
  File "/usr/src/homeassistant/homeassistant/components/http/request_context.py", line 28, in request_context_middleware
    return await handler(request)
  File "/usr/src/homeassistant/homeassistant/components/http/ban.py", line 80, in ban_middleware
    return await handler(request)
  File "/usr/src/homeassistant/homeassistant/components/http/auth.py", line 235, in auth_middleware
    return await handler(request)
  File "/usr/src/homeassistant/homeassistant/components/http/view.py", line 146, in handle
    result = await result
  File "/usr/src/homeassistant/homeassistant/components/config/config_entries.py", line 180, in post
    return await super().post(request, flow_id)
  File "/usr/src/homeassistant/homeassistant/components/http/data_validator.py", line 72, in wrapper
    result = await method(view, request, data, *args, **kwargs)
  File "/usr/src/homeassistant/homeassistant/helpers/data_entry_flow.py", line 110, in post
    result = await self._flow_mgr.async_configure(flow_id, data)
  File "/usr/src/homeassistant/homeassistant/data_entry_flow.py", line 271, in async_configure
    result = await self._async_handle_step(
  File "/usr/src/homeassistant/homeassistant/data_entry_flow.py", line 367, in _async_handle_step
    result: FlowResult = await getattr(flow, method)(user_input)
  File "/config/custom_components/elkbledom/config_flow.py", line 96, in async_step_user
    return await self.async_step_validate()
  File "/config/custom_components/elkbledom/config_flow.py", line 137, in async_step_validate
    error = await self.toggle_light()
  File "/config/custom_components/elkbledom/config_flow.py", line 187, in toggle_light
    await self._instance.stop()
  File "/config/custom_components/elkbledom/elkbledom.py", line 387, in stop
    await self._execute_disconnect()
  File "/config/custom_components/elkbledom/elkbledom.py", line 408, in _execute_disconnect
    await client.stop_notify(read_char)
  File "/usr/local/lib/python3.10/site-packages/bleak/__init__.py", line 735, in stop_notify
    await self._backend.stop_notify(char_specifier)
  File "/usr/local/lib/python3.10/site-packages/bleak/backends/bluezdbus/client.py", line 1035, in stop_notify
    assert_reply(reply)
  File "/usr/local/lib/python3.10/site-packages/bleak/backends/bluezdbus/utils.py", line 22, in assert_reply
    raise BleakDBusError(reply.error_name, reply.body)
bleak.exc.BleakDBusError: [org.bluez.Error.Failed] No notify session started
2023-05-03 23:57:52.891 DEBUG (MainThread) [custom_components.elkbledom.elkbledom] MELK-OA10          : Disconnected from device; RSSI: -79

dave-code-ruiz added a commit that referenced this issue May 5, 2023
@dave-code-ruiz
Copy link
Owner

dave-code-ruiz commented May 5, 2023

Ok, i have new change, you need to do this to try it again:

When homeassistant restart you can test it, send me DEBUG log

@nikolmedo
Copy link

Still having errors 😕
Sorry for so much inconvenience and thanks for your help

2023-05-04 23:04:28.180 DEBUG (MainThread) [custom_components.elkbledom.config_flow] Discovered supported devices: MELK-OA10 91 - BE:16:A9:00:00:91
2023-05-04 23:04:52.780 DEBUG (MainThread) [custom_components.elkbledom.elkbledom] Model information for device MELK-OA10 91 : ModelNo 2, Turn on cmd [126, 0, 4, 1, 0, 0, 0, 0, 239], Turn off cmd [126, 0, 4, 0, 0, 0, 255, 0, 239]
2023-05-04 23:04:52.789 DEBUG (MainThread) [custom_components.elkbledom.elkbledom] MELK-OA10 91: Connecting; RSSI: -82
2023-05-04 23:04:56.150 DEBUG (MainThread) [custom_components.elkbledom.config_flow] Discovered bluetooth devices, step bluetooth, : BE:16:A9:00:00:91 , MELK-OA10 91
2023-05-04 23:04:56.157 DEBUG (MainThread) [custom_components.elkbledom.elkbledom] MELK-OA10 91: Connected; RSSI: -82
2023-05-04 23:04:56.158 DEBUG (MainThread) [custom_components.elkbledom.elkbledom] MELK-OA10 91: Disconnected from device in 120 seconds; RSSI: -82
2023-05-04 23:04:56.160 DEBUG (MainThread) [custom_components.elkbledom.elkbledom] MELK-OA10 91: Disconnected from device in 120 seconds; RSSI: -82
2023-05-04 23:04:56.160 DEBUG (MainThread) [custom_components.elkbledom.elkbledom] 7e 00 04 01 00 00 00 00 ef
2023-05-04 23:04:58.182 DEBUG (MainThread) [custom_components.elkbledom.elkbledom] MELK-OA10 : Disconnected from device in 120 seconds; RSSI: -82
2023-05-04 23:04:58.183 DEBUG (MainThread) [custom_components.elkbledom.elkbledom] 7e 00 04 00 00 00 ff 00 ef
2023-05-04 23:04:58.192 DEBUG (MainThread) [custom_components.elkbledom.elkbledom] MELK-OA10 : Stop
2023-05-04 23:04:58.199 ERROR (MainThread) [aiohttp.server] Error handling request
Traceback (most recent call last):
File "/usr/local/lib/python3.10/site-packages/aiohttp/web_protocol.py", line 433, in _handle_request
resp = await request_handler(request)
File "/usr/local/lib/python3.10/site-packages/aiohttp/web_app.py", line 504, in _handle
resp = await handler(request)
File "/usr/local/lib/python3.10/site-packages/aiohttp/web_middlewares.py", line 117, in impl
return await handler(request)
File "/usr/src/homeassistant/homeassistant/components/http/security_filter.py", line 85, in security_filter_middleware
return await handler(request)
File "/usr/src/homeassistant/homeassistant/components/http/forwarded.py", line 94, in forwarded_middleware
return await handler(request)
File "/usr/src/homeassistant/homeassistant/components/http/request_context.py", line 28, in request_context_middleware
return await handler(request)
File "/usr/src/homeassistant/homeassistant/components/http/ban.py", line 80, in ban_middleware
return await handler(request)
File "/usr/src/homeassistant/homeassistant/components/http/auth.py", line 235, in auth_middleware
return await handler(request)
File "/usr/src/homeassistant/homeassistant/components/http/view.py", line 146, in handle
result = await result
File "/usr/src/homeassistant/homeassistant/components/config/config_entries.py", line 180, in post
return await super().post(request, flow_id)
File "/usr/src/homeassistant/homeassistant/components/http/data_validator.py", line 72, in wrapper
result = await method(view, request, data, *args, **kwargs)
File "/usr/src/homeassistant/homeassistant/helpers/data_entry_flow.py", line 110, in post
result = await self._flow_mgr.async_configure(flow_id, data)
File "/usr/src/homeassistant/homeassistant/data_entry_flow.py", line 271, in async_configure
result = await self._async_handle_step(
File "/usr/src/homeassistant/homeassistant/data_entry_flow.py", line 367, in _async_handle_step
result: FlowResult = await getattr(flow, method)(user_input)
File "/config/custom_components/elkbledom/config_flow.py", line 96, in async_step_user
return await self.async_step_validate()
File "/config/custom_components/elkbledom/config_flow.py", line 137, in async_step_validate
error = await self.toggle_light()
File "/config/custom_components/elkbledom/config_flow.py", line 187, in toggle_light
await self._instance.stop()
File "/config/custom_components/elkbledom/elkbledom.py", line 387, in stop
await self._execute_disconnect()
File "/config/custom_components/elkbledom/elkbledom.py", line 408, in _execute_disconnect
await client.stop_notify(read_char)
File "/usr/local/lib/python3.10/site-packages/bleak/__init__.py", line 735, in stop_notify
await self._backend.stop_notify(char_specifier)
File "/usr/local/lib/python3.10/site-packages/bleak/backends/bluezdbus/client.py", line 1035, in stop_notify
assert_reply(reply)
File "/usr/local/lib/python3.10/site-packages/bleak/backends/bluezdbus/utils.py", line 22, in assert_reply
raise BleakDBusError(reply.error_name, reply.body)
bleak.exc.BleakDBusError: [org.bluez.Error.Failed] No notify session started
2023-05-04 23:06:03.358 INFO (MainThread) [homeassistant.components.analytics] Submitted analytics to Home Assistant servers. Information submitted includes {'uuid': 'd9bb0425efbf477fa7c3583495485259', 'version': '2023.5.1', 'installation_type': 'Home Assistant OS', 'supervisor': {'healthy': True, 'supported': True, 'arch': 'aarch64'}, 'operating_system': {'board': 'rpi3-64', 'version': '10.1'}, 'certificate': False, 'integrations': ['broadlink', 'blueprint', 'cast', 'logger', 'switch', 'bluetooth_adapters', 'repairs', 'zha', 'counter', 'schedule', 'zone', 'usb', 'file_upload', 'homeassistant_alerts', 'input_boolean', 'raspberry_pi', 'diagnostics', 'media_source', 'history', 'ssdp', 'sensor', 'siren', 'ping', 'dlna_dmr', 'mqtt', 'text', 'number', 'sun', 'alarm_control_panel', 'my', 'input_select', 'network', 'esphome', 'input_datetime', 'webhook', 'search', 'energy', 'google_assistant', 'binary_sensor', 'tplink', 'androidtv_remote', 'template', 'system_health', 'roomba', 'bluetooth', 'mobile_app', 'cover', 'light', 'button', 'tasmota', 'hardware', 'update', 'image_upload', 'persistent_notification', 'weather', 'lovelace', 'frontend', 'default_config', 'stt', 'remote', 'google_translate', 'zeroconf', 'conversation', 'device_tracker', 'automation', 'scene', 'analytics', 'auth', 'fan', 'hassio', 'assist_pipeline', 'recorder', 'alexa', 'config', 'system_log', 'map', 'dhcp', 'tod', 'trace', 'cloud', 'tts', 'application_credentials', 'media_player', 'input_text', 'logbook', 'timer', 'person', 'upnp', 'http', 'select', 'google_assistant_sdk', 'device_automation', 'api', 'met', 'notify', 'stream', 'lock', 'vacuum', 'onboarding', 'humidifier', 'script', 'websocket_api', 'climate', 'input_button', 'homeassistant', 'mqtt_room', 'rpi_power', 'camera', 'tag', 'samsungtv', 'input_number'], 'custom_integrations': [{'domain': 'hacs', 'version': <AwesomeVersion SemVer '1.32.1'>}, {'domain': 'samsungtv_smart', 'version': <AwesomeVersion SemVer '0.11.6'>}, {'domain': 'google_home', 'version': <AwesomeVersion SemVer '1.9.17'>}], 'addons': [{'slug': '5c53de3b_esphome', 'protected': True, 'version': '2023.4.4', 'auto_update': False}, {'slug': 'core_ssh', 'protected': True, 'version': '9.7.0', 'auto_update': False}, {'slug': 'core_configurator', 'protected': True, 'version': '5.6.0', 'auto_update': True}, {'slug': 'core_mosquitto', 'protected': True, 'version': '6.2.1', 'auto_update': False}, {'slug': 'a0d7b954_ssh', 'protected': False, 'version': '14.1.0', 'auto_update': False}, {'slug': '45df7312_zigbee2mqtt', 'protected': True, 'version': '1.30.4-1', 'auto_update': True}, {'slug': 'a0d7b954_sonweb', 'protected': True, 'version': '0.24.1', 'auto_update': False}], 'energy': {'configured': False}, 'recorder': {'engine': 'sqlite', 'version': <AwesomeVersion SimpleVer '3.40.1'>}, 'state_count': 17422, 'automation_count': 12, 'integration_count': 111, 'addon_count': 7, 'user_count': 2}
2023-05-04 23:06:58.184 DEBUG (MainThread) [custom_components.elkbledom.elkbledom] MELK-OA10 : Disconnecting after timeout of 120
2023-05-04 23:08:36.728 DEBUG (MainThread) [custom_components.elkbledom.elkbledom] MELK-OA10 : Connecting; RSSI: -82
2023-05-04 23:08:36.751 DEBUG (MainThread) [custom_components.elkbledom.elkbledom] MELK-OA10 : Connected; RSSI: -82
2023-05-04 23:08:36.752 DEBUG (MainThread) [custom_components.elkbledom.elkbledom] MELK-OA10 : Disconnected from device in 120 seconds; RSSI: -82
2023-05-04 23:08:36.753 DEBUG (MainThread) [custom_components.elkbledom.elkbledom] MELK-OA10 : Disconnected from device in 120 seconds; RSSI: -82
2023-05-04 23:08:36.754 DEBUG (MainThread) [custom_components.elkbledom.elkbledom] 7e 00 04 01 00 00 00 00 ef
2023-05-04 23:08:38.795 DEBUG (MainThread) [custom_components.elkbledom.elkbledom] MELK-OA10 : Disconnected from device in 120 seconds; RSSI: -82
2023-05-04 23:08:38.796 DEBUG (MainThread) [custom_components.elkbledom.elkbledom] 7e 00 04 00 00 00 ff 00 ef
2023-05-04 23:08:38.804 DEBUG (MainThread) [custom_components.elkbledom.elkbledom] MELK-OA10 : Stop
2023-05-04 23:08:38.842 ERROR (MainThread) [aiohttp.server] Error handling request
Traceback (most recent call last):
File "/usr/local/lib/python3.10/site-packages/aiohttp/web_protocol.py", line 433, in _handle_request
resp = await request_handler(request)
File "/usr/local/lib/python3.10/site-packages/aiohttp/web_app.py", line 504, in _handle
resp = await handler(request)
File "/usr/local/lib/python3.10/site-packages/aiohttp/web_middlewares.py", line 117, in impl
return await handler(request)
File "/usr/src/homeassistant/homeassistant/components/http/security_filter.py", line 85, in security_filter_middleware
return await handler(request)
File "/usr/src/homeassistant/homeassistant/components/http/forwarded.py", line 94, in forwarded_middleware
return await handler(request)
File "/usr/src/homeassistant/homeassistant/components/http/request_context.py", line 28, in request_context_middleware
return await handler(request)
File "/usr/src/homeassistant/homeassistant/components/http/ban.py", line 80, in ban_middleware
return await handler(request)
File "/usr/src/homeassistant/homeassistant/components/http/auth.py", line 235, in auth_middleware
return await handler(request)
File "/usr/src/homeassistant/homeassistant/components/http/view.py", line 146, in handle
result = await result
File "/usr/src/homeassistant/homeassistant/components/config/config_entries.py", line 180, in post
return await super().post(request, flow_id)
File "/usr/src/homeassistant/homeassistant/components/http/data_validator.py", line 72, in wrapper
result = await method(view, request, data, *args, **kwargs)
File "/usr/src/homeassistant/homeassistant/helpers/data_entry_flow.py", line 110, in post
result = await self._flow_mgr.async_configure(flow_id, data)
File "/usr/src/homeassistant/homeassistant/data_entry_flow.py", line 271, in async_configure
result = await self._async_handle_step(
File "/usr/src/homeassistant/homeassistant/data_entry_flow.py", line 367, in _async_handle_step
result: FlowResult = await getattr(flow, method)(user_input)
File "/config/custom_components/elkbledom/config_flow.py", line 96, in async_step_user
return await self.async_step_validate()
File "/config/custom_components/elkbledom/config_flow.py", line 137, in async_step_validate
error = await self.toggle_light()
File "/config/custom_components/elkbledom/config_flow.py", line 187, in toggle_light
await self._instance.stop()
File "/config/custom_components/elkbledom/elkbledom.py", line 387, in stop
await self._execute_disconnect()
File "/config/custom_components/elkbledom/elkbledom.py", line 408, in _execute_disconnect
await client.stop_notify(read_char)
File "/usr/local/lib/python3.10/site-packages/bleak/__init__.py", line 735, in stop_notify
await self._backend.stop_notify(char_specifier)
File "/usr/local/lib/python3.10/site-packages/bleak/backends/bluezdbus/client.py", line 1035, in stop_notify
assert_reply(reply)
File "/usr/local/lib/python3.10/site-packages/bleak/backends/bluezdbus/utils.py", line 22, in assert_reply
raise BleakDBusError(reply.error_name, reply.body)
bleak.exc.BleakDBusError: [org.bluez.Error.Failed] No notify session started

dave-code-ruiz added a commit that referenced this issue May 5, 2023
@dave-code-ruiz
Copy link
Owner

we are in the right track, i publish new change, please, to try it again:

When homeassistant restart you can test it, send me DEBUG log

@infernix
Copy link
Author

infernix commented May 5, 2023

just an observation as i havent had the time to debug further myself.

i bought several of these, each came with a remote. I can turn them on with any remote, but they only respond to color commands from a single remote each.

So it looks to me as if there is some init and/or login/binding set of commands which then limits from which controller it accepts commands.

@dave-code-ruiz if you drop me a mail with your home address (can find it on my github profile page) i'll buy you one and have it shipped to you, if you're interested.

@nikolmedo
Copy link

just an observation as i havent had the time to debug further myself.

i bought several of these, each came with a remote. I can turn them on with any remote, but they only respond to color commands from a single remote each.

So it looks to me as if there is some init and/or login/binding set of commands which then limits from which controller it accepts commands.

@dave-code-ruiz if you drop me a mail with your home address (can find it on my github profile page) i'll buy you one and have it shipped to you, if you're interested.

That's weird. I have two and I can change the color of both with the same control. But I was also considering the option of sending one of the lights 😅

@infernix
Copy link
Author

infernix commented May 5, 2023

Yes you can control multiple from one controller at the same time, but not one strip from multiple controllers. Or that's what it looks like to me

@nikolmedo
Copy link

we are in the right track, i publish new change, please, to try it again:

When homeassistant restart you can test it, send me DEBUG log

This is the new log information:

2023-05-05 12:26:07.101 DEBUG (MainThread) [custom_components.elkbledom.config_flow] Discovered supported devices: MELK-OA10 91 - BE:16:A9:00:00:91
2023-05-05 12:26:14.738 DEBUG (MainThread) [custom_components.elkbledom.elkbledom] MELK-OA10 91: Connecting; RSSI: -84
2023-05-05 12:26:15.650 DEBUG (MainThread) [custom_components.elkbledom.elkbledom] MELK-OA10 91: Connected; RSSI: -84
2023-05-05 12:26:15.651 DEBUG (MainThread) [custom_components.elkbledom.elkbledom] MELK-OA10 91: Disconnected from device in 120 seconds; RSSI: -84
2023-05-05 12:26:15.651 DEBUG (MainThread) [custom_components.elkbledom.elkbledom] Executing init command for: MELK-OA10 91; RSSI: -84
2023-05-05 12:26:17.658 DEBUG (MainThread) [custom_components.elkbledom.elkbledom] MELK-OA10 : Subscribe to notifications; RSSI: -84
2023-05-05 12:26:47.843 ERROR (MainThread) [custom_components.elkbledom.elkbledom] Error getting status: [org.bluez.Error.Failed] Operation failed with ATT error: 0x0e (Unlikely Error)
2023-05-05 12:26:47.853 DEBUG (MainThread) [custom_components.elkbledom.elkbledom] Traceback (most recent call last):
File "/config/custom_components/elkbledom/elkbledom.py", line 279, in update
await self._ensure_connected()
File "/config/custom_components/elkbledom/elkbledom.py", line 344, in _ensure_connected
await client.start_notify(self._read_uuid, self._notification_handler)
File "/usr/local/lib/python3.10/site-packages/bleak/__init__.py", line 717, in start_notify
await self._backend.start_notify(characteristic, wrapped_callback, **kwargs)
File "/usr/local/lib/python3.10/site-packages/bleak/backends/bluezdbus/client.py", line 1003, in start_notify
assert_reply(reply)
File "/usr/local/lib/python3.10/site-packages/bleak/backends/bluezdbus/utils.py", line 22, in assert_reply
raise BleakDBusError(reply.error_name, reply.body)
bleak.exc.BleakDBusError: [org.bluez.Error.Failed] Operation failed with ATT error: 0x0e (Unlikely Error)
2023-05-05 12:26:47.854 DEBUG (MainThread) [custom_components.elkbledom.elkbledom] MELK-OA10 : Disconnected from device in 120 seconds; RSSI: -84
2023-05-05 12:26:47.855 DEBUG (MainThread) [custom_components.elkbledom.elkbledom] 7e 00 04 01 00 00 00 00 ef
2023-05-05 12:26:47.862 DEBUG (MainThread) [custom_components.elkbledom.elkbledom] MELK-OA10 : <class 'bleak.exc.BleakDBusError'> error calling <function BLEDOMInstance.turn_on at 0x7f740a12d0>, backing off 0.25s, retrying (0/2)...
Traceback (most recent call last):
File "/config/custom_components/elkbledom/elkbledom.py", line 106, in _async_wrap_retry_bluetooth_connection_error
return await func(self, *args, **kwargs)
File "/config/custom_components/elkbledom/elkbledom.py", line 227, in turn_on
await self._write(self._turn_on_cmd)
File "/config/custom_components/elkbledom/elkbledom.py", line 166, in _write
await self._write_while_connected(data)
File "/config/custom_components/elkbledom/elkbledom.py", line 170, in _write_while_connected
await self._client.write_gatt_char(self._write_uuid, data, False)
File "/usr/local/lib/python3.10/site-packages/bleak/__init__.py", line 659, in write_gatt_char
await self._backend.write_gatt_char(char_specifier, data, response)
File "/usr/local/lib/python3.10/site-packages/bleak/backends/bluezdbus/client.py", line 905, in write_gatt_char
assert_reply(reply)
File "/usr/local/lib/python3.10/site-packages/bleak/backends/bluezdbus/utils.py", line 22, in assert_reply
raise BleakDBusError(reply.error_name, reply.body)
bleak.exc.BleakDBusError: [org.bluez.Error.Failed] Not connected
2023-05-05 12:26:48.118 DEBUG (MainThread) [custom_components.elkbledom.elkbledom] MELK-OA10 : Disconnected from device in 120 seconds; RSSI: -84
2023-05-05 12:26:48.119 DEBUG (MainThread) [custom_components.elkbledom.elkbledom] 7e 00 04 01 00 00 00 00 ef
2023-05-05 12:26:48.130 DEBUG (MainThread) [custom_components.elkbledom.elkbledom] MELK-OA10 : <class 'bleak.exc.BleakDBusError'> error calling <function BLEDOMInstance.turn_on at 0x7f740a12d0>, backing off 0.25s, retrying (1/2)...
Traceback (most recent call last):
File "/config/custom_components/elkbledom/elkbledom.py", line 106, in _async_wrap_retry_bluetooth_connection_error
return await func(self, *args, **kwargs)
File "/config/custom_components/elkbledom/elkbledom.py", line 227, in turn_on
await self._write(self._turn_on_cmd)
File "/config/custom_components/elkbledom/elkbledom.py", line 166, in _write
await self._write_while_connected(data)
File "/config/custom_components/elkbledom/elkbledom.py", line 170, in _write_while_connected
await self._client.write_gatt_char(self._write_uuid, data, False)
File "/usr/local/lib/python3.10/site-packages/bleak/__init__.py", line 659, in write_gatt_char
await self._backend.write_gatt_char(char_specifier, data, response)
File "/usr/local/lib/python3.10/site-packages/bleak/backends/bluezdbus/client.py", line 905, in write_gatt_char
assert_reply(reply)
File "/usr/local/lib/python3.10/site-packages/bleak/backends/bluezdbus/utils.py", line 22, in assert_reply
raise BleakDBusError(reply.error_name, reply.body)
bleak.exc.BleakDBusError: [org.bluez.Error.Failed] Not connected
2023-05-05 12:26:48.384 DEBUG (MainThread) [custom_components.elkbledom.elkbledom] MELK-OA10 : Disconnected from device in 120 seconds; RSSI: -84
2023-05-05 12:26:48.385 DEBUG (MainThread) [custom_components.elkbledom.elkbledom] 7e 00 04 01 00 00 00 00 ef
2023-05-05 12:26:48.393 DEBUG (MainThread) [custom_components.elkbledom.elkbledom] MELK-OA10 : <class 'bleak.exc.BleakDBusError'> error calling <function BLEDOMInstance.turn_on at 0x7f740a12d0>, reach max attempts (2/2)
Traceback (most recent call last):
File "/config/custom_components/elkbledom/elkbledom.py", line 106, in _async_wrap_retry_bluetooth_connection_error
return await func(self, *args, **kwargs)
File "/config/custom_components/elkbledom/elkbledom.py", line 227, in turn_on
await self._write(self._turn_on_cmd)
File "/config/custom_components/elkbledom/elkbledom.py", line 166, in _write
await self._write_while_connected(data)
File "/config/custom_components/elkbledom/elkbledom.py", line 170, in _write_while_connected
await self._client.write_gatt_char(self._write_uuid, data, False)
File "/usr/local/lib/python3.10/site-packages/bleak/__init__.py", line 659, in write_gatt_char
await self._backend.write_gatt_char(char_specifier, data, response)
File "/usr/local/lib/python3.10/site-packages/bleak/backends/bluezdbus/client.py", line 905, in write_gatt_char
assert_reply(reply)
File "/usr/local/lib/python3.10/site-packages/bleak/backends/bluezdbus/utils.py", line 22, in assert_reply
raise BleakDBusError(reply.error_name, reply.body)
bleak.exc.BleakDBusError: [org.bluez.Error.Failed] Not connected
2023-05-05 12:26:48.396 DEBUG (MainThread) [custom_components.elkbledom.elkbledom] MELK-OA10 : Stop
2023-05-05 12:26:48.409 ERROR (MainThread) [aiohttp.server] Error handling request
Traceback (most recent call last):
File "/usr/local/lib/python3.10/site-packages/aiohttp/web_protocol.py", line 433, in _handle_request
resp = await request_handler(request)
File "/usr/local/lib/python3.10/site-packages/aiohttp/web_app.py", line 504, in _handle
resp = await handler(request)
File "/usr/local/lib/python3.10/site-packages/aiohttp/web_middlewares.py", line 117, in impl
return await handler(request)
File "/usr/src/homeassistant/homeassistant/components/http/security_filter.py", line 85, in security_filter_middleware
return await handler(request)
File "/usr/src/homeassistant/homeassistant/components/http/forwarded.py", line 94, in forwarded_middleware
return await handler(request)
File "/usr/src/homeassistant/homeassistant/components/http/request_context.py", line 28, in request_context_middleware
return await handler(request)
File "/usr/src/homeassistant/homeassistant/components/http/ban.py", line 80, in ban_middleware
return await handler(request)
File "/usr/src/homeassistant/homeassistant/components/http/auth.py", line 235, in auth_middleware
return await handler(request)
File "/usr/src/homeassistant/homeassistant/components/http/view.py", line 146, in handle
result = await result
File "/usr/src/homeassistant/homeassistant/components/config/config_entries.py", line 180, in post
return await super().post(request, flow_id)
File "/usr/src/homeassistant/homeassistant/components/http/data_validator.py", line 72, in wrapper
result = await method(view, request, data, *args, **kwargs)
File "/usr/src/homeassistant/homeassistant/helpers/data_entry_flow.py", line 110, in post
result = await self._flow_mgr.async_configure(flow_id, data)
File "/usr/src/homeassistant/homeassistant/data_entry_flow.py", line 271, in async_configure
result = await self._async_handle_step(
File "/usr/src/homeassistant/homeassistant/data_entry_flow.py", line 367, in _async_handle_step
result: FlowResult = await getattr(flow, method)(user_input)
File "/config/custom_components/elkbledom/config_flow.py", line 96, in async_step_user
return await self.async_step_validate()
File "/config/custom_components/elkbledom/config_flow.py", line 137, in async_step_validate
error = await self.toggle_light()
File "/config/custom_components/elkbledom/config_flow.py", line 187, in toggle_light
await self._instance.stop()
File "/config/custom_components/elkbledom/elkbledom.py", line 405, in stop
await self._execute_disconnect()
File "/config/custom_components/elkbledom/elkbledom.py", line 426, in _execute_disconnect
await client.stop_notify(read_char)
File "/usr/local/lib/python3.10/site-packages/bleak/__init__.py", line 735, in stop_notify
await self._backend.stop_notify(char_specifier)
File "/usr/local/lib/python3.10/site-packages/bleak/backends/bluezdbus/client.py", line 1035, in stop_notify
assert_reply(reply)
File "/usr/local/lib/python3.10/site-packages/bleak/backends/bluezdbus/utils.py", line 22, in assert_reply
raise BleakDBusError(reply.error_name, reply.body)
bleak.exc.BleakDBusError: [org.bluez.Error.Failed] No notify session started
2023-05-05 12:26:49.922 DEBUG (MainThread) [custom_components.elkbledom.elkbledom] MELK-OA10 : Disconnected from device; RSSI: -84

@dave-code-ruiz
Copy link
Owner

ok, try again, i think i have problems with login/init commands,

when code wants to read information to led strip show an error, i think it is for login/init commands don't work.

Solution: Do not read state information, my integration already had a bug about reading the state of the led strip

When i receive the led strip courtesy of @infernix i will continue with this

@nikolmedo
Copy link

ok, try again, i think i have problems with login/init commands,

when code wants to read information to led strip show an error, i think it is for login/init commands don't work.

Solution: Do not read state information, my integration already had a bug about reading the state of the led strip

When i receive the led strip courtesy of @infernix i will continue with this

Thank you! It's working now. If you could improve that in the future that would be awesome, but now it's really useful to be able to use the lights from home assistant.

@dave-code-ruiz
Copy link
Owner

Great!!, can you tell me in addition to turn on and turn off commands, the color and brightness also works?

@dave-code-ruiz
Copy link
Owner

Thnks for your coffee, I have refunded it by mistake, hehehe

@nikolmedo
Copy link

Great!!, can you tell me in addition to turn on and turn off commands, the color and brightness also works?

Yes, everything is working. It could be more precise when changing color, but I think it is also a problem with the device because with the native app it does not achieve the desired color either

dave-code-ruiz added a commit that referenced this issue May 10, 2023
- Finish changes for #11
- readme description
- Ajust config params
@dave-code-ruiz
Copy link
Owner

I create new version 1.0.7 with changes creates in this issue.
I think it's bestter to close the issue and if itˋs needed re-open or create new
Thanks for your information, integration is better now

@sasukebinbin
Copy link

It works great now. All function can work inside the compontent.
Would be great if can add rainbow effect inside the effect list.
And not sure if possible to add control for enable the sound detection mode.

But whatever it's already awsome.
Thank you so much

@dave-code-ruiz
Copy link
Owner

dave-code-ruiz commented May 23, 2023

just an observation as i havent had the time to debug further myself.

i bought several of these, each came with a remote. I can turn them on with any remote, but they only respond to color commands from a single remote each.

So it looks to me as if there is some init and/or login/binding set of commands which then limits from which controller it accepts commands.

@dave-code-ruiz if you drop me a mail with your home address (can find it on my github profile page) i'll buy you one and have it shipped to you, if you're interested.

Thanks @infernix for buy me your led strip, please post amazon link here, thnks

Initialy i have same issue. in logs show cannot connect to Led strip.

Before send inits commands i connect it and works without problem.

Where discover you init commands ??

@infernix
Copy link
Author

Install the DuoCo StripX android app and then turn on bluetooth packet logging. it generates a logfile which you can then feed into wireshark.

https://support.honeywellaidc.com/s/article/How-to-capture-Bluetooth-traffic-from-and-to-an-Android-Device

You can find the exact strip if you search amazon for B09VC77GCZ

@ynsgnr
Copy link
Contributor

ynsgnr commented Aug 26, 2023

Did some digging with packet logging, i think this integration can handle brightness better: #41

@ynsgnr
Copy link
Contributor

ynsgnr commented Aug 26, 2023

Did some changes to better support MELK (stripX) in https://github.com/ynsgnr/elkbledom

  • Implemented new effects including music effects
  • Implemented effect intensity

Not sure how to combine it with the ELK (strip) though, seems like MELK uses a different version of the protocol with backwards compability, maybe a separate repo can make sense for MELK only, or some config changes in this repo can help 🤔

@fonix232
Copy link

@ynsgnr since the protocol is backwards compatible, wouldn't it be possible to create an inheritance-based approach where there's:

  • an ELKProtocol class defining the base protocol
  • a MELKProtocol class, inheriting from ELKProtocol and adding its own specifics (e.g. overriding effects list)
  • have the setup code branch and load the appropriate Protocol instance depending on the device name (or if there's a better identifier of the protocol, using that).

@ynsgnr
Copy link
Contributor

ynsgnr commented Dec 29, 2023

@ynsgnr since the protocol is backwards compatible, wouldn't it be possible to create an inheritance-based approach where there's:

* an ELKProtocol class defining the base protocol

* a MELKProtocol class, inheriting from ELKProtocol and adding its own specifics (e.g. overriding effects list)

* have the setup code branch and load the appropriate Protocol instance depending on the device name (or if there's a better identifier of the protocol, using that).

Probably, but I do not own any ELK device so I can not implement or test it. Could also done with interfaces or abstract classes but all of those implementations and testing takes time which I do not have

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

6 participants