home-assistant / core

:house_with_garden: Open source home automation that puts local control and privacy first.
https://www.home-assistant.io
Apache License 2.0
71.04k stars 29.7k forks source link

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

Open fonix232 opened 1 month ago

fonix232 commented 1 month ago

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

home-assistant[bot] commented 1 month ago

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)

DaveWK commented 1 month ago

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

fonix232 commented 1 month ago

@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).

proffalken commented 1 month ago

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.

rwalker777 commented 1 month ago

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.

fonix232 commented 1 month ago

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

therealabradolf commented 3 weeks ago

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

rwalker777 commented 3 weeks ago

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.