Bluetooth-Devices / led-ble

Control a wide range of LED BLE devices
Apache License 2.0
12 stars 9 forks source link

Add to led_ble custom lights configured by user #34

Open and7ey opened 1 year ago

and7ey commented 1 year ago

What is the process to add more lights to led_ble? For ex., here is the list of commands/characteristics to be used with SP110E controller. And I would like to add commands for SP107E (it controls the strip, SK6812_RGBW in my case - it could be switched on/off, the color could be changed, the brightness, effects, music/static color modes).

Is your feature request related to a problem? Please describe. No

Describe the solution you'd like The ideal solution would be to move light settings/commands from const.py - the user interface should allow to choose ready-for-use settings based on the lamp name (what you have in const.py currently) or user should be able to input all settings manually. In this case I will be able to add SP107E myself.

Additional context I've tried to add SP107E support based on SP110E component, but it doesn't work since SP110E component uses its own implementation of bluetooth connection. I've tried to modify led_ble component to add support of SP107E, but I am failed with local led_ble installation (File "/config/led_ble/led_ble.py", line 16, in <module> from bleak_retry_connector import (ImportError: cannot import name 'retry_bluetooth_connection_error' from 'bleak_retry_connector' (/usr/local/lib/python3.10/site-packages/bleak_retry_connector/__init__.py)). But it looks for me that I am re-inventing the wheel.

bdraco commented 1 year ago

Can you post details about the protocol to see if it’s a fit for this library?

and7ey commented 1 year ago

Hmm, I thought I added it to the post :)

Here is the description of SP110E protocol https://gist.github.com/mbullington/37957501a07ad065b67d4e8d39bfe012?permalink_comment_id=3611593#gistcomment-3611593

and I am working on SP107E protocol reverse engineering currently :) The functionality is the same, just commands are different.

bdraco commented 1 year ago

Seems like a good candidate to add as it looks like it follows the same logic as this library.

You'll need to add a new protocol here https://github.com/Danielhiversen/flux_led/blob/master/flux_led/protocol.py

and7ey commented 1 year ago

I've expected more user friendly doc, not PR ;)

How the following code is used? I've supposed to replace 0xEF0177 with what?

    def construct_state_query(self) -> bytearray:
        """The bytes to send for a query request."""
        return self.construct_message(bytearray([0xEF, 0x01, 0x77]))

there is STATE_COMMAND const at led_ble, why there is another command?

bdraco commented 1 year ago

I've expected more user friendly doc, not PR ;)

It would be great if you could write some docs when you finish your PR.

How the following code is used? I've supposed to replace 0xEF0177 with what?

The state query is the bytes to send to get the current state of the device

    def construct_state_query(self) -> bytearray:
        """The bytes to send for a query request."""
        return self.construct_message(bytearray([0xEF, 0x01, 0x77]))

there is STATE_COMMAND const at led_ble, why there is another command?

The code was switched to using the flux_led protocol files at a later point. It might be leftovers that needs to be cleaned up still