Skip to main content

Python library for controlling BLEDOM devices

This library is still in development. Functionality hasn't fully been tested yet. If you find bugs or "stub" messages, please create an issue.

Demo Program

This library comes with a demo program.

python -m bledom

API

Run API

You can let the library do the Bluetooth set up for you by creating a main function which the library will call after having set up the Bluetooth device.

from time import sleep
from bledom import BleLedDevice, run_sync

async def main(device: BleLedDevice):
    while True:
        sleep(2)
        await device.set_color(randint(0, 255),
                               randint(0, 255),
                               randint(0, 255))

run_sync(main)

Device API

Creating a device from with a BleakClient

Reading the Bleak documentation is recommended for connecting to a device manually.

A device connection can be created with a Bleak client. See main.py for an example.

device = BleLedDevice.new(client)

The device will be powered on and have it's time synced on when it gets connected.

Modes

  • device.power_on(self)
    Powers on the device
  • device.set_color(128, 64, 255)
    Sets a static colour
  • device.set_brightness(64)
    Sets a static brightness (0-100)
  • device.set_effect(Effects.CROSSFADE_RED_GREEN_BLUE)
    Sets an effect
  • device.set_effect_speed(64)
    Sets the effect speed

Time and Schedule

  • device.sync_time()
    Syncs the device to the system time. Gets called on connection.
  • device.set_custom_time(datetime.now())
    Syncs the device to the given datetime.
  • device.set_schedule_on(Days.TUESDAY | Days.THURSDAY, 7, 30, True)
    Schedules LED to turn on on Tuesday and Thursday at 7:30 AM. Set last argument to False to disable.
  • device.set_schedule_off(Days.ALL, 0, 0, True)
    Schedules LED to turn off everyday at midnight (12:00 AM). Set last argument to False to disable.

The Days enum has the days MONDAY through SUNDAY as well as WEEK_DAY (Monday through Friday), WEEKEND_DAYS (Saturday and Sunday) and ALL for all days.

Effects

For device.set_effect(...), the following effects are available:

  • Effects.JUMP_RED_GREEN_BLUE
  • Effects.JUMP_RED_GREEN_BLUE_YELLOW_CYAN_MAGENTA_WHITE
  • Effects.CROSSFADE_RED
  • Effects.CROSSFADE_GREEN
  • Effects.CROSSFADE_BLUE
  • Effects.CROSSFADE_YELLOW
  • Effects.CROSSFADE_CYAN
  • Effects.CROSSFADE_MAGENTA
  • Effects.CROSSFADE_WHITE
  • Effects.CROSSFADE_RED_GREEN
  • Effects.CROSSFADE_RED_BLUE
  • Effects.CROSSFADE_GREEN_BLUE
  • Effects.CROSSFADE_RED_GREEN_BLUE
  • Effects.CROSSFADE_RED_GREEN_BLUE_YELLOW_CYAN_MAGENTA_WHITE
  • Effects.BLINK_RED
  • Effects.BLINK_GREEN
  • Effects.BLINK_BLUE
  • Effects.BLINK_YELLOW
  • Effects.BLINK_CYAN
  • Effects.BLINK_MAGENTA
  • Effects.BLINK_WHITE
  • Effects.BLINK_RED_GREEN_BLUE_YELLOW_CYAN_MAGENTA_WHITE

Acknowledgements

This library is a port of a Rust library written by TheSylex.

Salutations to Joel.

Release files for bledom 0.0.9

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

Source distribution (sdist)

Source distribution for bledom 0.0.9
File Size Uploaded
bledom-0.0.9.tar.gz 7.8 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for bledom 0.0.9
File Interpreter ABI Platform
bledom-0.0.9-py3-none-any.whl Python 3 none any Details

Total release size: 15.2 kB

Release files / bledom-0.0.9.tar.gz

Download URL bledom-0.0.9.tar.gz
Size 7.8 kB
Tags Source
SHA-256 checksum
How to use checksums
42ea5086469a914ca4d17748f42348d6a18d9d84f3918ae82454030d7bb05fd0
BLAKE2b-256 checksum
How to use checksums
f695e98f16be918f802ee46879f2907376aa7a5c6de55d408731e727bdef3063
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.4.1 importlib_metadata/4.0.1 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.60.0 CPython/3.9.5

Release files / bledom-0.0.9-py3-none-any.whl

Download URL bledom-0.0.9-py3-none-any.whl
Size 7.4 kB
Tags Python 3
SHA-256 checksum
How to use checksums
5b743bcaf231e688d155c521d4bf6ab12e88c2730617b044424e5a79417af157
BLAKE2b-256 checksum
How to use checksums
c0c81716f97295d7acab56e29d08dffa81c213f9ce0060b9e7d6425f53668d9a
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.4.1 importlib_metadata/4.0.1 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.60.0 CPython/3.9.5

Release history Release notifications | RSS feed

This release

0.0.9 This release

2 release files

0.0.8

2 release files

0.0.7

2 release files

0.0.5

2 release files

0.0.3

2 release files

0.0.2

2 release files

0.0.1

2 release files

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