Skip to main content

Introduction

Documentation Status Discord Build Status Code Style: Ruff

BLE service for Magic Light BLE RGB bulbs. Available from Amazon here.

Dependencies

This driver depends on:

Please ensure all dependencies are available on the CircuitPython filesystem. This is easily achieved by downloading the Adafruit library and driver bundle.

Installing from PyPI

On supported GNU/Linux systems like the Raspberry Pi, you can install the driver locally from PyPI. To install for current user:

pip3 install adafruit-circuitpython-ble-magic-light

To install system-wide (this may be required in some cases):

sudo pip3 install adafruit-circuitpython-ble-magic-light

To install in a virtual environment in your current project:

mkdir project-name && cd project-name
python3 -m venv .venv
source .venv/bin/activate
pip3 install adafruit-circuitpython-ble-magic-light

Usage Example

"""This demo connects to a magic light and has it do a colorwheel."""
import adafruit_ble
import _bleio

from adafruit_ble.advertising.standard import ProvideServicesAdvertisement
from adafruit_ble_magic_light import MagicLightService

# CircuitPython <6 uses its own ConnectionError type. So, is it if available. Otherwise,
# the built in ConnectionError is used.
connection_error = ConnectionError
if hasattr(_bleio, "ConnectionError"):
    connection_error = _bleio.ConnectionError

def find_connection():
    for connection in radio.connections:
        if MagicLightService not in connection:
            continue
        return connection, connection[MagicLightService]
    return None, None

# Start advertising before messing with the display so that we can connect immediately.
radio = adafruit_ble.BLERadio()

active_connection, pixels = find_connection()
current_notification = None
app_icon_file = None
while True:
    if not active_connection:
        print("Scanning for Magic Light")
        for scan in radio.start_scan(ProvideServicesAdvertisement):
            if MagicLightService in scan.services:
                active_connection = radio.connect(scan)
                try:
                    pixels = active_connection[MagicLightService]
                except connection_error:
                    print("disconnected")
                    continue
                break
        radio.stop_scan()

    i = 0
    while active_connection.connected:
        pixels[0] = colorwheel(i % 256)
        i += 1

    active_connection = None

Documentation

API documentation for this library can be found on Read the Docs.

For information on building library documentation, please check out this guide.

Contributing

Contributions are welcome! Please read our Code of Conduct before contributing to help this project stay welcoming.

Metadata

Release files for adafruit-circuitpython-ble-magic-light 0.9.27

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for adafruit-circuitpython-ble-magic-light 0.9.27
File Size Uploaded
adafruit_circuitpython_ble_magic_light-0.9.27.tar.gz 23.3 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for adafruit-circuitpython-ble-magic-light 0.9.27
File Interpreter ABI Platform
adafruit_circuitpython_ble_magic_light-0.9.27-py3-none-any.whl Python 3 none any Details

Total release size: 28.6 kB

Release files / adafruit_circuitpython_ble_magic_light-0.9.27.tar.gz

Download URL adafruit_circuitpython_ble_magic_light-0.9.27.tar.gz
Size 23.3 kB
Tags Source
SHA-256 checksum
How to use checksums
f929be3ea59be7f84f997063cd62a5dd99662955f5e20b71a88a8554823ccc55
BLAKE2b-256 checksum
How to use checksums
5117177e3ffdf4b1b31a80049e438f5869a4b61142f30bca112095243d237116
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.11.15

Release files / adafruit_circuitpython_ble_magic_light-0.9.27-py3-none-any.whl

Download URL adafruit_circuitpython_ble_magic_light-0.9.27-py3-none-any.whl
Size 5.2 kB
Tags Python 3
SHA-256 checksum
How to use checksums
71d62a8bd1ee29a298b6ff449767abdf5e1a915e7a89c7d6aa4c8559c04a4ab9
BLAKE2b-256 checksum
How to use checksums
20833a3867a7bcd6e4c9c2c256eb05a8c1aa551ecef0946052efbad0111d5f1a
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.11.15

Release history Release notifications | RSS feed

This release

0.9.27 This release

2 release files

0.9.26

2 release files

0.9.25

2 release files

0.9.24

2 release files

0.9.23

2 release files

0.9.22

2 release files

0.9.19

2 release files

0.9.18

2 release files

0.9.17

2 release files

0.9.16

2 release files

0.9.15

2 release files

0.9.13

1 release file

0.9.12

1 release file

0.9.11

1 release file

0.9.10

1 release file

0.9.9

1 release file

0.9.8

1 release file

0.9.7

1 release file

0.9.6

1 release file

0.9.5

1 release file

0.9.4

1 release file

0.9.3

1 release file

0.9.2

1 release file

0.9.1

1 release file

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page