GithubHelp home page GithubHelp logo

sp110e's Introduction

SP110E Python Library

Control SP110E BLE RGB LED device from computer

Install

pip install sp110e

Tools

  • Controller: High-level SP110E asynchronous controller. Use it only in asynchronous environment (with asyncio)
  • ControllerSync: Synchronous adapter for high-level SP110E asynchronous controller. Handy tool to use from Python shell or synchronous (normal) environment
  • Driver: Low-level SP110E asynchronous BLE driver based on bleak library. Use it only if you know why

Documentation

Full API Reference

Examples

Quick start:

from sp110e.controller_sync import ControllerSync

device = ControllerSync('AF:00:10:01:C8:AF')
device.switch_on()
device.set_color([255, 0, 0])
device.set_brightness(255)

More examples

Development

Create new release

Push changes to 'main' branch following Conventional Commits.

Update documentation

docs folder is being updated automatically by GitHub Actions when source files are changed.

Integrations

Useful links

⭐️ Show your support

Give a star if this project helped you.

sp110e's People

Contributors

actions-user avatar roslovets avatar semantic-release-bot avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

sp110e's Issues

Connecting to device not working?

I'm not too good at python and only have a pretty basic understanding of it and this might be a dumb question but when I try to connect to my device if comes up with this error:

Traceback (most recent call last):
  File "c:\Users\samet\Downloads\Python Scripts\LED\test.py", line 8, in main
    await device.connect('7F:00:00:04:3C:7F')
  File "C:\Users\samet\AppData\Local\Programs\Python\Python310\lib\site-packages\sp110e\driver.py", line 46, in connect
    await self._client.connect()
  File "C:\Users\samet\AppData\Local\Programs\Python\Python310\lib\site-packages\bleak\backends\winrt\client.py", line 257, in connect
    await self.get_services()
  File "C:\Users\samet\AppData\Local\Programs\Python\Python310\lib\site-packages\bleak\backends\winrt\client.py", line 426, in get_services
    await self._requester.get_gatt_services_async(
asyncio.exceptions.CancelledError

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "c:\Users\samet\Downloads\Python Scripts\LED\test.py", line 25, in <module>
    asyncio.run(main())
  File "C:\Users\samet\AppData\Local\Programs\Python\Python310\lib\asyncio\runners.py", line 44, in run
    return loop.run_until_complete(main)
  File "C:\Users\samet\AppData\Local\Programs\Python\Python310\lib\asyncio\base_events.py", line 646, in run_until_complete
    return future.result()
asyncio.exceptions.CancelledError

My code is only one of the example codes and the app on my phone works fine

Code:

from sp110e.controller_sync import ControllerSync

device = ControllerSync('7F:00:00:04:3C:7F', timeout=2, retries=1)
device.connect()
device.print_parameters()
device.switch_on()
device.set_brightness(255)
device.switch_off()
device.disconnect()

Please reply :)

SP107E support

Many thanks for your work!

Should your lib work with SP107E? Believe, it should be quite similar to SP110E.
SP107E is controlled with LED Chord application. Here are some photos - https://mysku.club/blog/aliexpress/77266.html:

The following code taken from the Bleak page returns nothing (I test from Mac).

import asyncio
from bleak import BleakScanner

async def main():
    devices = await BleakScanner.discover()
    for d in devices:
        print(d)

asyncio.run(main())

But nRF connect apps installed on my android phone sees the device.

the change of brightness, color, and connection does not work

from sp110e.controller_sync import ControllerSync

devices = ControllerSync.discover(ControllerSync)
print(devices)
mac = devices[0]['SP110E']

device = ControllerSync(mac, timeout=2, retries=1)

device.print_parameters()

device.switch_on()
device.set_brightness(255)
device.set_color(255,0,0)
device.print_parameters()

result:

[{'SP110E': '97:79:0D:19:5F:81'}]
state : False
mode : 0
speed : 0
brightness : 0
ic_model : SM16703
sequence : RGB
pixels : 0
color : [0, 0, 0]
white : 0
Traceback (most recent call last):
  File "C:\Users\Администратор\Desktop\ворки\controller_led_lib_test\lib\site-packages\sp110e\controller.py", line 208, in _connect_with_retries
    await self._driver.connect(self._mac, timeout=self._timeout)
  File "C:\Users\Администратор\Desktop\ворки\controller_led_lib_test\lib\site-packages\sp110e\driver.py", line 47, in connect
    await self._client.start_notify(self.CHARACTERISTIC, self._callback_handler)
  File "C:\Users\Администратор\Desktop\ворки\controller_led_lib_test\lib\site-packages\bleak\__init__.py", line 717, in start_notify
    await self._backend.start_notify(characteristic, wrapped_callback, **kwargs)
  File "C:\Users\Администратор\Desktop\ворки\controller_led_lib_test\lib\site-packages\bleak\backends\winrt\client.py", line 951, in start_notify
    await winrt_char.write_client_characteristic_configuration_descriptor_async(
OSError: [WinError -2147418113] Разрушительный сбой

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "C:\Users\Администратор\Desktop\ворки\controller_led_lib_test\Lib\run.py", line 11, in <module>
    device.switch_on()
  File "C:\Users\Администратор\Desktop\ворки\controller_led_lib_test\lib\site-packages\syncer.py", line 44, in run
    return asyncio.get_event_loop().run_until_complete(f(*args, **kwargs))
  File "C:\Users\Администратор\AppData\Local\Programs\Python\Python310\lib\asyncio\base_events.py", line 646, in run_until_complete
    return future.result()
  File "C:\Users\Администратор\Desktop\ворки\controller_led_lib_test\lib\site-packages\sp110e\controller_sync.py", line 41, in switch_on
    await super().switch_on()
  File "C:\Users\Администратор\Desktop\ворки\controller_led_lib_test\lib\site-packages\sp110e\controller.py", line 46, in switch_on
    await self.set_state(True, force=force)
  File "C:\Users\Администратор\Desktop\ворки\controller_led_lib_test\lib\site-packages\sp110e\controller.py", line 77, in set_state
    await self._connect_and_write_parameters({'state': state}, force=force)
  File "C:\Users\Администратор\Desktop\ворки\controller_led_lib_test\lib\site-packages\sp110e\controller.py", line 221, in _connect_and_write_parameters
    await self._connect_with_retries()
  File "C:\Users\Администратор\Desktop\ворки\controller_led_lib_test\lib\site-packages\sp110e\controller.py", line 211, in _connect_with_retries
    raise Exception
Exception

how can i fix it

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.