Skip to main content
https://img.shields.io/pypi/v/pyzerproc.svg https://github.com/emlove/pyzerproc/workflows/tests/badge.svg https://coveralls.io/repos/emlove/pyzerproc/badge.svg

Async library to control Zerproc Bluetooth LED smart string lights

  • Free software: Apache Software License 2.0

Features

  • Discover nearby devices

  • Turn lights on and off

  • Set light color

  • Get light status

Command line usage

pyzerproc ships with a command line tool that exposes the features of the library.

$ pyzerproc discover
INFO:pyzerproc.discovery:Starting scan for local devices
INFO:pyzerproc.discovery:Discovered AA:BB:CC:00:11:22: LEDBlue-CC001122
INFO:pyzerproc.discovery:Discovered AA:BB:CC:33:44:55: LEDBlue-CC334455
INFO:pyzerproc.discovery:Scan complete
AA:BB:CC:00:11:22
AA:BB:CC:33:44:55

$ pyzerproc turn-on AA:BB:CC:00:11:22
INFO:pyzerproc.light:Connecting to AA:BB:CC:00:11:22
INFO:pyzerproc.light:Turning on AA:BB:CC:00:11:22

$ pyzerproc turn-off AA:BB:CC:00:11:22
INFO:pyzerproc.light:Connecting to AA:BB:CC:00:11:22
INFO:pyzerproc.light:Turning off AA:BB:CC:00:11:22

$ pyzerproc set-color AA:BB:CC:00:11:22 ff0000
INFO:pyzerproc.light:Connecting to AA:BB:CC:00:11:22
INFO:pyzerproc.light:Changing color of AA:BB:CC:00:11:22 to #ff0000

$ pyzerproc set-color AA:BB:CC:00:11:22 00ff00
INFO:pyzerproc.light:Connecting to AA:BB:CC:00:11:22
INFO:pyzerproc.light:Changing color of AA:BB:CC:00:11:22 to #00ff00

$ pyzerproc is-on AA:BB:CC:00:11:22
INFO:pyzerproc.light:Connecting to AA:BB:CC:00:11:22
INFO:pyzerproc.light:Got state of AA:BB:CC:00:11:22: <LightState is_on='True' color='(255, 0, 0)'>
True

$ pyzerproc get-color AA:BB:CC:00:11:22
INFO:pyzerproc.light:Connecting to AA:BB:CC:00:11:22
INFO:pyzerproc.light:Got state of AA:BB:CC:00:11:22: <LightState is_on='True' color='(255, 0, 0)'>
ff0000

Usage

Discover nearby devices

import asyncio
import pyzerproc


async def main():
    lights = await pyzerproc.discover(timeout=30)

    for light in lights:
        print("Address: {} Name: {}".format(light.address, light.name))

asyncio.get_event_loop().run_until_complete(main())

Turn a light on and off

import asyncio
import pyzerproc


async def main():
    address = "AA:BB:CC:00:11:22"

    light = pyzerproc.Light(address)

    try:
        await light.connect()
        await light.turn_on()

        await asyncio.sleep(5)

        await light.turn_off()
    finally:
        await light.disconnect()

asyncio.get_event_loop().run_until_complete(main())

Change the light color

import asyncio
import pyzerproc


async def main():
    address = "AA:BB:CC:00:11:22"

    light = pyzerproc.Light(address)

    try:
        await light.connect()

        while True:
            await light.set_color(255, 0, 0) # Red
            await asyncio.sleep(1)
            await light.set_color(0, 255, 0) # Green
            await asyncio.sleep(1)
    finally:
        await light.disconnect()

asyncio.get_event_loop().run_until_complete(main())

Get the light state

import asyncio
import pyzerproc


async def main():
    address = "AA:BB:CC:00:11:22"

    light = pyzerproc.Light(address)

    try:
        await light.connect()

        state = await light.get_state()

        if state.is_on:
            print(state.color)
        else:
            print("Off")
    finally:
        await light.disconnect()

Changelog

0.4.12 (2023-04-07)

  • Fix test compatibility with bleak 0.20

0.4.11 (2022-05-03)

  • Unpin test dependencies

0.4.10 (2021-11-23)

  • Fix test compatibility with bleak 0.13

0.4.9 (2021-03-28)

0.4.8 (2021-02-12)

0.4.7 (2020-12-20)

  • Include a default timeout on all remote calls

0.4.5 (2020-12-20)

  • Wrap all exceptions from upstream code

0.4.4 (2020-12-19)

  • Timeout for is_connected and reduce extra calls

0.4.3 (2020-12-17)

  • Fix bleak dependency called in setup.py

0.4.1 (2020-12-17)

  • Wrap exceptions from is_connected

0.4.0 (2020-12-17)

  • Refactor from pygatt to bleak for async interface

0.3.0 (2020-12-03)

  • Remove thread-based auto_reconnect

0.2.5 (2020-06-24)

  • Set full brightness to 0xFF to match vendor app

0.2.4 (2020-05-09)

  • Improve RGB edge cases

0.2.3 (2020-05-09)

  • Rethrow exceptions on device subscribe

0.2.2 (2020-05-09)

  • Fix imports

0.2.1 (2020-05-09)

  • Wrap upstream exceptions

0.2.0 (2020-05-09)

  • Expose exception objects

  • Expose light address and name on discovery

0.1.1 (2020-05-08)

  • Expose auto reconnect

0.1.0 (2020-05-07)

  • Discover nearby devices

0.0.2 (2020-05-05)

  • Get the current light state

0.0.1 (2020-05-04)

  • Initial release

Credits

Metadata

Release files for pyzerproc 0.4.12

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

Source distribution (sdist)

Source distribution for pyzerproc 0.4.12
File Size Uploaded
pyzerproc-0.4.12.tar.gz 11.9 kB Details

Release files / pyzerproc-0.4.12.tar.gz

Download URL pyzerproc-0.4.12.tar.gz
Size 11.9 kB
Tags Source
SHA-256 checksum
How to use checksums
b6c82e3112cad542222f1c590f3eef38c0c6583b7fc749f2b35f3795a9cc384a
BLAKE2b-256 checksum
How to use checksums
371afe70219677822d06b7055f4779854ae238ccf287883d6fe42958f07cdf0f
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/1.14.0 pkginfo/1.8.1 requests/2.26.0 setuptools/58.3.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.9.13

Release history Release notifications | RSS feed

This release

0.4.12 This release

1 release file

0.4.11

1 release file

0.4.10

1 release file

0.4.9

1 release file

0.4.8

1 release file

0.4.7

1 release file

0.4.6

1 release file

0.4.5

1 release file

0.4.4

1 release file

0.4.3

1 release file

0.4.2

1 release file

0.4.1

1 release file

0.4.0

1 release file

0.3.0

1 release file

0.2.5

1 release file

0.2.4

1 release file

0.2.3

1 release file

0.2.2

1 release file

0.2.1

1 release file

0.2.0

1 release file

0.1.1

1 release file

0.1.0

1 release file

0.0.2

1 release file

0.0.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