Package: xled
XLED - unofficial control of Twinkly - Smart Decoration LED lightsXLED is a python library and command line interface (CLI) to controlTwinkly- Smart Decoration LED lights for Christmas.Official materials says:Twinkly is a LED light device that you can control via smartphone. It
allows you to play with colouful and animated effects, or create new ones.
Decoration lights, not suitable for household illumination.Since itsKickstarter projectin 2016 many products were introduced with
varying properties and features. Most notably products released since September
2019 are identified as Generation II. Older products are since then referred as
Generation I.Library and CLI are free software available under MIT license.InstallationBoth library and CLI tool are supported on Linux, primarily Fedora.First make sure that you havepip installed. E.g. for Fedora:$ sudo dnf install python3-pip python3-wheelYou might want tocreate and activate a virtual environment. E.g.:$ mkdir -p ~/.virtualenvs
$ python3 -m venv ~/.virtualenvs/xled
$ source ~/.virtualenvs/xled/bin/activateInstallxled from PyPI:$ python3 -m pip install --upgrade xledUsageIf you have installed the project into virtual environment, activate it first. E.g.$ source ~/.virtualenvs/xled/bin/activateUse of the library:>>>importxled>>>discovered_device=xled.discover.discover()>>>discovered_device.id'Twinkly_33AAFF'>>>control=xled.ControlInterface(discovered_device.ip_address,discovered_device.hw_address)>>>control.set_mode('movie')<ApplicationResponse[1000]>>>>control.get_mode()['mode']'movie'>>>control.get_device_info()['number_of_led']210Documentation for the library can be found online.Use of the CLI:$xledonLooking for any device...
Working on device: Twinkly_33AAFF
Turned on.For more commands and options seexled –help.Why?My first Twinkly was 105 LEDs starter light set. That was the latest available
model in 2017: TW105S-EU. As of December 2017 there are only two ways to
control lights: mobile app on Android or iOS or hardware button on the cord.Android application didn’t work as advertised on my Xiaomi Redmi 3S phone. On
first start it connected and disconnected in very fast pace (like every 1-2
seconds) to the hardware. I wasn’t able to control anything at all. Later I
wanted to connect it to my local WiFi network. But popup dialog that shouldn’t
have appear never did so.Public API waspromised around Christmas 2016for next season. Later update
from October 2016 it seemsAPI won’t be available any time soon:API for external control are on our dev check list, we definitely need some
feedback from the community to understand which could be a proper core set
to start with.It turned out that application uses HTTP to control lights. I ended up with
capturing network traffic anddocumented this private API. In the end I’m
able to configure the device pretty easilly.As of 2020 Twinkly devices can be controlled by Amazon Alexa and Google
Assistant as well. Mobile application now requires an account to operate lights
even locally. No sign of public API for local devices though. Therefore with my
second device - Twinkly 210 RGB+W Wall I keep improving this library and CLI
documentation to be able to operate my devices locally and not rely on
availability of manufacturer’s servers.ReferencesUnofficial documentation of private protocol and API isavailable online.There are other projects that might be more suitable for your needs:Twinkly integration in Home AssistantSmartThings:Twinkly integration in SmartThings by StevenJonSmithTwinkly integration in SmartThings by Dameon87TwinklyTree Bindingfor openHABTwinkly HomeKit Hub for Mongoose OSusingTwinkly library for Mongoose OSTwinklyWPF- .net 5 GUI and API libraryioBroker.twinkly- twinkly adapter for ioBroker to communicate with the Twinkly lightsTwinkly.vb for HomeSeerthingzi-logic-twinkly- Twinkly lights integration for node redPython class to interact with generation I device and IDA Pro loader of firmware binary inTwinkly Twinkly Little Star by F-Secure LABS.CreditsThis package was created withCookiecutterand theaudreyr/cookiecutter-pypackageproject template.History0.7.0 (2021-11-28)Major changes:Add realtime UDP protocol including unit testsAdd several missing rest calls in ControlInterfaceUnit test all methods in ControlInterfaceOther bugfixes and improvements:Provide a short guide how to install packages from PyPIProvidepython_requiresin setup.pyAdd project URLs to metadataCorrected import of security, and removed some old commentsMake encrypt_wifi_password work also with python3More flexible parameters to set_mqtt_configEnable options in set_network_mode_ap and _stationEnable relative values in set_brightnessMake firmware_update compatible with Generation IIFix error inpython setup.py install(fix #82)Use generic Exception in discover moduleOn Python 2.7 ignore VCR deprecation warningOn Python 2.7 ignore cryptography deprecation warningFix dependencies for python 2.7Don’t debug log reapped devicesTime format as hardcoded value instead of locale specificRaise an exception with a error message firmware update failedGet MAC address from gestalt API callAlways UTF-8 decode response from JOINED event in discoveryLog instead of print in discovery interface and return on unknown eventIf hw_address wasn’t possible to resolve don’t use None as a peerConfigure all loggers used by CLI with cli_log.basic_config()Make response assertions less strictReformat setup py so tox tests passDocumentation updates:Update example in README to use reflect change in APIAdd Gitter badgeUpdate of xled and xled-docs should be done hand in handRemove Enhancement section from Contributing as there is no such thingWrite down support for OS, devices, python and guide to CLIRewrite README fileFix documentation for set_led_movie_configChanges in CI/CD:Run linters as GitHub actionUse generic python3 in black pre-commit configConfigure pytest to collect tests only from tests/Use GitHub action for PyPI publishUpdate URL for CI from Travis to GitHub actionsOne more place to update supported python versionsMake Travis environment python againRemove non-deploy section from travis.ymlFix typo in travis.yml dep installIgnore Flake8 error on Sphinx configuration fileRun pytest directly from ToxAdd bug report template for GitHub issues and reference itSwitch to token authentication for deployment to pypi through TravisChanges in dependencies and python versions:Add 3.10 to supported Python versionsUpdate coverage from 4.4.2 to 5.5Update pip from 20.2.3 to 21.1Update travis.yaml: remove python 3.5 and add 3.8 and 3.9Add 3.9 to supported Python versionsDrop Python 3.5 supportDrop compatibility code for Python version 3.4Add Python 3.8 as a supported languageUpdate pip from 19.0.3 to 20.2.3Update sphinx from 1.6.5 to 3.0.40.6.1 (2020-01-17)Make tests with tox pass again so release can be automatically deployed:Add Black reformatter to tox linter envsTox config: new linters env to run Flake8Tox config update: Flake8 against tests/ and setup.py as wellMake xled.compat pass Flake8 for F821 undefined namesRefactor beacon processing of seen/new peer into separate methodsReformat test_control test with blackMake tox install test-only requiresUse conditional deployment to pypi with travis only from master0.6.0 (2020-01-15)Drop support for python 3.4Explicitly specify Linux as only operating systemAutomatically refresh token if expiredAdd brightness managementCheck response is OK before trying to decode JSON from bodyUse id instead of name in discoveryDevice class representing the deviceGet network status in control interfaceUse response from alive device to check if we reached discover timeoutProvide generator xdiscover() to return all or specific devicesSupport timeout for discoveryWhen agent stops stop ping task and processing responsesProvide close() for UDPClient and use it on DiscoveryInterface.stop()Do not continue receiving more data if UDP recv timeoutsOther bugfixes and improvements:Fix assertionsExpose HighControlInterface on package levelIf ApplicationError is raised, store value of response attributeAllow disable/enable of brightness without value changeUpdate wheel from 0.30.0 to 0.33.1Update pip from 9.0.1 to 19.0.3Add python 3.6 and 3.7 to Travis config0.5.0 (2018-12-09)CLI to update firmwareExample of library call and CLI usageOption to select device by hostname in CLI and ping in discoveryNew HighControlInterface() to aggregate and abstract low-level callsCLI and HighControlInterface way to set static single colorOther bugfixes and improvements:Fix typo in CLI error messagePrint message before discovery on CLIRefactor: join consecutive strings on same linePrint better message after device has been discovered over CLIRegenerate documentation index of a packageFix typo in control.set_mode() documentationReturn named tuple in discover.discover()Use discovery and named tuple in example of library useDo not assert return value in ControlInterface.set_led_movie_full()Return ApplicationResponse for ControlInterface.set_led_movie_config()Return ApplicationResponse for control.ControlInterface.led_reset()Remove unneeded debug message from DiscoveryInterface.__init__()0.4.0 (2018-12-03)Support Python 3.6 and 3.7 including tests and documentationPython 3 support with pyzmq >= 17.0 and Tornado 5Remove redundant udplibOther Python 3 compatibility:In Python 3+ import Mapping from collections.abcPython 3 compatible encoding of discovered IP and HW address and nameMake xled.security.xor_strings() compatible with Python 2 and 3Treat PING_MESSAGE as bytes to simplify handling Python 2 and 3Other bugfixes and improvements:Remove mention of PyPy from docs as it wasn’t ever tested on itImprove robustness with sending messages from agent to interfaceEscape display of binary challenge in debug log of xled.authIgnore (usually own) PING_MESSAGE on network when handling responses0.3.1 (2018-11-27)Update changelog for version 0.3.0Update description in setup.py to refer to CLIFix JSON payload sent to server for firmware update.0.3.0 (2018-11-27)CLI interfaceDiscovery interface - currently works only on Python 2Add support for API led/movie/full and corresponding CLI upload-movieNew Authentication mechanism - use sessionRename authentication module from long challenge_response_auth to authChange interface of ApplicationResponse to collections.MappingPython files reformatted with BlackOther bugfixes and improvements:Really show ApplicationResponse status in repr() when availableCatch JSONDecodeError in Python 3.5+ in ApplicationResponseNew shortcut method ok() of ApplicationResponseMake ApplicationResponse’s attribute status_code @propertyImprove error reporting during parsing of ApplicationResponseIf repr() of ApplicationResponse is called parse response firstCheck status of underlying requests’ Response if requestedAccept requests’ response as attribute to class ApplicationResponseMove generate_challenge to security moduleUnit tests for control interfaceRun unit tests on supported python versions with tox and TravisConfiguration for pre-commit-hooksInitial pyup configurationDon’t run Tox on Travis on Python 3.3Update coverage0.2.1 (2018-01-02)Add missing MANIFEST.inConfigure Travis for automatic deployment to PyPI0.2.0 (2018-01-02)First Python control interface.0.1.0 (2017-12-17)Low level control interface.