Name | BlueLights JSON |
Version |
0.3.1
JSON |
| download |
home_page | None |
Summary | A library for controlling MohuanLED lights via Bluetooth |
upload_time | 2024-09-14 03:08:52 |
maintainer | None |
docs_url | None |
author | Walkercito |
requires_python | >=3.8 |
license | None |
keywords |
|
VCS |
|
bugtrack_url |
|
requirements |
No requirements were recorded.
|
Travis-CI |
No Travis.
|
coveralls test coverage |
No coveralls.
|
# π MohuanLED Bluetooth Control
BJ_LED_M is a Python library designed to control MohuanLED brand lights via Bluetooth, directly from your laptop or PC (youβll need a Bluetooth adapter if itβs not built-in). This library allows you to perform simple actions like turning the lights on/off, changing colors, and applying animations or reactions to external events. It also includes a PyQt6-based GUI for more intuitive control over the lights. π
## π Usage
The library is fully asynchronous, so you'll need to use asyncio and await. Here's an example of how to establish a direct connection, knowing the UUID and MAC address of the LEDs:
```python
from bluelights import BJLEDInstance
import asyncio
ADDRESS = '64:11:a8:00:8b:a6' # Example address
UUID = '0000ee02-0000-1000-2000-00805f9b34fb' # Example UUID
async def main():
led = BJLEDInstance(address=ADDRESS, uuid=UUID)
try:
await led.turn_on()
await led.set_color_to_rgb(255, 0, 0) # Change color to red (RGB)
await asyncio.sleep(5) # Wait 5 seconds
await led.turn_off() # Turn off LEDs and disconnect
except Exception as e:
print(e)
finally:
await led._disconnect() # Clear the buffer
asyncio.run(main())
```
A dynamic example with the same orders:
```python
from bluelights import BJLEDInstance
import asyncio
async def main():
led = BJLEDInstance() # The Scanner will look for 'BJ_LED_M' (name of the devices) and connect
try:
await led.turn_on()
await led.set_color_to_rgb(255, 0, 0) # Change color to red (RGB)
await asyncio.sleep(5) # Wait 5 seconds
await led.turn_off() # Turn off LEDs and disconnect
except Exception as e:
print(e)
finally:
await led._disconnect() # Clear the buffer
asyncio.run(main())
```
## βοΈ Features
- Control MohuanLED lights via Bluetooth (BLE)
- Turn the LEDs on and off π‘
- Change colors across the full RGB spectrum π¨
- Apply effects like:
- π Color fade
- π‘ Color strobe
- π¬οΈ Breathing effect between colors
- π Rainbow cycle
- π Wave effect
- Graphical user interface (GUI) using PyQt6 (In development π οΈ)
- Command Line Interface (CLI) for basic commands (In development π οΈ)
- Dynamic MohuanLED device scanner for easy connections (In development π οΈ)
- Automatic detection of UUIDs and MAC addresses
## π οΈ Installation
### Requirements
- Python 3.8 or higher
- PyQt6 and qasync
- Built-in or external Bluetooth adapter
- MohuanLED lights
You can install the library via pip:
```bash
pip install BlueLights
```
Or install it directly from the repository:
```bash
git clone https://github.com/Walkercito/MohuanLED-Bluetooth_LED
cd BlueLights
pip install .
```
### π Applying Effects
You can add various effects to the lights, such as rainbow_cycle, wave_effect, or strobe_light. Here are a few examples:
```python
# Apply the 'rainbow_cycle' effect
await led.rainbow_cycle(duration_per_color=5.0)
# Apply the 'strobe_light' effect with 10 flashes
await led.strobe_light(color=(255, 255, 255), duration=5.0, flashes=10)
```
### π₯οΈ GUI Control
The library also provides a graphical user interface (GUI) built with PyQt6 to visually control the lights.
To launch the GUI:
```bash
python -m bluelights.gui.app
```
The GUI includes sliders to adjust RGB values and buttons to control the lights and apply effects like fading and color cycling.
### βοΈ Configuration
You can configure your setup using an .env file to store your MohuanLED lightβs MAC address and UUID.
Create a .env file in the project directory with the following structure:
```bash
LED_MAC_ADDRESS=xx:xx:xx:xx:xx:xx
LED_UUID=0000xxxx-0000-1000-8000-00805f9b34fb
```
The library will automatically load these values when you instantiate the LEDs.
### π οΈ Development
If you want to contribute or modify the project, you can set up the development environment as follows:
Clone the repository:
```bash
git clone https://github.com/Walkercito/MohuanLED-Bluetooth_LED
```
Install the dependencies:
```bash
pip install -r requirements.txt
```
### π License
This project is licensed under the MIT License. See the LICENSE file for more details.
### Acknowledgments
- Bleak: For Bluetooth Low Energy (BLE) device control π
- PyQt6: For creating the graphical interface πΌοΈ
- asyncio: For asyncronus tasks
- qasync: For handling asynchronous processes in PyQt6 β‘
- python-dotenv: For auto-loading of LED_MAC_ADDRESS and LED_UUID in case of a `.env` file
- nest_asyncio: For asyncio control
Raw data
{
"_id": null,
"home_page": null,
"name": "BlueLights",
"maintainer": null,
"docs_url": null,
"requires_python": ">=3.8",
"maintainer_email": null,
"keywords": null,
"author": "Walkercito",
"author_email": "walkercitoliver@gmail.com",
"download_url": "https://files.pythonhosted.org/packages/f3/22/51b9ea9fb9ab53b70838ece28cab22d052139d7e8625b180fa79be377e11/bluelights-0.3.1.tar.gz",
"platform": null,
"description": "# \ud83c\udf08 MohuanLED Bluetooth Control\r\nBJ_LED_M is a Python library designed to control MohuanLED brand lights via Bluetooth, directly from your laptop or PC (you\u2019ll need a Bluetooth adapter if it\u2019s not built-in). This library allows you to perform simple actions like turning the lights on/off, changing colors, and applying animations or reactions to external events. It also includes a PyQt6-based GUI for more intuitive control over the lights. \ud83c\udf1f\r\n\r\n## \ud83d\ude80 Usage\r\nThe library is fully asynchronous, so you'll need to use asyncio and await. Here's an example of how to establish a direct connection, knowing the UUID and MAC address of the LEDs:\r\n\r\n```python\r\nfrom bluelights import BJLEDInstance\r\nimport asyncio\r\n\r\nADDRESS = '64:11:a8:00:8b:a6' # Example address\r\nUUID = '0000ee02-0000-1000-2000-00805f9b34fb' # Example UUID\r\n\r\nasync def main():\r\n led = BJLEDInstance(address=ADDRESS, uuid=UUID)\r\n\r\n try:\r\n await led.turn_on()\r\n await led.set_color_to_rgb(255, 0, 0) # Change color to red (RGB)\r\n\r\n await asyncio.sleep(5) # Wait 5 seconds\r\n await led.turn_off() # Turn off LEDs and disconnect\r\n except Exception as e:\r\n print(e)\r\n \r\n finally:\r\n await led._disconnect() # Clear the buffer\r\n \r\nasyncio.run(main())\r\n```\r\n\r\nA dynamic example with the same orders:\r\n```python\r\nfrom bluelights import BJLEDInstance\r\nimport asyncio\r\n\r\nasync def main():\r\n led = BJLEDInstance() # The Scanner will look for 'BJ_LED_M' (name of the devices) and connect\r\n try:\r\n await led.turn_on()\r\n await led.set_color_to_rgb(255, 0, 0) # Change color to red (RGB)\r\n\r\n await asyncio.sleep(5) # Wait 5 seconds\r\n await led.turn_off() # Turn off LEDs and disconnect\r\n except Exception as e:\r\n print(e)\r\n\r\n finally:\r\n await led._disconnect() # Clear the buffer\r\n \r\nasyncio.run(main())\r\n```\r\n\r\n## \u2699\ufe0f Features\r\n- Control MohuanLED lights via Bluetooth (BLE)\r\n- Turn the LEDs on and off \ud83d\udca1\r\n- Change colors across the full RGB spectrum \ud83c\udfa8\r\n- Apply effects like:\r\n - \ud83d\udd04 Color fade\r\n - \ud83d\udca1 Color strobe\r\n - \ud83c\udf2c\ufe0f Breathing effect between colors\r\n - \ud83c\udf08 Rainbow cycle\r\n - \ud83c\udf0a Wave effect\r\n- Graphical user interface (GUI) using PyQt6 (In development \ud83d\udee0\ufe0f)\r\n- Command Line Interface (CLI) for basic commands (In development \ud83d\udee0\ufe0f)\r\n- Dynamic MohuanLED device scanner for easy connections (In development \ud83d\udee0\ufe0f)\r\n- Automatic detection of UUIDs and MAC addresses\r\n\r\n## \ud83d\udee0\ufe0f Installation\r\n\r\n### Requirements\r\n- Python 3.8 or higher\r\n- PyQt6 and qasync\r\n- Built-in or external Bluetooth adapter\r\n- MohuanLED lights\r\n\r\nYou can install the library via pip:\r\n\r\n```bash\r\npip install BlueLights\r\n```\r\n\r\nOr install it directly from the repository:\r\n\r\n```bash\r\ngit clone https://github.com/Walkercito/MohuanLED-Bluetooth_LED\r\ncd BlueLights\r\npip install .\r\n```\r\n\r\n### \ud83c\udf08 Applying Effects\r\nYou can add various effects to the lights, such as rainbow_cycle, wave_effect, or strobe_light. Here are a few examples:\r\n\r\n```python\r\n# Apply the 'rainbow_cycle' effect\r\nawait led.rainbow_cycle(duration_per_color=5.0)\r\n\r\n# Apply the 'strobe_light' effect with 10 flashes\r\nawait led.strobe_light(color=(255, 255, 255), duration=5.0, flashes=10)\r\n```\r\n\r\n### \ud83d\udda5\ufe0f GUI Control\r\nThe library also provides a graphical user interface (GUI) built with PyQt6 to visually control the lights.\r\n\r\nTo launch the GUI:\r\n\r\n```bash\r\npython -m bluelights.gui.app\r\n```\r\n\r\nThe GUI includes sliders to adjust RGB values and buttons to control the lights and apply effects like fading and color cycling.\r\n\r\n### \u2699\ufe0f Configuration\r\nYou can configure your setup using an .env file to store your MohuanLED light\u2019s MAC address and UUID.\r\n\r\nCreate a .env file in the project directory with the following structure:\r\n\r\n```bash\r\nLED_MAC_ADDRESS=xx:xx:xx:xx:xx:xx\r\nLED_UUID=0000xxxx-0000-1000-8000-00805f9b34fb\r\n```\r\nThe library will automatically load these values when you instantiate the LEDs.\r\n\r\n### \ud83d\udee0\ufe0f Development\r\nIf you want to contribute or modify the project, you can set up the development environment as follows:\r\n\r\nClone the repository:\r\n\r\n```bash\r\ngit clone https://github.com/Walkercito/MohuanLED-Bluetooth_LED\r\n```\r\nInstall the dependencies:\r\n\r\n```bash\r\npip install -r requirements.txt\r\n```\r\n\r\n### \ud83d\udcdc License\r\nThis project is licensed under the MIT License. See the LICENSE file for more details.\r\n\r\n### Acknowledgments\r\n- Bleak: For Bluetooth Low Energy (BLE) device control \ud83d\udd17\r\n- PyQt6: For creating the graphical interface \ud83d\uddbc\ufe0f\r\n- asyncio: For asyncronus tasks\r\n- qasync: For handling asynchronous processes in PyQt6 \u26a1\r\n- python-dotenv: For auto-loading of LED_MAC_ADDRESS and LED_UUID in case of a `.env` file\r\n- nest_asyncio: For asyncio control\r\n",
"bugtrack_url": null,
"license": null,
"summary": "A library for controlling MohuanLED lights via Bluetooth",
"version": "0.3.1",
"project_urls": null,
"split_keywords": [],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "97e17ceeac7a5fd291f4d2c3207a4d719e0d205d46373ad15819aefa1952e1f1",
"md5": "3fe5a3890dc300484e757dabfc081417",
"sha256": "be7ff22a57e7b688dd1f9ecdeb27e3bce0481785dc5a35735bb62af93bebb819"
},
"downloads": -1,
"filename": "BlueLights-0.3.1-py3-none-any.whl",
"has_sig": false,
"md5_digest": "3fe5a3890dc300484e757dabfc081417",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": ">=3.8",
"size": 8571,
"upload_time": "2024-09-14T03:08:50",
"upload_time_iso_8601": "2024-09-14T03:08:50.880283Z",
"url": "https://files.pythonhosted.org/packages/97/e1/7ceeac7a5fd291f4d2c3207a4d719e0d205d46373ad15819aefa1952e1f1/BlueLights-0.3.1-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "f32251b9ea9fb9ab53b70838ece28cab22d052139d7e8625b180fa79be377e11",
"md5": "8d12363e6f6125695b8484b694de9ee8",
"sha256": "9841c3e8fdf4440eaa0a2e3127feb2a69f4a707fdce09f9b4572212690db5419"
},
"downloads": -1,
"filename": "bluelights-0.3.1.tar.gz",
"has_sig": false,
"md5_digest": "8d12363e6f6125695b8484b694de9ee8",
"packagetype": "sdist",
"python_version": "source",
"requires_python": ">=3.8",
"size": 8078,
"upload_time": "2024-09-14T03:08:52",
"upload_time_iso_8601": "2024-09-14T03:08:52.835200Z",
"url": "https://files.pythonhosted.org/packages/f3/22/51b9ea9fb9ab53b70838ece28cab22d052139d7e8625b180fa79be377e11/bluelights-0.3.1.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2024-09-14 03:08:52",
"github": false,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"lcname": "bluelights"
}