core icon indicating copy to clipboard operation
core copied to clipboard

ELK/MELK protocol BLE LED devices are detected as supported by the LED BLE integration, but setup fails

Open fonix232 opened this issue 1 year ago • 12 comments

The problem

I have an Amazon bought shelf with a built-in addressable LED strip that I've been using with the elkbledom custom integration for about a year now. While the device is a bit limited, and the integration lacks a few features (e.g. precise effect list), it worked well so far for my purposes.

Ever since the first 24.7 beta, this same device has shown up as supported by the official LED BLE integration, however attempting setup results in the following error:

Logger: homeassistant.components.led_ble.config_flow
Source: components/led_ble/config_flow.py:68
integration: led_ble ([documentation](https://www.home-assistant.io/integrations/led_ble), [issues](https://github.com/home-assistant/core/issues?q=is%3Aissue+is%3Aopen+label%3A%22integration%3A+led_ble%22))
First occurred: 21:54:00 (1 occurrences)
Last logged: 21:54:00

Unexpected error
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/components/led_ble/config_flow.py", line 68, in async_step_user
    await led_ble.update()
  File "/usr/local/lib/python3.12/site-packages/led_ble/led_ble.py", line 150, in update
    await self._ensure_connected()
  File "/usr/local/lib/python3.12/site-packages/led_ble/led_ble.py", line 355, in _ensure_connected
    await client.start_notify(self._read_char, self._notification_handler)
  File "/usr/local/lib/python3.12/site-packages/bleak/__init__.py", line 827, in start_notify
    characteristic = self.services.get_characteristic(char_specifier)
                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/bleak/backends/service.py", line 179, in get_characteristic
    uuid = normalize_uuid_str(str(specifier))
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/bleak/uuids.py", line 1240, in normalize_uuid_str
    return str(UUID(uuid))
               ^^^^^^^^^^
  File "/usr/local/lib/python3.12/uuid.py", line 179, in __init__
    int = int_(hex, 16)
          ^^^^^^^^^^^^^
ValueError: invalid literal for int() with base 16: '0000None00001000800000805f9b34fb'

Looks like one of the characteristic IDs is not getting parsed, hence the random None in the middle of a hex string.

I've checked through the source of the integration, and I do not believe it supports the ELK/MELK protocol in its current shape and form. Thus I think the best approach would be ensuring that these devices don't show up for the LED BLE integration. I also tried to discern which change caused this, but alas couldn't point finger at any specific commit.

What version of Home Assistant Core has the issue?

core-2024.7.2

What was the last working version of Home Assistant Core?

core-2024.6.x

What type of installation are you running?

Home Assistant OS

Integration causing the issue

LED BLE

Link to integration documentation on our website

https://www.home-assistant.io/integrations/led_ble

Diagnostics information

No response

Example YAML snippet

No response

Anything in the logs that might be useful for us?

Logger: homeassistant.components.led_ble.config_flow
Source: components/led_ble/config_flow.py:68
integration: led_ble (documentation, issues)
First occurred: 21:54:00 (1 occurrences)
Last logged: 21:54:00

Unexpected error
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/components/led_ble/config_flow.py", line 68, in async_step_user
    await led_ble.update()
  File "/usr/local/lib/python3.12/site-packages/led_ble/led_ble.py", line 150, in update
    await self._ensure_connected()
  File "/usr/local/lib/python3.12/site-packages/led_ble/led_ble.py", line 355, in _ensure_connected
    await client.start_notify(self._read_char, self._notification_handler)
  File "/usr/local/lib/python3.12/site-packages/bleak/__init__.py", line 827, in start_notify
    characteristic = self.services.get_characteristic(char_specifier)
                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/bleak/backends/service.py", line 179, in get_characteristic
    uuid = normalize_uuid_str(str(specifier))
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/bleak/uuids.py", line 1240, in normalize_uuid_str
    return str(UUID(uuid))
               ^^^^^^^^^^
  File "/usr/local/lib/python3.12/uuid.py", line 179, in __init__
    int = int_(hex, 16)
          ^^^^^^^^^^^^^
ValueError: invalid literal for int() with base 16: '0000None00001000800000805f9b34fb'

Additional information

No response

fonix232 avatar Jul 10 '24 21:07 fonix232

Hey there @bdraco, mind taking a look at this issue as it has been labeled with an integration (led_ble) you are listed as a code owner for? Thanks!

Code owner commands

Code owners of led_ble can trigger bot actions by commenting:

  • @home-assistant close Closes the issue.
  • @home-assistant rename Awesome new title Renames the issue.
  • @home-assistant reopen Reopen the issue.
  • @home-assistant unassign led_ble Removes the current integration label and assignees on the issue, add the integration domain after the command.
  • @home-assistant add-label needs-more-information Add a label (needs-more-information, problem in dependency, problem in custom component) to the issue.
  • @home-assistant remove-label needs-more-information Remove a label (needs-more-information, problem in dependency, problem in custom component) on the issue.

(message by CodeOwnersMention)


led_ble documentation led_ble source (message by IssueLinks)

home-assistant[bot] avatar Jul 10 '24 21:07 home-assistant[bot]

I am also seeing this -- got all excited that HA had added support for my light strip. Hopefully this is a sign of things to come..

I am getting the same error as above, and same UUID: ValueError: invalid literal for int() with base 16: '0000None00001000800000805f9b34fb'

Device is identified as: MELK-OC21W 79 (2E79) and is a vertical LED light bar that I would love to control with HA instead of the limited app it came with.

Happy to test and get logs

DaveWK avatar Jul 11 '24 00:07 DaveWK

@DaveWK as per my post you can control it with HA, using the linked elkbledom integration - with some limitations (e.g. the device doesn't broadcast its state like other BLE LED controllers, so upon HA reboot the state becomes the generic default until you change it; and also the list of effects is incorrect as it reads from the ELK-specific table for MELK devices).

fonix232 avatar Jul 11 '24 02:07 fonix232

I'm seeing this same issue but I don't think I've got it with an ELK/MELK device as it shows up in HA as LEDBLE-0A2C95 (2C95)

Error output:

Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/components/led_ble/config_flow.py", line 68, in async_step_user
    await led_ble.update()
  File "/usr/local/lib/python3.12/site-packages/led_ble/led_ble.py", line 150, in update
    await self._ensure_connected()
  File "/usr/local/lib/python3.12/site-packages/led_ble/led_ble.py", line 355, in _ensure_connected
    await client.start_notify(self._read_char, self._notification_handler)
  File "/usr/local/lib/python3.12/site-packages/bleak/__init__.py", line 827, in start_notify
    characteristic = self.services.get_characteristic(char_specifier)
                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/bleak/backends/service.py", line 179, in get_characteristic
    uuid = normalize_uuid_str(str(specifier))
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/bleak/uuids.py", line 1240, in normalize_uuid_str
    return str(UUID(uuid))
               ^^^^^^^^^^
  File "/usr/local/lib/python3.12/uuid.py", line 179, in __init__
    int = int_(hex, 16)
          ^^^^^^^^^^^^^
ValueError: invalid literal for int() with base 16: '0000None00001000800000805f9b34fb'

In my case, the elkbledom plugin also errors with a GAAT timout, but I suspect that's because this is not an ELK device.

proffalken avatar Jul 12 '24 11:07 proffalken

This was my commit, I'm working on putting a fix in with led_ble python module, but that may be a while. We can revert this until then.

rwalker777 avatar Jul 15 '24 14:07 rwalker777

@rwalker777 thanks for the confirmation. You marked your PR as tested locally - did it actually work for your MELK protocol devices?

fonix232 avatar Jul 15 '24 22:07 fonix232

Same issue here. would love to see it fixed :)

therealabradolf avatar Aug 13 '24 19:08 therealabradolf

I have writes working for on/off, effect, color, brightness and speed, but the read calls don't work. It will be a bit longer as I'm pretty busy with work.

rwalker777 avatar Aug 14 '24 13:08 rwalker777

Want to brain dump what I have so far, as I have had no cycle to come back to this:

"ELK-BLE**" - 7e07 "ELK-BULB*" - 7e07 "MELK-*" - 7e00

**** | | | | - Header - second octet is padding |** | | | - Command | |********** | | - Data | | |**** | - Footer 7e00 01 64000000 00ef

Commands and Data structure: 01 - Brightness (first 2 data 0-100% - next 2 '03' next 4 is padding) 7e00013203000000ef - 50% 7e00016403000000ef - 100% 02 - Speed (first 2 data 0-100% - next 6 is padding) 7e00023200000000ef - 50% 7e00026400000000ef - 100% 03 - Effect (first 2 effect # - next 6 is padding) 7e00038803000000ef - cycle colors 04 - Power (first 2 00 for off or 01 for on - next 6 is padding) 05 - Color (03 - RED - GREEN - BLUE) where 0-255 for each color in hex 7e000503ff000000ef - RED 7e00050300ff0000ef - GREEN 7e0005030000ff00ef - BLUE

Remaining issues:

  1. No way to list effects (which means they will need to be predefined).
  2. Query current state works, but can't find a way to get updates with polling.

rwalker777 avatar Sep 10 '24 15:09 rwalker777

@rwalker777 FYI read calls on MELK haven't worked for me at all - the connection ends up hanging, the device refuses to respond to any other commands, and needed a connection reset (often even a device reset) to get things going again. I think it is a (more or less "known") fault of the devices equipped with this protocol.

So for MELK I'd recommend forgoing the read operations, and reusing the last known state.

Also you might want to fix the table you tried to make in your reply, it's completely effed on my end :(

fonix232 avatar Sep 10 '24 21:09 fonix232

Same for me. Hope to get this working. It would be great to integrate in HA. The included Magic Lantern app is pretty bad. image

From my Log viewer

           ^^^^^^^^^^

File "/usr/local/lib/python3.12/uuid.py", line 179, in init int = int_(hex, 16) ^^^^^^^^^^^^^ ValueError: invalid literal for int() with base 16: '0000None00001000800000805f9b34fb'

soupman98 avatar Oct 30 '24 13:10 soupman98

I have the same issue with this led lamp

RBF-Martin avatar Nov 04 '24 18:11 RBF-Martin

How did you connect it to Bluetooth please

Steve Campbell 615.497.4761


From: RBF-Martin @.> Sent: Monday, November 4, 2024 12:45:54 PM To: home-assistant/core @.> Cc: Steve Campbell @.>; Comment @.> Subject: Re: [home-assistant/core] ELK/MELK protocol BLE LED devices are detected as supported by the LED BLE integration, but setup fails (Issue #121718)

I have the same issue with this led lamp

— Reply to this email directly, view it on GitHubhttps://github.com/home-assistant/core/issues/121718#issuecomment-2455452035, or unsubscribehttps://github.com/notifications/unsubscribe-auth/ADUPRMIPSDNDJTW7OZGNQGLZ666GFAVCNFSM6AAAAABKVV5EUSVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDINJVGQ2TEMBTGU. You are receiving this because you commented.Message ID: @.***>

soupman98 avatar Nov 05 '24 00:11 soupman98

Device: MELK-OA10W 82 Manufacturer: BE:11:15

Recoginition is working

image

Configuration fails

image

Logs:

2024-11-06 16:05:34.193 DEBUG (MainThread) [homeassistant.components.bluetooth.manager] hci1 (E0:75:26:82:69:A3) [connectable]: <BluetoothServiceInfoBleak name=MELK-OA10W  82 address=BE:11:15:00:1A:82 rssi=-84 manufacturer_data={} service_data={} service_uuids=[] source=E0:75:26:82:69:A3 connectable=True time=4327459.150935603 tx_power=None> match: set()
2024-11-06 16:08:26.517 WARNING (MainThread) [led_ble.led_ble] MELK-OA10W  82: Device unexpectedly disconnected; RSSI: None

Versions

  • hass 2024.10.4
  • bluetoothctl 5.76

rueckert-digital avatar Nov 06 '24 16:11 rueckert-digital

I still have not had any time to get this working, unfortunately it would require significant rework to support ELK/MELK based devices. I will revert the support for this.

rwalker777 avatar Nov 06 '24 17:11 rwalker777

I still have not had any time to get this working, unfortunately it would require significant rework to support ELK/MELK based devices. I will revert the support for this.

That's a shame, but absolutely understandable !!!

For everyone else: After various attempts and fights with https://github.com/dave-code-ruiz/elkbledom I can now use finally my device.

rueckert-digital avatar Nov 06 '24 18:11 rueckert-digital

Same error here

addisaden avatar Dec 22 '24 11:12 addisaden

Same error for me - happy to test in future

billybigpotatoes avatar Jan 09 '25 23:01 billybigpotatoes

Same error, guys)

SpectralDragon avatar Jan 15 '25 22:01 SpectralDragon

Same error for me!

fmiguelmmartins avatar Jan 17 '25 17:01 fmiguelmmartins