{ "info": { "author": "Fran\u00e7ois Wautier, Max Isom et al.", "author_email": "francois@wautier.eu", "bugtrack_url": null, "classifiers": [ "Development Status :: 4 - Beta", "Intended Audience :: Developers", "Intended Audience :: System Administrators", "License :: OSI Approved :: MIT License", "Operating System :: MacOS :: MacOS X", "Operating System :: POSIX", "Operating System :: POSIX :: Linux", "Programming Language :: Python", "Programming Language :: Python :: 3.5", "Programming Language :: Python :: 3.6", "Programming Language :: Python :: Implementation :: CPython", "Topic :: Software Development :: Libraries" ], "description": "# aiotuya\n\naiotuya ia a Python library for LAN control of Tuya devices. It can detect, provision\nand control devices that connect to the [Tuya Cloud](https://www.tuya.com).\n\nTo make things easy to the user, aiotuya comes with an application key and secret\nthat were provided by [Tuya Cloud](https://www.tuya.com). We request that you\ndo not use these key and secret for any other purpose.\n\n# Acknowledgement\n\nAll credits for figuring out how those device communicate goes to [codetheweb](https://github.com/codetheweb/tuyapi)\nand all the participants to this [conversation](https://github.com/codetheweb/tuyapi/issues/5). All I did is\nport their work to Python with asyncio and added bugs.\n\n# Installation\n\nComing soon... we will upload to Pypi\n\nIn the meantime....\n\n``` shell\npython3 setup.py install\n```\n\n# Usage\n\nThe easiest way to start is running the module\n\n``` shell\npython3 -m aiotuya\n```\n\nWhich, the first time around, will give you absolutely nothing. You want to\nstart with\n\n``` shell\npython3 -m aiotuya -e me@myself.com -p mypass -s WIFISSID -P WIFISECRET\n```\n\nAfter you hit the \"Enter\" you should get\n\n``` shell\nHit \"Enter\" to start\nUse Ctrl-C to quit\n\nSelect Device:\n\n [0] Provision new devices\n```\n\n\nReady you devices for configuration and hit 0 followed by enter.\n\nThen wait, hiting the \"Enter\" key from time to time.\n\nYou can also use the '-d' option to get debug messages. These are not suitable for human consumption and are\nknown to cause cancer in rats.\n\n## Provisioning Caveat\n\nFor provisioning to work, you must be able to send broadcast packets over WiFi.\nIn my case, I was only able to use provisioning on a laptop connected to my\nhouse WiFi. Trying from a wired computer did not work. Apparently my router (Asus RT-AC5300)\ndid not relay the packets. Your milage may vary.\n\nProvisioning is also working on a RPi3 connected through WiFi (Note that I use a USB WiFi dongle to\nconnect, not the RPi3 WiFi module)\n\nProvisioning is NOT YET working from a RPi2 (wire connected) with a WiFi dongle.\n\n\n## Remembering devices keys\n\nDuring the provisioning process, the device will register with the [Tuya Cloud](https://www.tuya.com).\nOnce the registration has succeeded, the provisioning system will receive a key to be used\nwhen communicating with the device. By default, aiotuya will save the pairs (device id, key) in a CSV file\nin your home directory. The default file name is .aiotuya\n\n# The devices\n\nAt this time (Feb '19) aiotuya will handle 3 types of devices\n\n## Switch\n\nA simple On/Off switch is provided by ``` TuyaSwitch ``` . It has 2 methods:\n\n* on()\n* off()\n\nAnd the status will be reported as\n\n``` python\n{'state': 'on'}\n{'state': 'off'}\n```\n\n## Open/Close/Idle Switch\n\nThis is the kind of switch that can be used for curtains, garage doors and so on. It is\nprovided with ``` TuyaOCSwitch ```. It has 3 methods:\n\n* open()\n* close()\n* idle()\n\nAnd the state value can be one of:\n\n* closing\n* opening\n* idling\n\n## LED lights\n\nThis is a colour LED light. It is provided by ``` TuyaLight ``` and offers the following methods:\n\n* on()\n* off()\n* set_white( brightness, K)\n* set_colour([hue, saturation, value])\n* set_colour_rgb([pred, green, blue])\n* transition_white([bright, K], duration)\n* transition_colour([h, s, v], duration)\n* fadein_white(bright, K, duration)\n* fadeout_white(duration)\n* fadein_colour([h, s, v], duration)\n* fadeout_colour(duration)\n\n## Other Devices\n\nOther devices can be added, but I do not have the information needed to add them.\n\n## Devices caveat\n\naiotuya keeps a connection to the device, and send a heartbeat status request every timout secs\n(10 secs by default). This allows it to receive real time status messages upon changes in the device status\n(e.g. button pressed on a switch). The downside is that Tuya devices seem to only accept one such a\nconnection, so aiotuya has exclusive control of the device via LAN. Fortunately, the devices stop broacasting their presence\nwhen they have a network connection, so other application should not be able to find them. I have not tried to see if the\ncloud API was still working in that case.\n\n# How to use aiotuya\n\nCreate a class to manage your devices. The class should have at least 4 methods:\n\n* register(self, device)\n This will be used to report when a new device has been found.\n* unregister(self,device)\n This is called when connection to a device is lost.\n* got_data(self, data)\n This is called when a device receive data. The data should be a dictionary. The 'devId' can be used to iscriminate which device received the data\n* got_error(self, device, data)\n This is called when an error is received. The device is passed as parameter.\n\n\nSubclass TuyaManager, if you want to persists the device keys, by overloading 2 methods:\n\n* load_keys(self)\n Loading the known keys in the dictionary self.known_devices. called in __init__\n* persist_keys(self)\n Save the keys, called when new keys are reported.\n\nAfter that\n\n``` python\nMyDevs= Devices()\nloop = aio.get_event_loop()\nmanager = DevManager(dev_parent=MyDevs)\nscanner = tuya.TuyaScanner(parent=manager)\nscanner.start(loop)\n```\n## How does it work\n\nTuya devices, when they are not connected, broadcast their presence on the network, TuyaScanner listen\nfor those broadcasts and pass them on to TuyaManager.\n\nIf the key is known, TuyaManager will create a TuyaDevice generic instance with raw_dps set, using itself as device manager.\nUpon receiving the device status data, Tuyamanager will try to figure out the type of device and create the proper instance\nusing the application device manager to control the device.\n\nTuyaManager figures out the type of device it is dealing with by issuing a status request and inspecting the returned value.\nIf an error is returned, ot will try sending a command. The reason for this is that my OC Switch, after powering up, will return\na \"json struct data unvalid\" error to any status request until either, a button is pressed or a valid command is issued. The behaviour\nof Tuyamanager is meant to circumvent this problem.\n\n# Status\n\n0.1.0b1: Initial version. Works for me with a LED lightbulb and a Open/Close switch\n\n\n", "description_content_type": "", "docs_url": null, "download_url": "", "downloads": { "last_day": -1, "last_month": -1, "last_week": -1 }, "home_page": "https://github.com/frawau/aiotuya", "keywords": "Tuya,IoT,WiFi,Home Automation,asyncio", "license": "MIT", "maintainer": "", "maintainer_email": "", "name": "aiotuya", "package_url": "https://pypi.org/project/aiotuya/", "platform": "unix", "project_url": "https://pypi.org/project/aiotuya/", "project_urls": { "Homepage": "https://github.com/frawau/aiotuya" }, "release_url": "https://pypi.org/project/aiotuya/0.1.0b2/", "requires_dist": null, "requires_python": "", "summary": "Pure Python library to control/provision Tuya devices", "version": "0.1.0b2" }, "last_serial": 4953924, "releases": { "0.1.0b2": [ { "comment_text": "", "digests": { "md5": "9817d74ee7129b03053a8c35c23fba92", "sha256": "a21dea864c26a08b76094812272ee0b2caa67e11b1fc47c629496d8b5bd63867" }, "downloads": -1, "filename": "aiotuya-0.1.0b2-py3-none-any.whl", "has_sig": false, "md5_digest": "9817d74ee7129b03053a8c35c23fba92", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": null, "size": 21832, "upload_time": "2019-03-18T13:36:50", "url": "https://files.pythonhosted.org/packages/46/30/74ccec457be29df74051386360eb169801e2c300df7a0ae4b03e89de1257/aiotuya-0.1.0b2-py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "1e0cfe43b7491d5c65c1c31a758b1fa6", "sha256": "01236dad4d15bd082f8669da83499066a1e9b282d00d4c3d0a2060c7b0fe0e6b" }, "downloads": -1, "filename": "aiotuya-0.1.0b2.tar.gz", "has_sig": false, "md5_digest": "1e0cfe43b7491d5c65c1c31a758b1fa6", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 19211, "upload_time": "2019-03-18T13:36:52", "url": "https://files.pythonhosted.org/packages/16/66/45d73b254619d4580d9cb5fd05b52c73f40fcfede9e4ab67a84ceea797fb/aiotuya-0.1.0b2.tar.gz" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "9817d74ee7129b03053a8c35c23fba92", "sha256": "a21dea864c26a08b76094812272ee0b2caa67e11b1fc47c629496d8b5bd63867" }, "downloads": -1, "filename": "aiotuya-0.1.0b2-py3-none-any.whl", "has_sig": false, "md5_digest": "9817d74ee7129b03053a8c35c23fba92", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": null, "size": 21832, "upload_time": "2019-03-18T13:36:50", "url": "https://files.pythonhosted.org/packages/46/30/74ccec457be29df74051386360eb169801e2c300df7a0ae4b03e89de1257/aiotuya-0.1.0b2-py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "1e0cfe43b7491d5c65c1c31a758b1fa6", "sha256": "01236dad4d15bd082f8669da83499066a1e9b282d00d4c3d0a2060c7b0fe0e6b" }, "downloads": -1, "filename": "aiotuya-0.1.0b2.tar.gz", "has_sig": false, "md5_digest": "1e0cfe43b7491d5c65c1c31a758b1fa6", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 19211, "upload_time": "2019-03-18T13:36:52", "url": "https://files.pythonhosted.org/packages/16/66/45d73b254619d4580d9cb5fd05b52c73f40fcfede9e4ab67a84ceea797fb/aiotuya-0.1.0b2.tar.gz" } ] }