Library to control Zerproc Bluetooth LED smart string lights
Project description
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 pyzerproc
lights = pyzerproc.discover(timeout=30)
for light in lights:
print("Address: {} Name: {}".format(light.address, light.name))
Turn a light on and off
import pyzerproc
import time
address = "AA:BB:CC:00:11:22"
light = pyzerproc.Light(address)
try:
light.connect(auto_reconnect=True)
light.turn_on()
time.sleep(5)
light.turn_off()
finally:
light.disconnect()
Change the light color
import pyzerproc
import time
address = "AA:BB:CC:00:11:22"
light = pyzerproc.Light(address)
try:
light.connect()
while True:
light.set_color(255, 0, 0) # Red
time.sleep(1)
light.set_color(0, 255, 0) # Green
time.sleep(1)
finally:
light.disconnect()
Get the light state
import pyzerproc
import time
address = "AA:BB:CC:00:11:22"
light = pyzerproc.Light(address)
try:
light.connect()
state = light.get_state()
if state.is_on:
print(state.color)
else:
print("Off")
finally:
light.disconnect()
Changelog
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
Thanks to Uri Shaked for an incredible guide to Reverse Engineering a Bluetooth Lightbulb.
This package was created with Cookiecutter and the audreyr/cookiecutter-pypackage project template.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
File details
Details for the file pyzerproc-0.2.3.tar.gz.
File metadata
- Download URL: pyzerproc-0.2.3.tar.gz
- Upload date:
- Size: 12.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/1.14.0 pkginfo/1.5.0.1 requests/2.23.0 setuptools/46.1.3 requests-toolbelt/0.9.1 tqdm/4.46.0 CPython/3.6.10
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
c7f2724f177bcc2476346a582b2c6775dc5521248957976eb92096a1999fcf4c
|
|
| MD5 |
b0bf2c96ad077db31cd3c710443b4c21
|
|
| BLAKE2b-256 |
cbde5bf4537c7b8af969dbb8155bc3ff1595af8b840143cca3e78c50369a133a
|