=========
pyzerproc
=========
.. image:: https://img.shields.io/pypi/v/pyzerproc.svg
:target: https://pypi.python.org/pypi/pyzerproc
.. image:: https://github.com/emlove/pyzerproc/workflows/tests/badge.svg
:target: https://github.com/emlove/pyzerproc/actions
.. image:: https://coveralls.io/repos/emlove/pyzerproc/badge.svg
:target: https://coveralls.io/r/emlove/pyzerproc
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.
.. code-block:: console
$ 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
.. code-block:: python
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
.. code-block:: python
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
.. code-block:: python
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
.. code-block:: python
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)
~~~~~~~~~~~~~~~~~~
- Upgrade to `bleak 0.11.0 <https://github.com/hbldh/bleak/releases/tag/v0.11.0>`_
0.4.8 (2021-02-12)
~~~~~~~~~~~~~~~~~~
- Dependency cleanup `(#1) <https://github.com/emlove/pyzerproc/pull/1>`_ `(#3) <https://github.com/emlove/pyzerproc/issues/3>`_ `@fabaff <https://github.com/fabaff>`_
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
-------
- 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.
.. _`Uri Shaked`: https://medium.com/@urish
.. _`Reverse Engineering a Bluetooth Lightbulb`: https://medium.com/@urish/reverse-engineering-a-bluetooth-lightbulb-56580fcb7546
.. _Cookiecutter: https://github.com/audreyr/cookiecutter
.. _`audreyr/cookiecutter-pypackage`: https://github.com/audreyr/cookiecutter-pypackage
Raw data
{
"_id": null,
"home_page": "https://github.com/emlove/pyzerproc",
"name": "pyzerproc",
"maintainer": "",
"docs_url": null,
"requires_python": ">=3.6",
"maintainer_email": "",
"keywords": "pyzerproc",
"author": "Emily Love Mills",
"author_email": "emily@emlove.me",
"download_url": "https://files.pythonhosted.org/packages/37/1a/fe70219677822d06b7055f4779854ae238ccf287883d6fe42958f07cdf0f/pyzerproc-0.4.12.tar.gz",
"platform": null,
"description": "=========\npyzerproc\n=========\n\n\n.. image:: https://img.shields.io/pypi/v/pyzerproc.svg\n :target: https://pypi.python.org/pypi/pyzerproc\n\n.. image:: https://github.com/emlove/pyzerproc/workflows/tests/badge.svg\n :target: https://github.com/emlove/pyzerproc/actions\n\n.. image:: https://coveralls.io/repos/emlove/pyzerproc/badge.svg\n :target: https://coveralls.io/r/emlove/pyzerproc\n\n\nAsync library to control Zerproc Bluetooth LED smart string lights\n\n* Free software: Apache Software License 2.0\n\n\nFeatures\n--------\n\n* Discover nearby devices\n* Turn lights on and off\n* Set light color\n* Get light status\n\n\nCommand line usage\n------------------\npyzerproc ships with a command line tool that exposes the features of the library.\n\n.. code-block:: console\n\n $ pyzerproc discover\n INFO:pyzerproc.discovery:Starting scan for local devices\n INFO:pyzerproc.discovery:Discovered AA:BB:CC:00:11:22: LEDBlue-CC001122\n INFO:pyzerproc.discovery:Discovered AA:BB:CC:33:44:55: LEDBlue-CC334455\n INFO:pyzerproc.discovery:Scan complete\n AA:BB:CC:00:11:22\n AA:BB:CC:33:44:55\n\n $ pyzerproc turn-on AA:BB:CC:00:11:22\n INFO:pyzerproc.light:Connecting to AA:BB:CC:00:11:22\n INFO:pyzerproc.light:Turning on AA:BB:CC:00:11:22\n\n $ pyzerproc turn-off AA:BB:CC:00:11:22\n INFO:pyzerproc.light:Connecting to AA:BB:CC:00:11:22\n INFO:pyzerproc.light:Turning off AA:BB:CC:00:11:22\n\n $ pyzerproc set-color AA:BB:CC:00:11:22 ff0000\n INFO:pyzerproc.light:Connecting to AA:BB:CC:00:11:22\n INFO:pyzerproc.light:Changing color of AA:BB:CC:00:11:22 to #ff0000\n\n $ pyzerproc set-color AA:BB:CC:00:11:22 00ff00\n INFO:pyzerproc.light:Connecting to AA:BB:CC:00:11:22\n INFO:pyzerproc.light:Changing color of AA:BB:CC:00:11:22 to #00ff00\n\n $ pyzerproc is-on AA:BB:CC:00:11:22\n INFO:pyzerproc.light:Connecting to AA:BB:CC:00:11:22\n INFO:pyzerproc.light:Got state of AA:BB:CC:00:11:22: <LightState is_on='True' color='(255, 0, 0)'>\n True\n\n $ pyzerproc get-color AA:BB:CC:00:11:22\n INFO:pyzerproc.light:Connecting to AA:BB:CC:00:11:22\n INFO:pyzerproc.light:Got state of AA:BB:CC:00:11:22: <LightState is_on='True' color='(255, 0, 0)'>\n ff0000\n\n\nUsage\n-----\n\nDiscover nearby devices\n\n.. code-block:: python\n\n import asyncio\n import pyzerproc\n\n\n async def main():\n lights = await pyzerproc.discover(timeout=30)\n\n for light in lights:\n print(\"Address: {} Name: {}\".format(light.address, light.name))\n\n asyncio.get_event_loop().run_until_complete(main())\n\n\nTurn a light on and off\n\n.. code-block:: python\n\n import asyncio\n import pyzerproc\n\n\n async def main():\n address = \"AA:BB:CC:00:11:22\"\n\n light = pyzerproc.Light(address)\n\n try:\n await light.connect()\n await light.turn_on()\n\n await asyncio.sleep(5)\n\n await light.turn_off()\n finally:\n await light.disconnect()\n\n asyncio.get_event_loop().run_until_complete(main())\n\n\nChange the light color\n\n.. code-block:: python\n\n import asyncio\n import pyzerproc\n\n\n async def main():\n address = \"AA:BB:CC:00:11:22\"\n\n light = pyzerproc.Light(address)\n\n try:\n await light.connect()\n\n while True:\n await light.set_color(255, 0, 0) # Red\n await asyncio.sleep(1)\n await light.set_color(0, 255, 0) # Green\n await asyncio.sleep(1)\n finally:\n await light.disconnect()\n\n asyncio.get_event_loop().run_until_complete(main())\n\n\nGet the light state\n\n.. code-block:: python\n\n import asyncio\n import pyzerproc\n\n\n async def main():\n address = \"AA:BB:CC:00:11:22\"\n\n light = pyzerproc.Light(address)\n\n try:\n await light.connect()\n\n state = await light.get_state()\n\n if state.is_on:\n print(state.color)\n else:\n print(\"Off\")\n finally:\n await light.disconnect()\n\n\nChangelog\n---------\n0.4.12 (2023-04-07)\n~~~~~~~~~~~~~~~~~~~\n- Fix test compatibility with bleak 0.20\n\n0.4.11 (2022-05-03)\n~~~~~~~~~~~~~~~~~~~\n- Unpin test dependencies\n\n0.4.10 (2021-11-23)\n~~~~~~~~~~~~~~~~~~~\n- Fix test compatibility with bleak 0.13\n\n0.4.9 (2021-03-28)\n~~~~~~~~~~~~~~~~~~\n- Upgrade to `bleak 0.11.0 <https://github.com/hbldh/bleak/releases/tag/v0.11.0>`_\n\n0.4.8 (2021-02-12)\n~~~~~~~~~~~~~~~~~~\n- Dependency cleanup `(#1) <https://github.com/emlove/pyzerproc/pull/1>`_ `(#3) <https://github.com/emlove/pyzerproc/issues/3>`_ `@fabaff <https://github.com/fabaff>`_\n\n0.4.7 (2020-12-20)\n~~~~~~~~~~~~~~~~~~\n- Include a default timeout on all remote calls\n\n0.4.5 (2020-12-20)\n~~~~~~~~~~~~~~~~~~\n- Wrap all exceptions from upstream code\n\n0.4.4 (2020-12-19)\n~~~~~~~~~~~~~~~~~~\n- Timeout for is_connected and reduce extra calls\n\n0.4.3 (2020-12-17)\n~~~~~~~~~~~~~~~~~~\n- Fix bleak dependency called in setup.py\n\n0.4.1 (2020-12-17)\n~~~~~~~~~~~~~~~~~~\n- Wrap exceptions from is_connected\n\n0.4.0 (2020-12-17)\n~~~~~~~~~~~~~~~~~~\n- Refactor from pygatt to bleak for async interface\n\n0.3.0 (2020-12-03)\n~~~~~~~~~~~~~~~~~~\n- Remove thread-based auto_reconnect\n\n0.2.5 (2020-06-24)\n~~~~~~~~~~~~~~~~~~\n- Set full brightness to 0xFF to match vendor app\n\n0.2.4 (2020-05-09)\n~~~~~~~~~~~~~~~~~~\n- Improve RGB edge cases\n\n0.2.3 (2020-05-09)\n~~~~~~~~~~~~~~~~~~\n- Rethrow exceptions on device subscribe\n\n0.2.2 (2020-05-09)\n~~~~~~~~~~~~~~~~~~\n- Fix imports\n\n0.2.1 (2020-05-09)\n~~~~~~~~~~~~~~~~~~\n- Wrap upstream exceptions\n\n0.2.0 (2020-05-09)\n~~~~~~~~~~~~~~~~~~\n- Expose exception objects\n- Expose light address and name on discovery\n\n0.1.1 (2020-05-08)\n~~~~~~~~~~~~~~~~~~\n- Expose auto reconnect\n\n0.1.0 (2020-05-07)\n~~~~~~~~~~~~~~~~~~\n- Discover nearby devices\n\n0.0.2 (2020-05-05)\n~~~~~~~~~~~~~~~~~~\n- Get the current light state\n\n0.0.1 (2020-05-04)\n~~~~~~~~~~~~~~~~~~\n- Initial release\n\n\nCredits\n-------\n\n- Thanks to `Uri Shaked`_ for an incredible guide to `Reverse Engineering a Bluetooth Lightbulb`_.\n\n- This package was created with Cookiecutter_ and the `audreyr/cookiecutter-pypackage`_ project template.\n\n.. _`Uri Shaked`: https://medium.com/@urish\n.. _`Reverse Engineering a Bluetooth Lightbulb`: https://medium.com/@urish/reverse-engineering-a-bluetooth-lightbulb-56580fcb7546\n.. _Cookiecutter: https://github.com/audreyr/cookiecutter\n.. _`audreyr/cookiecutter-pypackage`: https://github.com/audreyr/cookiecutter-pypackage\n\n\n",
"bugtrack_url": null,
"license": "Apache Software License 2.0",
"summary": "Async library to control Zerproc Bluetooth LED smart string lights",
"version": "0.4.12",
"split_keywords": [
"pyzerproc"
],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "371afe70219677822d06b7055f4779854ae238ccf287883d6fe42958f07cdf0f",
"md5": "260a3ad29adec2a8e28cbb0c2a78151b",
"sha256": "b6c82e3112cad542222f1c590f3eef38c0c6583b7fc749f2b35f3795a9cc384a"
},
"downloads": -1,
"filename": "pyzerproc-0.4.12.tar.gz",
"has_sig": false,
"md5_digest": "260a3ad29adec2a8e28cbb0c2a78151b",
"packagetype": "sdist",
"python_version": "source",
"requires_python": ">=3.6",
"size": 11943,
"upload_time": "2023-04-07T17:14:53",
"upload_time_iso_8601": "2023-04-07T17:14:53.021664Z",
"url": "https://files.pythonhosted.org/packages/37/1a/fe70219677822d06b7055f4779854ae238ccf287883d6fe42958f07cdf0f/pyzerproc-0.4.12.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2023-04-07 17:14:53",
"github": true,
"gitlab": false,
"bitbucket": false,
"github_user": "emlove",
"github_project": "pyzerproc",
"travis_ci": false,
"coveralls": true,
"github_actions": true,
"tox": true,
"lcname": "pyzerproc"
}