Async library to control Zerproc Bluetooth LED smart string lights
- Free software: Apache Software License 2.0
- Discover nearby devices
- Turn lights on and off
- Set light color
- Get light status
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
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()
- Fix test compatibility with bleak 0.20
- Unpin test dependencies
- Fix test compatibility with bleak 0.13
- Upgrade to bleak 0.11.0
- Include a default timeout on all remote calls
- Wrap all exceptions from upstream code
- Timeout for is_connected and reduce extra calls
- Fix bleak dependency called in setup.py
- Wrap exceptions from is_connected
- Refactor from pygatt to bleak for async interface
- Remove thread-based auto_reconnect
- Set full brightness to 0xFF to match vendor app
- Improve RGB edge cases
- Rethrow exceptions on device subscribe
- Fix imports
- Wrap upstream exceptions
- Expose exception objects
- Expose light address and name on discovery
- Expose auto reconnect
- Discover nearby devices
- Get the current light state
- Initial release
- 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.