├── .github ├── ISSUE_TEMPLATE │ ├── bug_report.md │ └── new-device-support.md └── workflows │ ├── codeql-analysis.yml │ └── hassfest.yml ├── .gitignore ├── LICENSE ├── README.md └── docs ├── develop_new_driver.md ├── error_code.md ├── faq.md ├── get_log.md ├── install.md ├── not_supported_devices.md ├── platform_configuration.md ├── raspberryPi_setup.md ├── regions_dataCenters.md ├── supported_devices.md └── supported_devices_cn.md /.github/ISSUE_TEMPLATE/bug_report.md: -------------------------------------------------------------------------------- 1 | --- 2 | name: Bug report 3 | about: Create a report to help us improve, Not leave sensitive info in the log. 4 | title: '' 5 | labels: bug 6 | assignees: '' 7 | 8 | --- 9 | 10 | **Describe the bug** 11 | 12 | A clear and concise description of what the bug is. 13 | 14 | **Expected behavior** 15 | 16 | A clear and concise description of what you expected to happen. 17 | 18 | **Diagnostics for integrations and devices** 19 | 20 | You can download the diagnostics text file by clicking the "Download diagnostics" button in (Configuration -> Integrations -> Tuya Integration -> lower right button), please check the image below: 21 | 22 | image 23 | 24 | **Screenshots** 25 | 26 | If applicable, add screenshots to help explain your problem. 27 | 28 | **Home Assistant Version** 29 | - e.g. 2021.5.1 30 | 31 | **Device info (please complete the following information, which can be found in [log](https://github.com/tuya/tuya-home-assistant/wiki/How-to-get-the-log)):** 32 | 33 | like this: 34 | { 35 | "active_time": 1623229189, 36 | "biz_type": 18, 37 | "category": "cz", 38 | "create_time": 1560491945, 39 | "icon": "smart/product_icon/cz.png", 40 | "id": "aaaaaaaaaaa", 41 | "ip": "xxxxxxxxxxxxxxxx", 42 | "lat": "xxxxxxxxxx", 43 | "local_key": "xxxxxxxxxxxxx", 44 | "lon": "xxxxxxx", 45 | "model": "", 46 | "name": "Living Room Socket", 47 | "online": false, 48 | "owner_id": "34794909", 49 | "product_id": "yfemiswbgjhddhcf", 50 | "product_name": "Switch Product", 51 | "status": [ 52 | { 53 | "code": "switch", 54 | "value": false 55 | }, 56 | { 57 | "code": "countdown_1", 58 | "value": 0 59 | }, 60 | { 61 | "code": "cur_current", 62 | "value": 0 63 | }, 64 | { 65 | "code": "cur_power", 66 | "value": 0 67 | }, 68 | { 69 | "code": "cur_voltage", 70 | "value": 2343 71 | } 72 | ], 73 | "sub": false, 74 | "time_zone": "+08:00", 75 | "uid": "xxxxxxxxxxxxxxxxxxx", 76 | "update_time": 1625101929, 77 | "uuid": "xxxxxxxxxxxxxxxxxx" 78 | } 79 | 80 | **Device specifications (please complete the following information, which can be found in [log](https://github.com/tuya/tuya-home-assistant/wiki/How-to-get-the-log)):** 81 | 82 | Same device's id, like this: 83 | [2021-07-01 10:18:01,351] [tuya-openapi] Request: method = GET, url = https://openapi.tuyacn.com/v1.0/devices/aaaaaaaaaaa/specifications, params = None, body = None, headers = {'client_id': 'xxxxxxxxxxxx', 'sign': 'xxxxxxxxxxxx', 'sign_method': 'HMAC-SHA256', 'access_token': 'xxxxxxxxxxxxxxxx', 't': '1625105881351', 'lang': 'en'} 84 | 2021-07-01 10:18:01 DEBUG (SyncWorker_1) [tuya iot] Response: { 85 | "result": { 86 | "category": "cz", 87 | "functions": [ 88 | { 89 | "code": "countdown_1", 90 | "type": "Integer", 91 | "values": "{\"unit\":\"s\",\"min\":0,\"max\":86400,\"scale\":0,\"step\":1}" 92 | }, 93 | { 94 | "code": "switch", 95 | "type": "Boolean", 96 | "values": "{}" 97 | } 98 | ], 99 | "status": [ 100 | { 101 | "code": "cur_voltage", 102 | "type": "Integer", 103 | "values": "{\"unit\":\"V\",\"min\":0,\"max\":2500,\"scale\":0,\"step\":1}" 104 | }, 105 | { 106 | "code": "cur_current", 107 | "type": "Integer", 108 | "values": "{\"unit\":\"mA\",\"min\":0,\"max\":30000,\"scale\":0,\"step\":1}" 109 | }, 110 | { 111 | "code": "switch", 112 | "type": "Boolean", 113 | "values": "{}" 114 | }, 115 | { 116 | "code": "cur_power", 117 | "type": "Integer", 118 | "values": "{\"unit\":\"W\",\"min\":0,\"max\":50000,\"scale\":0,\"step\":1}" 119 | }, 120 | { 121 | "code": "countdown_1", 122 | "type": "Integer", 123 | "values": "{\"unit\":\"s\",\"min\":0,\"max\":86400,\"scale\":0,\"step\":1}" 124 | } 125 | ] 126 | }, 127 | "success": true, 128 | "t": 1625105881348 129 | } 130 | 131 | **Additional context** 132 | 133 | Add any other context or logs about the problem here. 134 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/new-device-support.md: -------------------------------------------------------------------------------- 1 | --- 2 | name: New Device Support 3 | about: New device that wants to be supported, Not leave sensitive info in the log. 4 | title: '' 5 | labels: enhancement, help wanted 6 | assignees: '' 7 | 8 | --- 9 | 10 | **Device normal info** 11 | - Brand 12 | - Model 13 | 14 | **Device info (please complete the following information, which can be found in [log](https://github.com/tuya/tuya-home-assistant/wiki/How-to-get-the-log)):** 15 | like this: 16 | { 17 | "active_time": 1623229189, 18 | "biz_type": 18, 19 | "category": "cz", 20 | "create_time": 1560491945, 21 | "icon": "smart/product_icon/cz.png", 22 | "id": "aaaaaaaaaaa", 23 | "ip": "xxxxxxxxxxxxxxxx", 24 | "lat": "xxxxxxxxxxxxxxxx", 25 | "local_key": "xxxxxxxxxxxxx", 26 | "lon": "xxxxxxxxxxxxxxx", 27 | "model": "", 28 | "name": "Living Room Socket", 29 | "online": false, 30 | "owner_id": "34794909", 31 | "product_id": "yfemiswbgjhddhcf", 32 | "product_name": "Switch Product", 33 | "status": [ 34 | { 35 | "code": "switch", 36 | "value": false 37 | }, 38 | { 39 | "code": "countdown_1", 40 | "value": 0 41 | }, 42 | { 43 | "code": "cur_current", 44 | "value": 0 45 | }, 46 | { 47 | "code": "cur_power", 48 | "value": 0 49 | }, 50 | { 51 | "code": "cur_voltage", 52 | "value": 2343 53 | } 54 | ], 55 | "sub": false, 56 | "time_zone": "+08:00", 57 | "uid": "xxxxxxxxxxxxxxxxxxx", 58 | "update_time": 1625101929, 59 | "uuid": "xxxxxxxxxxxxxxxxxx" 60 | } 61 | 62 | **Device specifications (please complete the following information, which can be found in [log](https://github.com/tuya/tuya-home-assistant/wiki/How-to-get-the-log)):** 63 | Same device's id, like this: 64 | [2021-07-01 10:18:01,351] [tuya-openapi] Request: method = GET, url = https://openapi.tuyacn.com/v1.0/devices/aaaaaaaaaaa/specifications, params = None, body = None, headers = {'client_id': 'xxxxxxxxxxxx', 'sign': 'xxxxxxxxxxxx', 'sign_method': 'HMAC-SHA256', 'access_token': '213e2d4af5e8d217abc0b104462a9f72', 't': '1625105881351', 'lang': 'en'} 65 | 2021-07-01 10:18:01 DEBUG (SyncWorker_1) [tuya iot] Response: { 66 | "result": { 67 | "category": "cz", 68 | "functions": [ 69 | { 70 | "code": "countdown_1", 71 | "type": "Integer", 72 | "values": "{\"unit\":\"s\",\"min\":0,\"max\":86400,\"scale\":0,\"step\":1}" 73 | }, 74 | { 75 | "code": "switch", 76 | "type": "Boolean", 77 | "values": "{}" 78 | } 79 | ], 80 | "status": [ 81 | { 82 | "code": "cur_voltage", 83 | "type": "Integer", 84 | "values": "{\"unit\":\"V\",\"min\":0,\"max\":2500,\"scale\":0,\"step\":1}" 85 | }, 86 | { 87 | "code": "cur_current", 88 | "type": "Integer", 89 | "values": "{\"unit\":\"mA\",\"min\":0,\"max\":30000,\"scale\":0,\"step\":1}" 90 | }, 91 | { 92 | "code": "switch", 93 | "type": "Boolean", 94 | "values": "{}" 95 | }, 96 | { 97 | "code": "cur_power", 98 | "type": "Integer", 99 | "values": "{\"unit\":\"W\",\"min\":0,\"max\":50000,\"scale\":0,\"step\":1}" 100 | }, 101 | { 102 | "code": "countdown_1", 103 | "type": "Integer", 104 | "values": "{\"unit\":\"s\",\"min\":0,\"max\":86400,\"scale\":0,\"step\":1}" 105 | } 106 | ] 107 | }, 108 | "success": true, 109 | "t": 1625105881348 110 | } 111 | -------------------------------------------------------------------------------- /.github/workflows/codeql-analysis.yml: -------------------------------------------------------------------------------- 1 | # For most projects, this workflow file will not need changing; you simply need 2 | # to commit it to your repository. 3 | # 4 | # You may wish to alter this file to override the set of languages analyzed, 5 | # or to provide custom queries or build logic. 6 | # 7 | # ******** NOTE ******** 8 | # We have attempted to detect the languages in your repository. Please check 9 | # the `language` matrix defined below to confirm you have the correct set of 10 | # supported CodeQL languages. 11 | # 12 | name: "CodeQL" 13 | 14 | on: 15 | push: 16 | branches: [ master, develop ] 17 | pull_request: 18 | # The branches below must be a subset of the branches above 19 | branches: [ master ] 20 | schedule: 21 | - cron: '25 16 * * 1' 22 | 23 | jobs: 24 | analyze: 25 | name: Analyze 26 | runs-on: ubuntu-latest 27 | permissions: 28 | actions: read 29 | contents: read 30 | security-events: write 31 | 32 | strategy: 33 | fail-fast: false 34 | matrix: 35 | language: [ 'python' ] 36 | # CodeQL supports [ 'cpp', 'csharp', 'go', 'java', 'javascript', 'python' ] 37 | # Learn more: 38 | # https://docs.github.com/en/free-pro-team@latest/github/finding-security-vulnerabilities-and-errors-in-your-code/configuring-code-scanning#changing-the-languages-that-are-analyzed 39 | 40 | steps: 41 | - name: Checkout repository 42 | uses: actions/checkout@v2 43 | 44 | # Initializes the CodeQL tools for scanning. 45 | - name: Initialize CodeQL 46 | uses: github/codeql-action/init@v1 47 | with: 48 | languages: ${{ matrix.language }} 49 | # If you wish to specify custom queries, you can do so here or in a config file. 50 | # By default, queries listed here will override any specified in a config file. 51 | # Prefix the list here with "+" to use these queries and those in the config file. 52 | # queries: ./path/to/local/query, your-org/your-repo/queries@main 53 | 54 | # Autobuild attempts to build any compiled languages (C/C++, C#, or Java). 55 | # If this step fails, then you should remove it and run the build manually (see below) 56 | - name: Autobuild 57 | uses: github/codeql-action/autobuild@v1 58 | 59 | # ℹ️ Command-line programs to run using the OS shell. 60 | # 📚 https://git.io/JvXDl 61 | 62 | # ✏️ If the Autobuild fails above, remove it and uncomment the following three lines 63 | # and modify them (or add more) to build your code if your project 64 | # uses a compiled language 65 | 66 | #- run: | 67 | # make bootstrap 68 | # make release 69 | 70 | - name: Perform CodeQL Analysis 71 | uses: github/codeql-action/analyze@v1 72 | -------------------------------------------------------------------------------- /.github/workflows/hassfest.yml: -------------------------------------------------------------------------------- 1 | name: Validate with hassfest 2 | 3 | on: 4 | push: 5 | pull_request: 6 | schedule: 7 | - cron: "0 0 * * *" 8 | 9 | jobs: 10 | validate: 11 | runs-on: "ubuntu-latest" 12 | steps: 13 | - uses: "actions/checkout@v2" 14 | - uses: home-assistant/actions/hassfest@master 15 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # Byte-compiled / optimized / DLL files 2 | __pycache__/ 3 | *.py[cod] 4 | *$py.class 5 | 6 | # C extensions 7 | *.so 8 | 9 | # Distribution / packaging 10 | .Python 11 | build/ 12 | develop-eggs/ 13 | dist/ 14 | downloads/ 15 | eggs/ 16 | .eggs/ 17 | lib/ 18 | lib64/ 19 | parts/ 20 | sdist/ 21 | var/ 22 | wheels/ 23 | share/python-wheels/ 24 | *.egg-info/ 25 | .installed.cfg 26 | *.egg 27 | MANIFEST 28 | 29 | # PyInstaller 30 | # Usually these files are written by a python script from a template 31 | # before PyInstaller builds the exe, so as to inject date/other infos into it. 32 | *.manifest 33 | *.spec 34 | 35 | # Installer logs 36 | pip-log.txt 37 | pip-delete-this-directory.txt 38 | 39 | # Unit test / coverage reports 40 | htmlcov/ 41 | .tox/ 42 | .nox/ 43 | .coverage 44 | .coverage.* 45 | .cache 46 | nosetests.xml 47 | coverage.xml 48 | *.cover 49 | *.py,cover 50 | .hypothesis/ 51 | .pytest_cache/ 52 | cover/ 53 | 54 | # Translations 55 | *.mo 56 | *.pot 57 | 58 | # Django stuff: 59 | *.log 60 | local_settings.py 61 | db.sqlite3 62 | db.sqlite3-journal 63 | 64 | # Flask stuff: 65 | instance/ 66 | .webassets-cache 67 | 68 | # Scrapy stuff: 69 | .scrapy 70 | 71 | # Sphinx documentation 72 | docs/_build/ 73 | 74 | # PyBuilder 75 | .pybuilder/ 76 | target/ 77 | 78 | # Jupyter Notebook 79 | .ipynb_checkpoints 80 | 81 | # IPython 82 | profile_default/ 83 | ipython_config.py 84 | 85 | # pyenv 86 | # For a library or package, you might want to ignore these files since the code is 87 | # intended to run in multiple environments; otherwise, check them in: 88 | # .python-version 89 | 90 | # pipenv 91 | # According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control. 92 | # However, in case of collaboration, if having platform-specific dependencies or dependencies 93 | # having no cross-platform support, pipenv may install dependencies that don't work, or not 94 | # install all needed dependencies. 95 | #Pipfile.lock 96 | 97 | # PEP 582; used by e.g. github.com/David-OConnor/pyflow 98 | __pypackages__/ 99 | 100 | # Celery stuff 101 | celerybeat-schedule 102 | celerybeat.pid 103 | 104 | # SageMath parsed files 105 | *.sage.py 106 | 107 | # Environments 108 | .env 109 | .venv 110 | env/ 111 | venv/ 112 | ENV/ 113 | env.bak/ 114 | venv.bak/ 115 | 116 | # Spyder project settings 117 | .spyderproject 118 | .spyproject 119 | 120 | # Rope project settings 121 | .ropeproject 122 | 123 | # mkdocs documentation 124 | /site 125 | 126 | # mypy 127 | .mypy_cache/ 128 | .dmypy.json 129 | dmypy.json 130 | 131 | # Pyre type checker 132 | .pyre/ 133 | 134 | # pytype static type analyzer 135 | .pytype/ 136 | 137 | # Cython debug symbols 138 | cython_debug/ 139 | 140 | # MacOS files 141 | .DS_Store 142 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2014-2021 Tuya Inc. 4 | Permission is hereby granted, free of charge, to any person obtaining a copy 5 | of this software and associated documentation files (the "Software"), to deal 6 | in the Software without restriction, including without limitation the rights 7 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 8 | copies of the Software, and to permit persons to whom the Software is 9 | furnished to do so, subject to the following conditions: 10 | 11 | The above copyright notice and this permission notice shall be included in 12 | all copies or substantial portions of the Software. 13 | 14 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 15 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 16 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 17 | THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 18 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 19 | FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 20 | DEALINGS IN THE SOFTWARE. 21 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | [![GitHub license](https://img.shields.io/github/license/tuya/tuya-home-assistant.svg)](https://github.com/tuya/tuya-home-assistant/blob/master/LICENSE) 2 | [![GitHub contributors](https://img.shields.io/github/contributors/tuya/tuya-home-assistant.svg)](https://github.com/tuya/tuya-home-assistant/graphs/contributors) 3 | [![GitHub issues](https://img.shields.io/github/issues/tuya/tuya-home-assistant.svg)](https://GitHub.com/tuya/tuya-home-assistant/issues/) 4 | [![GitHub pull-requests](https://img.shields.io/github/issues-pr/tuya/tuya-home-assistant.svg)](https://GitHub.com/tuya/tuya-home-assistant/pulls/) 5 | [![PRs Welcome](https://img.shields.io/badge/PRs-welcome-brightgreen.svg?style=flat-square)](http://makeapullrequest.com) 6 | 7 | [![GitHub watchers](https://img.shields.io/github/watchers/tuya/tuya-home-assistant.svg?style=social&label=Watch)](https://GitHub.com/tuya/tuya-home-assistant/watchers/) 8 | [![GitHub forks](https://img.shields.io/github/forks/tuya/tuya-home-assistant.svg?style=social&label=Fork)](https://GitHub.com/tuya/tuya-home-assistant/network/) 9 | [![GitHub stars](https://img.shields.io/github/stars/tuya/tuya-home-assistant.svg?style=social&label=Star)](https://GitHub.com/tuya/tuya-home-assistant/stargazers/) 10 | 11 | ## Breaking Update: 12 | Tuya has developed a new HA integration called [Smart Life](https://github.com/tuya/tuya-smart-life), available for free to developers. Currently in beta testing, it eliminates the need to register a cloud development project on Tuya IoT platform and extend the Tuya cloud development IoT Core Service resources when expired. This significantly lowers the access barrier and enhances user experience. If you're interested, please check the following links to get started with the integration: 13 | 14 | - Smart Life Integration (Beta): 15 | - Tutorial documentation: 16 | - Video Tutorial: 17 | 18 | Key Features: 19 | - The new Smart Life integration is open source, allowing developers to actively contribute and maintain it. 20 | - Please note that the new Smart Life integration is not compatible with the existing [Tuya integration](https://www.home-assistant.io/integrations/tuya/), and device migration is not possible. Users will need to use the new plugin to add devices and configure automation scenarios. 21 | - The new Smart Life integration supports the same range of products as the [Tuya integration](https://www.home-assistant.io/integrations/tuya/). 22 | - Local control is not yet supported in the new [Smart Life Integration](https://github.com/tuya/tuya-smart-life). 23 | 24 | # Tuya Home Assistant Integration Documentation 25 | 26 |

27 | 28 |

29 | 30 | The Tuya Home Assistant integration is developed for controlling **Powered by Tuya (PBT)** devices using the [tuya-iot-python-sdk](https://github.com/tuya/tuya-iot-python-sdk?_source=df9bd859d17e7610d5b9df34d38a83e9) (a python version of [Tuya Open API](https://developer.tuya.com/en/docs/cloud/?_source=6c7c0e6d9fc9ac8296e1a48954e1d0e4)), and maintained by the official Tuya Developer Team and Home Assistant Community. 31 | 32 | ## Important Note 33 | 34 | We are announcing that the **Tuya v2 integration** hosted on this repository is no longer maintained by the Tuya Developer Team. Only the related documentation will be provided in this repository, as shown below: 35 | 36 | #### Installation 37 | - [Tuya IoT Platform Configuration Guide](./docs/platform_configuration.md) 38 | - [Install Tuya Integration](./docs/install.md) 39 | 40 | #### Documentation 41 | - [Error Code and Troubleshooting](./docs/error_code.md) 42 | - [Tuya Integration FAQs](./docs/faq.md) 43 | - [Countries/Regions and Data Center](./docs/regions_dataCenters.md) 44 | - [Not Supported Device Category](./docs/not_supported_devices.md) 45 | 46 | Here is the official [Tuya Home Assistant integration](https://www.home-assistant.io/integrations/tuya/). 47 | 48 | If you want to contribute to the Tuya integration, please directly create issues or pull requests in the [Home Assistant Core repository](https://github.com/home-assistant/core/tree/dev/homeassistant/components/tuya). 49 | 50 | If you want to contribute to the documentation, please create issues or pull requests in this repo. 51 | 52 | We really appreciate your contributions and awesome ideas to this project. 53 | We are happy to hear your voices at **GitHub Discussions** to make our integration better. 54 | 55 | ## Prerequisites 56 | 57 | - Your devices need to first be added in the [Tuya Smart or Smart Life app](https://developer.tuya.com/en/docs/iot/tuya-smart-app-smart-life-app-advantages?id=K989rqa49rluq&_source=fa490bbdc25052bdf601160a53e5629c#title-1-Download). 58 | - You will also need to create an account in the [Tuya IoT Platform](https://iot.tuya.com/?_source=a4c65f56395e05cf64cc8d4abb7396b6). 59 | This is a separate account to the one you made for the app. You cannot log in with your app's credentials. 60 | 61 | ## Supported Tuya Device Categories 62 | Seven primary categories, 50 secondary categories are supported now! 63 | 64 | :clap: [Supported Device Category](./docs/supported_devices.md) 65 | 66 | :tada: :tada: :tada: [Vote for Tuya Integration New Device Driver Support!](https://github.com/tuya/tuya-home-assistant/discussions/86) :tada::tada::tada: 67 | 68 | ## Verified PBT Products List 69 | 70 | If you have tested and confirmed any Tuya compatible PBT (Powered by Tuya) device, please help to contribute to [Mark Watt Tech's page](https://github.com/MarkWattTech/Tuya-v2-Supported-Devices) 71 | 72 | It's a collection of known working PBT Products that are compatible with Home Assistant and the Tuya integration. 73 | 74 | We appreciate your contribution! 75 | 76 | ### DISCLAIMER 77 | 78 | [Mark Watt](https://www.youtube.com/channel/UCQRm_z7seHnGsBiWDNEWr6A) is not associated with Home Assistant or Tuya. He is a Smart Home and Home Assistant enthusiast, and would like to help make the Tuya integration the best it can be. 79 | 80 | ## Follow us 81 | 82 | - [Twitter](https://twitter.com/developwithtuya) 83 | - [YouTube](https://www.youtube.com/channel/UC25KgSG1nXMZmR8ehs3tleA) 84 | - [Facebook](https://www.facebook.com/Develop-With-Tuya-104216298552203) 85 | - [Bilibili](https://space.bilibili.com/1394005610?from=search&seid=1788260158867313813) 86 | - [Linkedin](https://www.linkedin.com/company/develop-with-tuya) 87 | - [Discord](https://discord.gg/E2Xs97N9RK) 88 | 89 | Follow us to get more information and leading technology on the Internet of Things, as well as updates and activities on the [Tuya IoT Developer Platform](https://developer.tuya.com/?_source=6d8d369b1b09336f622047669af507c4) 90 | 91 | ## Issue Feedback 92 | 93 | You can give feedback on issues you encounter for the documentation via **GitHub Issue**. 94 | 95 | ## Related Projects 96 | 97 | - [Tuya IoT Python SDK](https://github.com/tuya/tuya-iot-python-sdk?_source=df9bd859d17e7610d5b9df34d38a83e9) 98 | 99 | - [Tuya Connector Python](https://github.com/tuya/tuya-connector-python?_source=5f909fc5f4f349e687a09dc5c91bac4c) 100 | 101 | ## LICENSE 102 | 103 | For more information, please refer to the [LICENSE](LICENSE) file. 104 | -------------------------------------------------------------------------------- /docs/develop_new_driver.md: -------------------------------------------------------------------------------- 1 | # How to Develop a New Driver 2 | 3 | For example, I want my socket called "Living Room Socket" to work in Tuya. 4 | 5 | ## I. Getting information about the device 6 | First, get the logs according to [How to get logs](./get_log.md) and look up "living room socket" in the logs to get information about the device, such as 7 | ```json 8 | { 9 | "active_time": 1623229189, 10 | "biz_type": 18, 11 | "category": "cz", 12 | "create_time": 1560491945, 13 | "icon": "smart/product_icon/cz.png", 14 | "id": "xxxxxxxxxxxxxxxx", 15 | "ip": "xxxxxxxxxxxxxxxx", 16 | "lat": "30.30286857361191", 17 | "local_key": "xxxxxxxxxxxxx", 18 | "lon": "120.0639743842656", 19 | "model": "", 20 | "name": "Living Room Socket", 21 | "online": false, 22 | "owner_id": "34794909", 23 | "product_id": "yfemiswbgjhddhcf", 24 | "product_name": "Switch Product", 25 | "status": [ 26 | { 27 | "code": "switch", 28 | "value": false 29 | }, 30 | { 31 | "code": "countdown_1", 32 | "value": 0 33 | }, 34 | { 35 | "code": "cur_current", 36 | "value": 0 37 | }, 38 | { 39 | "code": "cur_power", 40 | "value": 0 41 | }, 42 | { 43 | "code": "cur_voltage", 44 | "value": 2343 45 | } 46 | ], 47 | "sub": false, 48 | "time_zone": "+08:00", 49 | "uid": "ay1622097934070h5Mpi", 50 | "update_time": 1625101929, 51 | "uuid": "65015854bcddc21a9073" 52 | } 53 | ``` 54 | ## II. Finding category support 55 | ### 2.1 Tuya device category Instruction Set. 56 | Get `"category": "cz"` from the log, I learn that my socket is in the category defined by Tuya as cz. 57 | Go to the [Tuya developer website](https://developer.tuya.com/en/docs/iot/standarddescription?id=K9i5ql6waswzq&_source=523ce082061eb112a40973f8bbc6908b) to find the Instruction set corresponding to the cz category. 58 | 59 | 60 | 61 | ### 2.2 Home Assistant supports Entities 62 | Based on my socket, I looked up the supported Entity models from the Home Assistant Entities, and here I found that the SwitchEntity was a better match for my socket device. 63 | ## III. Driver development 64 | Based on the SwitchEntity selected in Home Assistant, I create a new switch.py file in tuya_v2. 65 | ### 3.1 Supported categories 66 | Since we need to support cz, write in the switch.py file 67 | ```python 68 | TUYA_SUPPORT_TYPE = { 69 | "cz", # Switch 70 | } 71 | ``` 72 | In the TUYA_SUPPORT_HA_TYPE of const.py make sure the Home Assistant domain corresponding to SwitchEntity which is "switch" exists; if it doesn't, then add it in TUYA_SUPPORT_HA_TYPE. 73 | 74 | ```python 75 | TUYA_SUPPORT_HA_TYPE = [ 76 | "switch", 77 | "fan", 78 | "cover", 79 | "climate", 80 | "light", 81 | "sensor", 82 | "binary_sensor", 83 | "humidifier", 84 | "number", 85 | "vacuum" 86 | ] 87 | ``` 88 | ### 3.2 Device registration logic 89 | ```python 90 | async def async_setup_entry( 91 | hass: HomeAssistant, _entry: ConfigEntry, async_add_entities 92 | ): 93 | """Set up tuya sensors dynamically through tuya discovery.""" 94 | _LOGGER.info("switch init") 95 | 96 | hass.data[DOMAIN][TUYA_HA_TUYA_MAP].update({DEVICE_DOMAIN: TUYA_SUPPORT_TYPE}) 97 | 98 | async def async_discover_device(dev_ids): 99 | """Discover and add a discovered tuya switch.""" 100 | _LOGGER.info(f "switch add-> {dev_ids}") 101 | if not dev_ids: 102 | return 103 | entities = await hass.async_add_executor_job(_setup_entities, hass, dev_ids) 104 | hass.data[DOMAIN][TUYA_HA_DEVICES].extend(entities) 105 | async_add_entities(entities) 106 | 107 | async_dispatcher_connect( 108 | hass, TUYA_DISCOVERY_NEW.format(DEVICE_DOMAIN), async_discover_device 109 | ) 110 | 111 | device_manager = hass.data[DOMAIN][TUYA_DEVICE_MANAGER] 112 | device_ids = [] 113 | for (device_id, device) in device_manager.device_map.items(): 114 | if device.category in TUYA_SUPPORT_TYPE: 115 | device_ids.append(device_id) 116 | await async_discover_device(device_ids) 117 | 118 | 119 | def _setup_entities(hass, device_ids: list): 120 | """Set up Tuya Switch device.""" 121 | device_manager = hass.data[DOMAIN][TUYA_DEVICE_MANAGER] 122 | entities = [] 123 | for device_id in device_ids: 124 | device = device_manager.device_map[device_id] 125 | if device is None: 126 | continue 127 | 128 | for function in device.function: 129 | if function.startswith(DPCODE_SWITCH): 130 | entities.append(TuyaHaSwitch(device, device_manager, function)) 131 | continue 132 | 133 | return entities 134 | ``` 135 | ### 3.2 Properties 136 | From the Entity documentation for Home Assistant Switch, you can see that the Properties parameter to be overridden is is_on. 137 | 138 | 139 | 140 | It's used to indicate the on/off status of the socket. You can find that the corresponding Tuya category code of sockets is "cz", and the DP code to control the switch state in the instruction set is "switch". You can also find the code "switch" in the status section of the log. 141 | ```json 142 | "status": [ 143 | { 144 | "code": "switch", 145 | "value": false 146 | }, 147 | { 148 | "code": "countdown_1", 149 | "value": 0 150 | }, 151 | { 152 | "code": "cur_current", 153 | "value": 0 154 | }, 155 | { 156 | "code": "cur_power", 157 | "value": 0 158 | }, 159 | { 160 | "code": "cur_voltage", 161 | "value": 2343 162 | } 163 | ] 164 | ``` 165 | It is known that the DP code "switch" exists in the status of this device, so 166 | Define `DPCODE_SWITCH` as the switch DP code and rewrite the method is_on: 167 | ```python 168 | @property 169 | def is_on(self) -> bool: 170 | """Return true if switch is on.""" 171 | return self.tuya_device.status.get(self.dp_code, False) 172 | ``` 173 | 174 | ### 3.3 Methods 175 | The Methods that need to be rewritten can be viewed in the Entity documentation for Home Assistant Switch 176 | 177 | 178 | 179 | The "turn_on" and "turn_off" methods are used to turn on and turn off the socket. You can find its Tuya category code is "cz" and the DP code to control the switch state is "switch", and get the device set information of the device from the log. 180 | ```json 181 | "result": { 182 | "category": "cz", 183 | "functions": [ 184 | { 185 | "code": "countdown_1", 186 | "type": "Integer", 187 | "values": "{\"unit\":\"s\",\"min\":0,\"max\":86400,\"scale\":0,\"step\":1}" 188 | }, 189 | { 190 | "code": "switch", 191 | "type": "Boolean", 192 | "values": "{}" 193 | } 194 | ], 195 | "status": [ 196 | { 197 | "code": "cur_voltage", 198 | "type": "Integer", 199 | "values": "{\"unit\":\"V\",\"min\":0,\"max\":2500,\"scale\":0,\"step\":1}" 200 | }, 201 | { 202 | "code": "cur_current", 203 | "type": "Integer", 204 | "values": "{\"unit\":\"mA\",\"min\":0,\"max\":30000,\"scale\":0,\"step\":1}" 205 | }, 206 | { 207 | "code": "switch", 208 | "type": "Boolean", 209 | "values": "{}" 210 | }, 211 | { 212 | "code": "cur_power", 213 | "type": "Integer", 214 | "values": "{\"unit\":\"W\",\"min\":0,\"max\":50000,\"scale\":0,\"step\":1}" 215 | }, 216 | { 217 | "code": "countdown_1", 218 | "type": "Integer", 219 | "values": "{\"unit\":\"s\",\"min\":0,\"max\":86400,\"scale\":0,\"step\":1}" 220 | } 221 | ] 222 | }, 223 | "success": true, 224 | "t": 1625105881348 225 | } 226 | ``` 227 | We know that there is a DP code "switch" in the functions of this device, so 228 | reuse `DPCODE_SWITCH`, rewrite methods turn_on and turn_off 229 | 230 | ```python 231 | def turn_on(self, **kwargs: Any) -> None: 232 | """Turn the switch on.""" 233 | self._send_command([{"code": self.dp_code, "value": True}]) 234 | 235 | def turn_off(self, **kwargs: Any) -> None: 236 | """Turn the device off.""" 237 | self._send_command([{"code": self.dp_code, "value": False}]) 238 | ``` 239 | Now we have finished writing the socket driver. 240 | ### 3.4 Debugging 241 | Debug by enabling the tuya_v2 log. 242 | ## IV. Reference code 243 | https://github.com/tuya/tuya-home-assistant/blob/master/custom_components/tuya_v2/switch.py 244 | ## V. Reference documents 245 | Tuya DP Code Data Type and Value Constraint: https://developer.tuya.com/en/docs/iot/datatypedescription?id=K9i5ql2jo7j1k&_source=751e806efb9d0a8cb3793945cccdc47e 246 | -------------------------------------------------------------------------------- /docs/error_code.md: -------------------------------------------------------------------------------- 1 | # Error Code and Troubleshooting 2 | 3 | | Error code | Message | Troubleshooting | 4 | |:----|:----|:----| 5 | | 1004 | sign invalid | The Access ID and Access Secret you entered are not correct. For more information, see entering credentials step in [Install Tuya Integration](.././docs/install.md). | 6 | | 1106 | permission deny |
  • Your app account is not linked to your cloud project. This operation is a must-do. For more information, see [Link devices by app account](https://developer.tuya.com/en/docs/iot/Platform_Configuration_smarthome?id=Kamcgamwoevrx#title-3-Link%20devices%20by%20app%20account).
  • Incorrect account or password. You must enter the account and password of the mobile app that you use to scan the QR code for linking devices to your cloud project on the [Tuya IoT Development Platform](https://iot.tuya.com/).
  • Incorrect country. You must select the region of your account of the Tuya Smart app or Smart Life app.
| 7 | |1100|param is empty| Empty parameter of username or app. Fill the parameters refer to the entering credentials step in [Install Tuya Integration](.././docs/install.md).| 8 | | 2406 | skill id invalid |
  • Make sure you use the Tuya Smart or SmartLife app account to log in. Also, choose the right data center endpoint related to your country region. For more details, please check [Mappings Between OEM App Accounts and Data Centers](https://developer.tuya.com/en/docs/iot/oem-app-data-center-distributed?id=Kafi0ku9l07qb).
  • Your cloud project on the [Tuya IoT Development Platform](https://iot.tuya.com) should be created after May 25, 2021. Otherwise, you need to create a new project. For more information, see [Operation on the Tuya IoT Development Platform](https://developer.tuya.com/en/docs/iot/migrate-from-an-older-version?id=Kamee9wtbd00b#title-3-Operation%20on%20the%20Tuya%20IoT%20Platform).
| 9 | | 28841105 | No permissions. This project is not authorized to call this API | Insufficient API permissions. You need to subscribe to the required [API services](https://developer.tuya.com/en/docs/iot/applying-for-api-group-permissions?id=Ka6vf012u6q76#title-2-Subscribe%20to%20API%20services) and [authorize](https://developer.tuya.com/en/docs/iot/applying-for-api-group-permissions?id=Ka6vf012u6q76#title-3-Authorize%20project%20to%20call%20APIs) your cloud project to use these API services. The following API services are required.
  • Authorization
  • IoT Core
  • Smart Home Scene Linkage
  • IoT Data Analytics
  • Device Status Notification
| 10 | -------------------------------------------------------------------------------- /docs/faq.md: -------------------------------------------------------------------------------- 1 | # Tuya Integration FAQs 2 | 3 | Q1: I got an error saying 'Config flow could not be loaded' when setting up the Tuya integration. How to fix it? 4 | 5 | 6 | 7 | - You might have added Tuya v2 to Home Assistant. Tuya v2 is not compatible with the Tuya integration. 8 | 9 | - Go to `custom_components` under the Home Assistant directory and delete the `tuya_v2` folder. Restart Home Assistant and try to install the integration again. 10 | 11 | Install Tuya Integration 12 | 13 | Q2: I got an error shown in the following screenshot when I tried to scan a QR code to link my devices to my cloud project. How to fix it? 14 | 15 | 16 | 17 | - This is because the data center you selected for your cloud project cannot serve the region of your app account. You must switch to the correct data center and scan the QR code again. 18 | 19 | 1. Here is how to find the region: open the mobile app you use and tap **Me** > **Setting** > **Account and Security** > **Region**. 20 | 21 | 22 | 23 | 2. See [Mappings Between OEM App Accounts and Data Centers](https://developer.tuya.com/en/docs/iot/oem-app-data-center-distributed?id=Kafi0ku9l07qb) and find the data center that can serve your region. 24 | 25 | 3. (Optional) If you do not find the data center you want to use, click the **Overview** tab and then **Edit** to add data centers. 26 | 27 | 28 | 29 | 4. Click the **Devices** tab > **Link Tuya App Account**. Select the correct data center from the drop-down menu in the top right corner and click **Add App Account**. 30 | 31 | ![Image](https://airtake-public-data-1254153901.cos.ap-shanghai.myqcloud.com/content-platform/hestia/1634631514880ec6c4d6d.png) 32 | 33 | 5. Scan the QR code again to link devices. 34 | 35 | Q3: Will I be billed after the free trial of the API service expires? 36 | 37 | - After your API service expires, go to **Cloud** > **My Services** on the [Tuya IoT Development Platform](https://iot.tuya.com) to request extending your API service by up to 6 months. 38 | 39 | 1. Click **Extend Trial Period**. 40 | 41 | 42 | 43 | 2. Complete this form. 44 | 45 | 46 | 47 | 3. You will get the result within one working day. 48 | 49 | 50 | 51 | - The Trial Edition allows you to use all free API services but puts limits on the quota of API calls. For more information about the quota, see [Pricing](https://developer.tuya.com/en/docs/iot/membership-service?id=K9m8k45jwvg9j). 52 | 53 | Q4: Can I request Tuya's cloud services from an IP address outside the data center region? 54 | 55 | Please note that data transfer across regions has a risk of violation of the data security regulations. If you request Tuya's cloud services from an IP address outside the data center region, you are at risk of illegally transferring data. For example, using an IP address in the U.S.A. to access cloud services in China's data centers will be regarded as data transfer across regions, and vice versa. Tuya will completely prohibit cross-region API calls and message subscriptions. Please deploy your cloud services properly to ensure data security. 56 | -------------------------------------------------------------------------------- /docs/get_log.md: -------------------------------------------------------------------------------- 1 | # How to Get the Log 2 | 3 | [![En](https://img.shields.io/badge/Docs-English-orange)](https://github.com/tuya/tuya-home-assistant/wiki/How-to-Get-the-Log) [![Zh](https://img.shields.io/badge/Docs-中文-orange)](https://github.com/tuya/tuya-home-assistant/wiki/%E5%A6%82%E4%BD%95%E8%8E%B7%E5%8F%96%E6%97%A5%E5%BF%97) 4 | 5 | With Home Assistant **logger** integration, we can get tuya integration's log which can help us fix bugs and develop new device drivers. 6 | 7 | Add the following to your **configuration.yaml** file: 8 | ```python 9 | logger: 10 | default: critical 11 | logs: 12 | homeassistant.components.tuya: debug 13 | ``` 14 | Then you can get the log from **home-assistant.log** 15 | 16 | 17 | 18 | or **Configuration/Logs** with "LOAD FULL HOME ASSISTANT LOG" 19 | 20 | 21 | 22 | -------------------------------------------------------------------------------- /docs/install.md: -------------------------------------------------------------------------------- 1 | # Install Tuya Integration 2 | 3 | This topic describes how to install and use the official Tuya integration in Home Assistant. 4 | 5 | ## Prerequisites 6 | 7 | * You have created a cloud project of Smart Home type on the [Tuya IoT Development Platform](https://iot.tuya.com/), added at least one real device or one virtual device, and authorized your project to use the required API services. For more information, see [Configuration Wizard of Smart Home PaaS](https://developer.tuya.com/en/docs/iot/Platform_Configuration_smarthome?id=Kamcgamwoevrx). 8 | 9 | > **Note**: If your cloud project was created before May 25, 2021, you need to perform project migration. For more information, see [How to Migrate to the Tuya Home Assistant Integration](https://developer.tuya.com/en/docs/iot/migrate-from-an-older-version?id=Kamee9wtbd00b#title-3-Operation%20on%20the%20Tuya%20IoT%20Platform). 10 | 11 | * You have installed Python 3.8 (including python3-dev) or a later version on your system. 12 | 13 | 14 | ## Set up 15 | 16 | After you have installed Home Assistant Core, you can search for and set up the Tuya integration in Home Assistant. 17 | 18 | > **Note**: 19 | Only Home Assistant 2021.10.4 and later versions support the official Tuya integration. 20 | 21 | 22 | 23 | 1. Enter `localhost:8123` into the address bar in your browser and hit Enter to connect to Home Assistant. 24 | 2. Register and log in. 25 | 3. Click **Configuration** > **Integrations**. 26 | 27 | Integrations 28 | 29 | 4. On the **Integrations** page in the configurations panel, click the **+** button in the lower right and search for Tuya. 30 | Add integration 31 | 32 | 5. Select **Tuya** and set up the integration. 33 | 34 | 35 | 36 | 6. Enter your Tuya credentials. 37 | 38 | Smart Home 39 | 40 | | Fields | Description | 41 | | ------- | -------- | 42 | | Country | Select the region of your account of the Tuya Smart app or Smart Life app.
**Note**: Open the mobile app you use and tap **Me** > **Setting** > **Account and Security** > **Region**. | 43 | | Tuya IoT Access ID and Tuya IoT Access Secret | Go to the [Tuya IoT Development Platform](https://iot.tuya.com/cloud/) and select your cloud project. Click the **Overview** tab and find the **Access ID** and **Access Secret** in the **Authorization Key** area. | 44 | | Account | Your account of the Tuya Smart app or Smart Life app.
Attention:Do not use the Tuya IoT Development platform account to log in. | 45 | | Password | Your password of the Tuya Smart app or Smart Life app. | 46 | 47 | > **Note**: 48 | The mobile app mentioned in the above table must be the one you use to scan the QR code for linking devices to your cloud project on the [Tuya IoT Development Platform](https://iot.tuya.com/). 49 | 50 | 7. Click **Submit**. 51 | 52 | Click **Overview** in the sidebar on the left. You will find all the smart devices linked to your cloud project created on the [Tuya IoT Development Platform](https://iot.tuya.com/). 53 | 54 | ![Image](https://airtake-public-data-1254153901.cos.ap-shanghai.myqcloud.com/content-platform/hestia/1634631514c040ab52f07.png) -------------------------------------------------------------------------------- /docs/not_supported_devices.md: -------------------------------------------------------------------------------- 1 | # Not Supported Device Category 2 | 3 | | First Class Category | category code | category[en] | HA Platforms | Product ID | Product Name [en] | Product Name [cn] | 4 | |---|---|---|---|---|---|---| 5 | | Electrician Category | wk | Thermostat | Climate | IAYz2WK1th0cMLmL | Boyi Thermostat (Heating) | 柏益温控器(采暖) | -------------------------------------------------------------------------------- /docs/platform_configuration.md: -------------------------------------------------------------------------------- 1 | # Tuya IoT Platform Configuration Guide 2 | 3 | This topic describes how to create a project on the [Tuya IoT Platform](https://iot.tuya.com/) and link devices to this project with an account of the Tuya Smart app or Smart Life app. 4 | 5 | ## Prerequisites 6 | 7 | You have [registered](https://developer.tuya.com/en/docs/iot/tuya-smart-app-smart-life-app-advantages?id=K989rqa49rluq#title-3-Account) with the **Tuya Smart** app or **Smart Life** app. 8 | 9 | ## Create a project 10 | 11 | 1. Log in to the [Tuya IoT Development Platform](https://iot.tuya.com/). 12 | 2. In the left navigation pane, click **Cloud**. 13 | 3. On the page that appears, click **Create Cloud Project**. 14 | 4. In the **Create Cloud Project** dialog, set the required parameters. 15 | 16 | | Parameters | Description | 17 | |:----|:----| 18 | | Project Name | User-defined | 19 | | Description | User-defined | 20 | | Industry | Select one as per your needs. | 21 | | Development Method | Select **Smart Home**. | 22 | | Data Center | Select the correct data center to serve your project. For more information, see [Mappings Between OEM App Accounts and Data Centers](https://developer.tuya.com/en/docs/iot/oem-app-data-center-distributed?id=Kafi0ku9l07qb). | 23 | 24 | 25 | 26 | 5. Click **Create** to continue with project configuration. 27 | 6. In the **Authorize API Services** dialog, select **Device Status Notification**. 28 | 29 | 30 | 31 | 7. Click **Authorize**. 32 | 33 | ## Get authorization key 34 | 35 | Click the newly created project to enter the **Overview** page and get the **Authorization Key** used to make API requests. 36 | 37 | 38 | 39 | ## Link devices by app account 40 | 41 | 42 | 1. Click the **Devices** tab. 43 | 2. Choose **Link Tuya App Account** > **Add App Account**. A QR code will appear. 44 | 45 | ![Image](https://airtake-public-data-1254153901.cos.ap-shanghai.myqcloud.com/content-platform/hestia/16346291664e386e176aa.png) 46 | 47 | 48 | 49 | 3. Scan the QR code with the **Tuya Smart** app or **Smart Life** app. 50 | 51 | > **important**: 52 | The data center selected for your cloud project must be capable of serving the region of your app account. Here is how to find the region: open the mobile app you use and tap **Me** > **Setting** > **Account and Security** > **Region**. For more information, see [Mappings Between OEM App Accounts and Data Centers](https://developer.tuya.com/en/docs/iot/oem-app-data-center-distributed?id=Kafi0ku9l07qb). 53 | 54 | ![Mappings](https://airtake-public-data-1254153901.cos.ap-shanghai.myqcloud.com/content-platform/hestia/1634629166d85e498a612.png) 55 | 56 | 4. Tap **Confirm** on the app. 57 | 58 | 5. Click **All Devices**. You will find all your smart devices that have been added to this mobile app are listed here. 59 | 60 | ## Mappings between regions and data centers 61 | 62 | Make sure the **data center** you select for your cloud project can serve the **region** of your app account. 63 | 64 | - Region: the region you have selected when you register with the Tuya Smart app or Smart Life app. Here is how to find the region: open the mobile app you use and tap **Me** > **Setting** > **Account and Security** > **Region**. 65 | 66 | 67 | 68 | 69 | - Data center: The server that your cloud project is hosted on. You must select the correct data center that can serve your **region**. Otherwise, your devices cannot be connected to the [Tuya IoT Development Platform](https://iot.tuya.com/). 70 | 71 | 72 | 73 | For more information, see [Mappings Between OEM App Accounts and Data Centers](https://developer.tuya.com/en/docs/iot/oem-app-data-center-distributed?id=Kafi0ku9l07qb). 74 | -------------------------------------------------------------------------------- /docs/raspberryPi_setup.md: -------------------------------------------------------------------------------- 1 | # Set up Home Assistant on a Raspberry Pi 2 | 3 | [![En](https://img.shields.io/badge/Docs-English-orange)](https://github.com/tuya/tuya-home-assistant/wiki/Set-up-Home-Assistant-on-a-Raspberry-Pi) [![Zh](https://img.shields.io/badge/Docs-中文-orange)](https://github.com/tuya/tuya-home-assistant/wiki/%E5%9F%BA%E4%BA%8E%E6%A0%91%E8%8E%93%E6%B4%BE%E6%90%AD%E5%BB%BA-Home-Assistant-%E5%BC%80%E5%8F%91%E7%8E%AF%E5%A2%83) 4 | 5 | This tutorial describes how to install Home Assistant Core on Raspberry Pi to get started with Home Assistant and set up the development environment. 6 | 7 | 8 | Home Assistant is a Python-based open-source smart home system. It supports connection to smart devices across different platforms, which allows you to control a connected home with one system. 9 | We use Home Assistant Core (recommended for developers) to install Home Assistant OS and runs the program in Ubuntu Server. For more information about other installation methods, see the instructions on [Home Assistant](https://www.home-assistant.io/installation/). 10 | 11 | ## Preparation 12 | 13 | ### Prerequisites 14 | 15 | You have installed Python on your system. Python 3.8.0 or later is recommended. 16 | 17 | ### Prepare hardware and software 18 | 19 | | Hardware/Software | Description | 20 | |:----|:----| 21 | | Computer | A computer | 22 | | Device to run Home Assistant | Raspberry Pi 3 or later
This tutorial uses the 64-bit Raspberry Pi 4, with 8 GB RAM. | 23 | | Environment | Ubuntu Server 20.04.2 LTS | 24 | | Wireless router | One piece | 25 | | microSD card | One piece | 26 | | SD Card reader | One piece | 27 | 28 | ## Steps 29 | ### Install the environment 30 | 1. Download and install [Raspberry Pi Imager 1.6](https://downloads.raspberrypi.org/imager/imager_1.6.dmg). 31 | 32 | 2. Insert the microSD card into your computer. 33 | 34 | 3. Start Raspberry Pi Imager 1.6 and click **CHOOSE OS**. 35 | 36 | 37 | 4. In the **Operating System** dialog box, select **Other general purpose OS** > **Ubuntu** > **Ubuntu Server 20.04.2 LTS (RPi 3/4/400)**. 38 | 39 | 40 | 5. On the page of **Raspberry Pi Imager 1.6**, click **CHOOSE STORAGE** and select your microSD card. 41 | 42 | 43 | 6. Click **WRITE** to flash the SD card with Raspberry Pi Imager. 44 | 45 | 46 | 7. Waiting for flashing completed. 47 | 48 | 49 | 8. Remove the microSD card from your Mac and insert it into the Raspberry Pi. 50 | 51 | 52 | ### Connect Raspberry Pi to the internet 53 | You can connect Raspberry Pi to the internet through a wired Ethernet connection (recommended) or a Wi-Fi network. 54 | * Wired connection 55 | Use an Ethernet cable to connect Raspberry Pi to the router. 56 | * Wi-Fi connection 57 | 1. Insert the flashed microSD card into your computer. 58 | 2. Open **Finder** on your Mac and click **Locations** > **system-boot**. 59 | 3. Open the **network-config** file with a text editor. Change the `myhomewifi` field to the SSID of your router and the `S3kr1t` field to the password of your router. 60 | ``` 61 | wifis: 62 | wlan0: 63 | dhcp4: true 64 | optional: true 65 | access-points: 66 | myhomewifi: 67 | password: "S3kr1t" 68 | ``` 69 | 4. Save the file and exit. 70 | 5. Insert the microSD card into Raspberry Pi. 71 | 72 | ### Start Ubuntu Server 73 | 1. Find your Raspberry Pi's IP address on the local network from your router setup page. This tutorial uses `192.168.1.140` as an example. 74 | 2. Make sure your computer and Raspberry Pi connect to the same LAN. Execute the following command to connect to Raspberry Pi. 75 | ``` 76 | ssh ubuntu@192.168.1.140 77 | ``` 78 | 3. Enter the default password and then enter the new password twice to reset the password. 79 | > **Note**: The default username and password of Ubuntu Server both are `ubuntu`. 80 | 81 | ### Install Home Assistant 82 | #### Install dependency 83 | 84 | Execute the following three commands respectively to install dependencies. The installation process will take some time. 85 | 86 | ``` 87 | sudo apt-get update 88 | ``` 89 | 90 | ``` 91 | sudo apt-get upgrade -y 92 | ``` 93 | 94 | ``` 95 | sudo apt-get install -y python3 python3-dev python3-venv python3-pip libffi-dev libssl-dev libjpeg-dev zlib1g-dev autoconf build-essential libopenjp2-7 libtiff5 --fix-missing 96 | ``` 97 | 98 | 99 | #### Create virtual environment 100 | 101 | 1. Create a directory for the installation of Home Assistant. 102 | 103 | ``` 104 | mkdir ~/hass 105 | ``` 106 | 2. Create and activate the virtual environment for Home Assistant. 107 | 1. Go to the directory. 108 | ``` 109 | cd ~/hass 110 | ``` 111 | 2. Create virtual environment. 112 | ``` 113 | python3 -m venv . 114 | ``` 115 | 3. Activate virtual environment. 116 | ``` 117 | source bin/activate 118 | ``` 119 | 120 | #### Install Home Assistant 121 | 122 | 1. Install Python package. 123 | ``` 124 | python3 -m pip install wheel 125 | ``` 126 | 2. Install Home Assistant Core. 127 | ``` 128 | pip3 install homeassistant 129 | ``` 130 | 131 | 132 | #### Start Home Assistant 133 | Execute the following command to start Home Assistant. 134 | ``` 135 | hass 136 | ``` 137 | When you start Home Assistant for the first time, the system will create `~/.homeassistant` directory to store configuration files and install required dependencies. This process will take some time. 138 | 139 | Visit in a browser by using a device in the same LAN. If the Home Assistant homepage appears, it indicates that installation is successful. 140 | > **Note**: The IP address here is only for demonstration. Use your Raspberry Pi's IP address. 141 | 142 | 143 | 144 | ### Install Samba 145 | We use Samba to share `.homeassistant` directory in the LAN. You can modify the `.homeassistant` file directly on your computer, which will help the development of drivers. 146 | 147 | 1. Install Samba. 148 | ``` 149 | sudo apt-get install samba samba-common-bin 150 | ``` 151 | 2. Configure `smb.conf` file. 152 | > **Note**: Yo must specify an absolute path to `smb.conf`, such as `/home/ubuntu/.homeassistant`. 153 | 1. Edit the file. 154 | ``` 155 | sudo vi /etc/samba/smb.conf 156 | ``` 157 | 2. Add the following line of code to the bottom of the configuration file. 158 | ``` 159 | [pi] 160 | path = /home/ubuntu/.homeassistant 161 | writeable=Yes 162 | create mask=0777 163 | directory mask=0777 164 | public=no 165 | ``` 166 | 3. Save the file. 167 | 3. Add a Samba account. 168 | > **Note**: When you use the `sudo smbpasswd -a` command to create a Samba user, the account must be a Linux system account, such as ubuntu. 169 | 1. Execute the following command line. 170 | ``` 171 | sudo smbpasswd -a ubuntu 172 | ``` 173 | 2. Enter a password, such as `a123456`. 174 | 4. Restart Samba to make the configuration effective. 175 | ``` 176 | sudo systemctl restart smbd 177 | ``` 178 | Once Samba is installed, the development environment is set up. 179 | 180 | ### Access Home Assistant folder through Samba 181 | 182 | 1. Open **Finder** on your Mac. 183 | 2. In the top-left corner of the screen, click **Go** > **Connect to Server**. 184 | 3. In the dialog box, enter your Raspberry Pi's IP address and click **Connect**. 185 | ``` 186 | smb://192.168.1.140/pi 187 | ``` 188 | > **Note**: The IP address here is only for demonstration. Use your Raspberry Pi's IP address. 189 | 190 | 191 | 192 | 4. In the dialog box, enter the account and password of the Samba user. See the following example. 193 | * Name: ubuntu 194 | * Password: a123456 195 | 196 | 5. Click **Connect** to access the Home Assistant folder shared with Raspberry Pi. 197 | 198 | ![Browse folder](https://airtake-public-data-1254153901.cos.ap-shanghai.myqcloud.com/content-platform/hestia/16191665814cf607ed248.jpg) 199 | 200 | ## Summary 201 | You can access the Home Assistant folder through Samba and proceed with the development of drivers. For more information, see [Develop Tuya-Compatible Home Assistant Drivers](https://developer.tuya.com/en/demo/devhomeassistantplugin?count=0.7387204857679788&_source=dc22d62a9924627fd8db9b750d54d93e). 202 | -------------------------------------------------------------------------------- /docs/regions_dataCenters.md: -------------------------------------------------------------------------------- 1 | # Country Regions and Data Center 2 | 3 | This topic describes the data centers in which Tuya Smart or Smart Life app accounts are served based on the app account locations. 4 | 5 | ## Correspondence table of regions and data centers 6 | 7 | > **Note**: The countries or regions not listed in the following tables are mapped to **Western America Data Center**. 8 | 9 | | Country code | Country or region | Data Center | Endpoint | 10 | |:----|:----|:----|:----| 11 | | 1 | United States | Western America Data Center | https://openapi.tuyaus.com | 12 | | 1 | Canada | Western America Data Center | https://openapi.tuyaus.com | 13 | | 1787 | Puerto Rico | Western America Data Center | https://openapi.tuyaus.com | 14 | | 1809 | Dominican Republic (1-809) | Western America Data Center | https://openapi.tuyaus.com | 15 | | 1829 | Dominican Republic (1-829) | Western America Data Center | https://openapi.tuyaus.com | 16 | | 1849 | Dominican Republic (1-849) | Western America Data Center | https://openapi.tuyaus.com | 17 | | 502 | Guatemala | Western America Data Center | https://openapi.tuyaus.com | 18 | | 51 | Peru | Western America Data Center | https://openapi.tuyaus.com | 19 | | 52 | Mexico | Western America Data Center | https://openapi.tuyaus.com | 20 | | 54 | Argentina | Western America Data Center | https://openapi.tuyaus.com | 21 | | 55 | Brazil | Western America Data Center | https://openapi.tuyaus.com | 22 | | 56 | Chile | Western America Data Center | https://openapi.tuyaus.com | 23 | | 57 | Colombia | Western America Data Center | https://openapi.tuyaus.com | 24 | | 58 | Venezuela | Western America Data Center | https://openapi.tuyaus.com | 25 | | 591 | Bolivia | Western America Data Center | https://openapi.tuyaus.com | 26 | | 593 | Ecuador | Western America Data Center | https://openapi.tuyaus.com | 27 | | 595 | Paraguay | Western America Data Center | https://openapi.tuyaus.com | 28 | | 597 | Suriname | Western America Data Center | https://openapi.tuyaus.com | 29 | | 598 | Uruguay | Western America Data Center | https://openapi.tuyaus.com | 30 | | 5999 | Curaçao | Western America Data Center | https://openapi.tuyaus.com | 31 | | 60 | Malaysia | Western America Data Center | https://openapi.tuyaus.com | 32 | | 62 | Indonesia | Western America Data Center | https://openapi.tuyaus.com | 33 | | 63 | Philippines | Western America Data Center | https://openapi.tuyaus.com | 34 | | 64 | New Zealand | Western America Data Center | https://openapi.tuyaus.com | 35 | | 66 | Thailand | Western America Data Center | https://openapi.tuyaus.com | 36 | | 81 | Japan | Western America Data Center | https://openapi.tuyaus.com | 37 | | 82 | South Korea | Western America Data Center | https://openapi.tuyaus.com | 38 | | 84 | Vietnam | Western America Data Center | https://openapi.tuyaus.com | 39 | | 852 | Hong Kong (People’s Republic of China) | Western America Data Center | https://openapi.tuyaus.com | 40 | | 853 | Macao (People’s Republic of China) | Western America Data Center | https://openapi.tuyaus.com | 41 | | 886 | Taiwan (People’s Republic of China) | Western America Data Center | https://openapi.tuyaus.com | 42 | | 95 | Myanmar | Western America Data Center | https://openapi.tuyaus.com | 43 | | 239 | São Tomé and Príncipe | Western America Data Center | https://openapi.tuyaus.com | 44 | | 245 | Guinea-Bissau | Western America Data Center | https://openapi.tuyaus.com | 45 | | 246 | British Indian Ocean Territory | Western America Data Center | https://openapi.tuyaus.com | 46 | | 500 | Falkland Islands | Western America Data Center | https://openapi.tuyaus.com | 47 | | 594 | French Guiana | Western America Data Center | https://openapi.tuyaus.com | 48 | | 670 | Timor-Leste | Western America Data Center | https://openapi.tuyaus.com | 49 | | 672 | Norfolk Island | Western America Data Center | https://openapi.tuyaus.com | 50 | | 674 | Nauru | Western America Data Center | https://openapi.tuyaus.com | 51 | | 675 | Papua New Guinea | Western America Data Center | https://openapi.tuyaus.com | 52 | | 677 | Solomon Islands | Western America Data Center | https://openapi.tuyaus.com | 53 | | 678 | Vanuatu | Western America Data Center | https://openapi.tuyaus.com | 54 | | 682 | Cook Islands | Western America Data Center | https://openapi.tuyaus.com | 55 | | 683 | Niue | Western America Data Center | https://openapi.tuyaus.com | 56 | | 686 | Kiribati | Western America Data Center | https://openapi.tuyaus.com | 57 | | 690 | Tokelau | Western America Data Center | https://openapi.tuyaus.com | 58 | | 970 | Palestine | Western America Data Center | https://openapi.tuyaus.com | 59 | | 1721 | Sint Maarten | Western America Data Center | https://openapi.tuyaus.com | 60 | | 4779 | Svalbard and Jan Mayen | Western America Data Center | https://openapi.tuyaus.com | 61 | | 35818 | Åland Islands | Western America Data Center | https://openapi.tuyaus.com | 62 | | 1242 | Bahamas | Central Europe Data Center | https://openapi.tuyaeu.com | 63 | | 1246 | Barbados | Central Europe Data Center | https://openapi.tuyaeu.com | 64 | | 1264 | Anguilla | Central Europe Data Center | https://openapi.tuyaeu.com | 65 | | 1268 | Antigua and Barbuda | Central Europe Data Center | https://openapi.tuyaeu.com | 66 | | 1284 | British Virgin Islands | Central Europe Data Center | https://openapi.tuyaeu.com | 67 | | 1340 | U.S. Virgin Islands | Central Europe Data Center | https://openapi.tuyaeu.com | 68 | | 1345 | Cayman Islands | Central Europe Data Center | https://openapi.tuyaeu.com | 69 | | 1441 | Bermuda | Central Europe Data Center | https://openapi.tuyaeu.com | 70 | | 1473 | Grenada | Central Europe Data Center | https://openapi.tuyaeu.com | 71 | | 1649 | Turks and Caicos Islands | Central Europe Data Center | https://openapi.tuyaeu.com | 72 | | 1664 | Montserrat | Central Europe Data Center | https://openapi.tuyaeu.com | 73 | | 1670 | Northern Mariana Islands | Central Europe Data Center | https://openapi.tuyaeu.com | 74 | | 1671 | Guam | Central Europe Data Center | https://openapi.tuyaeu.com | 75 | | 1684 | American Samoa | Central Europe Data Center | https://openapi.tuyaeu.com | 76 | | 1758 | Saint Lucia | Central Europe Data Center | https://openapi.tuyaeu.com | 77 | | 1767 | Dominica | Central Europe Data Center | https://openapi.tuyaeu.com | 78 | | 1784 | Saint Vincent and the Grenadines | Central Europe Data Center | https://openapi.tuyaeu.com | 79 | | 1868 | Trinidad and Tobago | Central Europe Data Center | https://openapi.tuyaeu.com | 80 | | 1869 | Saint Kitts and Nevis | Central Europe Data Center | https://openapi.tuyaeu.com | 81 | | 1876 | Jamaica | Central Europe Data Center | https://openapi.tuyaeu.com | 82 | | 20 | Egypt | Central Europe Data Center | https://openapi.tuyaeu.com | 83 | | 212 | Morocco | Central Europe Data Center | https://openapi.tuyaeu.com | 84 | | 213 | Algeria | Central Europe Data Center | https://openapi.tuyaeu.com | 85 | | 216 | Tunisia | Central Europe Data Center | https://openapi.tuyaeu.com | 86 | | 218 | Libya | Central Europe Data Center | https://openapi.tuyaeu.com | 87 | | 220 | The Gambia | Central Europe Data Center | https://openapi.tuyaeu.com | 88 | | 221 | Senegal | Central Europe Data Center | https://openapi.tuyaeu.com | 89 | | 222 | Mauritania | Central Europe Data Center | https://openapi.tuyaeu.com | 90 | | 223 | Mali | Central Europe Data Center | https://openapi.tuyaeu.com | 91 | | 224 | Guinea | Central Europe Data Center | https://openapi.tuyaeu.com | 92 | | 225 | Côte d’Ivoire | Central Europe Data Center | https://openapi.tuyaeu.com | 93 | | 226 | Burkina Faso | Central Europe Data Center | https://openapi.tuyaeu.com | 94 | | 227 | Niger | Central Europe Data Center | https://openapi.tuyaeu.com | 95 | | 228 | Togo | Central Europe Data Center | https://openapi.tuyaeu.com | 96 | | 229 | Benin | Central Europe Data Center | https://openapi.tuyaeu.com | 97 | | 230 | Mauritius | Central Europe Data Center | https://openapi.tuyaeu.com | 98 | | 231 | Liberia | Central Europe Data Center | https://openapi.tuyaeu.com | 99 | | 232 | Sierra Leone | Central Europe Data Center | https://openapi.tuyaeu.com | 100 | | 233 | Ghana | Central Europe Data Center | https://openapi.tuyaeu.com | 101 | | 234 | Nigeria | Central Europe Data Center | https://openapi.tuyaeu.com | 102 | | 235 | Chad | Central Europe Data Center | https://openapi.tuyaeu.com | 103 | | 236 | Central African Republic | Central Europe Data Center | https://openapi.tuyaeu.com | 104 | | 237 | Cameroon | Central Europe Data Center | https://openapi.tuyaeu.com | 105 | | 238 | Cabo Verde | Central Europe Data Center | https://openapi.tuyaeu.com | 106 | | 240 | Equatorial Guinea | Central Europe Data Center | https://openapi.tuyaeu.com | 107 | | 241 | Gabon | Central Europe Data Center | https://openapi.tuyaeu.com | 108 | | 242 | Congo | Central Europe Data Center | https://openapi.tuyaeu.com | 109 | | 243 | Congo (DRC) | Central Europe Data Center | https://openapi.tuyaeu.com | 110 | | 244 | Angola | Central Europe Data Center | https://openapi.tuyaeu.com | 111 | | 248 | Seychelles | Central Europe Data Center | https://openapi.tuyaeu.com | 112 | | 250 | Rwanda | Central Europe Data Center | https://openapi.tuyaeu.com | 113 | | 251 | Ethiopia | Central Europe Data Center | https://openapi.tuyaeu.com | 114 | | 252 | Somalia | Central Europe Data Center | https://openapi.tuyaeu.com | 115 | | 253 | Djibouti | Central Europe Data Center | https://openapi.tuyaeu.com | 116 | | 254 | Kenya | Central Europe Data Center | https://openapi.tuyaeu.com | 117 | | 255 | Tanzania | Central Europe Data Center | https://openapi.tuyaeu.com | 118 | | 256 | Uganda | Central Europe Data Center | https://openapi.tuyaeu.com | 119 | | 257 | Burundi | Central Europe Data Center | https://openapi.tuyaeu.com | 120 | | 258 | Mozambique | Central Europe Data Center | https://openapi.tuyaeu.com | 121 | | 260 | Zambia | Central Europe Data Center | https://openapi.tuyaeu.com | 122 | | 261 | Madagascar | Central Europe Data Center | https://openapi.tuyaeu.com | 123 | | 262 | Mayotte | Central Europe Data Center | https://openapi.tuyaeu.com | 124 | | 263 | Zimbabwe | Central Europe Data Center | https://openapi.tuyaeu.com | 125 | | 264 | Namibia | Central Europe Data Center | https://openapi.tuyaeu.com | 126 | | 265 | Malawi | Central Europe Data Center | https://openapi.tuyaeu.com | 127 | | 266 | Lesotho | Central Europe Data Center | https://openapi.tuyaeu.com | 128 | | 267 | Botswana | Central Europe Data Center | https://openapi.tuyaeu.com | 129 | | 268 | Swaziland | Central Europe Data Center | https://openapi.tuyaeu.com | 130 | | 269 | Comoros | Central Europe Data Center | https://openapi.tuyaeu.com | 131 | | 27 | South Africa | Central Europe Data Center | https://openapi.tuyaeu.com | 132 | | 291 | Eritrea | Central Europe Data Center | https://openapi.tuyaeu.com | 133 | | 297 | Aruba | Central Europe Data Center | https://openapi.tuyaeu.com | 134 | | 298 | Faroe Islands | Central Europe Data Center | https://openapi.tuyaeu.com | 135 | | 299 | Greenland | Central Europe Data Center | https://openapi.tuyaeu.com | 136 | | 30 | Greece | Central Europe Data Center | https://openapi.tuyaeu.com | 137 | | 31 | Netherlands | Central Europe Data Center | https://openapi.tuyaeu.com | 138 | | 32 | Belgium | Central Europe Data Center | https://openapi.tuyaeu.com | 139 | | 33 | France | Central Europe Data Center | https://openapi.tuyaeu.com | 140 | | 34 | Spain | Central Europe Data Center | https://openapi.tuyaeu.com | 141 | | 350 | Gibraltar | Central Europe Data Center | https://openapi.tuyaeu.com | 142 | | 351 | Portugal | Central Europe Data Center | https://openapi.tuyaeu.com | 143 | | 352 | Luxembourg | Central Europe Data Center | https://openapi.tuyaeu.com | 144 | | 353 | Ireland | Central Europe Data Center | https://openapi.tuyaeu.com | 145 | | 354 | Iceland | Central Europe Data Center | https://openapi.tuyaeu.com | 146 | | 355 | Albania | Central Europe Data Center | https://openapi.tuyaeu.com | 147 | | 356 | Malta | Central Europe Data Center | https://openapi.tuyaeu.com | 148 | | 357 | Cyprus | Central Europe Data Center | https://openapi.tuyaeu.com | 149 | | 358 | Finland | Central Europe Data Center | https://openapi.tuyaeu.com | 150 | | 359 | Bulgaria | Central Europe Data Center | https://openapi.tuyaeu.com | 151 | | 36 | Hungary | Central Europe Data Center | https://openapi.tuyaeu.com | 152 | | 370 | Lithuania | Central Europe Data Center | https://openapi.tuyaeu.com | 153 | | 371 | Latvia | Central Europe Data Center | https://openapi.tuyaeu.com | 154 | | 372 | Estonia | Central Europe Data Center | https://openapi.tuyaeu.com | 155 | | 373 | Moldova | Central Europe Data Center | https://openapi.tuyaeu.com | 156 | | 374 | Armenia | Central Europe Data Center | https://openapi.tuyaeu.com | 157 | | 375 | Belarus | Central Europe Data Center | https://openapi.tuyaeu.com | 158 | | 376 | Andorra | Central Europe Data Center | https://openapi.tuyaeu.com | 159 | | 377 | Monaco | Central Europe Data Center | https://openapi.tuyaeu.com | 160 | | 378 | San Marino | Central Europe Data Center | https://openapi.tuyaeu.com | 161 | | 379 | Vatican City | Central Europe Data Center | https://openapi.tuyaeu.com | 162 | | 380 | Ukraine | Central Europe Data Center | https://openapi.tuyaeu.com | 163 | | 381 | Serbia | Central Europe Data Center | https://openapi.tuyaeu.com | 164 | | 382 | Montenegro | Central Europe Data Center | https://openapi.tuyaeu.com | 165 | | 385 | Croatia | Central Europe Data Center | https://openapi.tuyaeu.com | 166 | | 386 | Slovenia | Central Europe Data Center | https://openapi.tuyaeu.com | 167 | | 387 | Bosnia and Herzegovina | Central Europe Data Center | https://openapi.tuyaeu.com | 168 | | 389 | Macedonian | Central Europe Data Center | https://openapi.tuyaeu.com | 169 | | 39 | Italy | Central Europe Data Center | https://openapi.tuyaeu.com | 170 | | 40 | Romania | Central Europe Data Center | https://openapi.tuyaeu.com | 171 | | 41 | Switzerland | Central Europe Data Center | https://openapi.tuyaeu.com | 172 | | 420 | Czech Republic | Central Europe Data Center | https://openapi.tuyaeu.com | 173 | | 421 | Slovakia | Central Europe Data Center | https://openapi.tuyaeu.com | 174 | | 423 | Liechtenstein | Central Europe Data Center | https://openapi.tuyaeu.com | 175 | | 43 | Austria | Central Europe Data Center | https://openapi.tuyaeu.com | 176 | | 44 | United Kingdom | Central Europe Data Center | https://openapi.tuyaeu.com | 177 | | 45 | Denmark | Central Europe Data Center | https://openapi.tuyaeu.com | 178 | | 46 | Sweden | Central Europe Data Center | https://openapi.tuyaeu.com | 179 | | 47 | Norway | Central Europe Data Center | https://openapi.tuyaeu.com | 180 | | 48 | Poland | Central Europe Data Center | https://openapi.tuyaeu.com | 181 | | 49 | Germany | Central Europe Data Center | https://openapi.tuyaeu.com | 182 | | 501 | Belize | Central Europe Data Center | https://openapi.tuyaeu.com | 183 | | 503 | El Salvador | Central Europe Data Center | https://openapi.tuyaeu.com | 184 | | 504 | Honduras | Central Europe Data Center | https://openapi.tuyaeu.com | 185 | | 505 | Nicaragua | Central Europe Data Center | https://openapi.tuyaeu.com | 186 | | 506 | Costa Rica | Central Europe Data Center | https://openapi.tuyaeu.com | 187 | | 507 | Panama | Central Europe Data Center | https://openapi.tuyaeu.com | 188 | | 508 | Saint Pierre and Miquelon | Central Europe Data Center | https://openapi.tuyaeu.com | 189 | | 509 | Haiti | Central Europe Data Center | https://openapi.tuyaeu.com | 190 | | 590 | Saint Martin | Central Europe Data Center | https://openapi.tuyaeu.com | 191 | | 592 | Guyana | Central Europe Data Center | https://openapi.tuyaeu.com | 192 | | 596 | Martinique | Central Europe Data Center | https://openapi.tuyaeu.com | 193 | | 61 | Australia | Central Europe Data Center | https://openapi.tuyaeu.com | 194 | | 65 | Singapore | Central Europe Data Center | https://openapi.tuyaeu.com | 195 | | 673 | Brunei | Central Europe Data Center | https://openapi.tuyaeu.com | 196 | | 676 | Tonga | Central Europe Data Center | https://openapi.tuyaeu.com | 197 | | 679 | Fiji | Central Europe Data Center | https://openapi.tuyaeu.com | 198 | | 680 | Palau | Central Europe Data Center | https://openapi.tuyaeu.com | 199 | | 681 | Wallis and Futuna | Central Europe Data Center | https://openapi.tuyaeu.com | 200 | | 685 | Samoa | Central Europe Data Center | https://openapi.tuyaeu.com | 201 | | 687 | New Caledonia | Central Europe Data Center | https://openapi.tuyaeu.com | 202 | | 688 | Tuvalu | Central Europe Data Center | https://openapi.tuyaeu.com | 203 | | 689 | French Polynesia | Central Europe Data Center | https://openapi.tuyaeu.com | 204 | | 691 | Federated States of Micronesia | Central Europe Data Center | https://openapi.tuyaeu.com | 205 | | 692 | Marshall Islands | Central Europe Data Center | https://openapi.tuyaeu.com | 206 | | 7 | Russia | Central Europe Data Center | https://openapi.tuyaeu.com | 207 | | 855 | Cambodia | Central Europe Data Center | https://openapi.tuyaeu.com | 208 | | 856 | Laos | Central Europe Data Center | https://openapi.tuyaeu.com | 209 | | 880 | Bangladesh | Central Europe Data Center | https://openapi.tuyaeu.com | 210 | | 90 | Turkey | Central Europe Data Center | https://openapi.tuyaeu.com | 211 | | 92 | Pakistan | Central Europe Data Center | https://openapi.tuyaeu.com | 212 | | 93 | Afghanistan | Central Europe Data Center | https://openapi.tuyaeu.com | 213 | | 94 | Sri Lanka | Central Europe Data Center | https://openapi.tuyaeu.com | 214 | | 960 | Maldives | Central Europe Data Center | https://openapi.tuyaeu.com | 215 | | 961 | Lebanon | Central Europe Data Center | https://openapi.tuyaeu.com | 216 | | 962 | Jordan | Central Europe Data Center | https://openapi.tuyaeu.com | 217 | | 964 | Iraq | Central Europe Data Center | https://openapi.tuyaeu.com | 218 | | 965 | Kuwait | Central Europe Data Center | https://openapi.tuyaeu.com | 219 | | 966 | Saudi Arabia | Central Europe Data Center | https://openapi.tuyaeu.com | 220 | | 967 | Yemen | Central Europe Data Center | https://openapi.tuyaeu.com | 221 | | 968 | Oman | Central Europe Data Center | https://openapi.tuyaeu.com | 222 | | 971 | United Arab Emirates | Central Europe Data Center | https://openapi.tuyaeu.com | 223 | | 972 | Israel | Central Europe Data Center | https://openapi.tuyaeu.com | 224 | | 973 | Bahrain | Central Europe Data Center | https://openapi.tuyaeu.com | 225 | | 974 | Qatar | Central Europe Data Center | https://openapi.tuyaeu.com | 226 | | 975 | Bhutan | Central Europe Data Center | https://openapi.tuyaeu.com | 227 | | 976 | Mongolia | Central Europe Data Center | https://openapi.tuyaeu.com | 228 | | 977 | Nepal | Central Europe Data Center | https://openapi.tuyaeu.com | 229 | | 992 | Tajikistan | Central Europe Data Center | https://openapi.tuyaeu.com | 230 | | 993 | Turkmenistan | Central Europe Data Center | https://openapi.tuyaeu.com | 231 | | 994 | Azerbaijan | Central Europe Data Center | https://openapi.tuyaeu.com | 232 | | 995 | Georgia | Central Europe Data Center | https://openapi.tuyaeu.com | 233 | | 996 | Kyrgyzstan | Central Europe Data Center | https://openapi.tuyaeu.com | 234 | | 998 | Uzbekistan | Central Europe Data Center | https://openapi.tuyaeu.com | 235 | | 91 | India | India Data Center | https://openapi.tuyain.com | 236 | | 86 | China | China Data Center | https://openapi.tuyacn.com | | -------------------------------------------------------------------------------- /docs/supported_devices.md: -------------------------------------------------------------------------------- 1 | # Supported Device Category 2 | 3 | | First Class Category | category code | category[en] | HA Core Supported Version | HA Platforms | 4 | |-----------------------|---------------|----------------------------------|---------------------------|------------------------------------------------------| 5 | | Large Home Appliances | kt | Air conditioner | Release 2021.10 | Climate, Switch, Light | 6 | | Small Home Appliances | cwysj | Pet Water Feeder | Release 2021.10 | Switch | 7 | | | qn | Heater | Release 2021.10 | Climate, Switch, Select, Sensor | 8 | | | sd | Robot Vaccum | Release 2021.11 | Vacuum | 9 | | | fs | Fan | Release 2021.10 | Fan | 10 | | | cl | Curtain | Release 2021.11 | Cover | 11 | | | kj | Air Purifer | Release 2021.10 | Fan, Switch | 12 | | | cs | Dehumidifier | Release 2021.11 | Humidifier | 13 | | | xxj | Diffuser | Release 2021.11 | Switch | 14 | | Electrician Category | kg | Switch | Release 2021.10 | Sensor, Switch, Light, Select | 15 | | | cz | Socket | Release 2021.10 | Sensor, Switch | 16 | | | pc | Power Strip | Release 2021.10 | Sensor, Switch | 17 | | | clkg | Curtain Switch | Release 2021.11 | Cover | 18 | | | jdcljqr | Curtain Robot | Release 2021.11 | Cover | 19 | | | wk | Thermostat | Release 2021.10 | Climate | 20 | | | dlq | Circuit Breaker | Release 2021.10 | Switch | 21 | | | ckmkzq | Garage Door Opener | Release 2021.11 | Cover, Switch | 22 | | Security & Sensors | wsdcg | Temperature and Humidity Sensor | Release 2021.11 | Binary Sensor, Sensor | 23 | | | mcs | Door Window Sensor | Release 2021.10 | Sensor, Binary Sensor | 24 | | | ywbj | Smoke Detector | Release 2021.11 | Sensor, Binary Sensor | 25 | | | rqbj | Gas Detector | Release 2021.11 | Sensor, Binary Sensor | 26 | | | pir | PIR Detector | Release 2021.10 | Sensor, Binary Sensor | 27 | | | sj | Water Detector | Release 2021.11 | Sensor, Binary Sensor | 28 | | | pm25 | PM2.5 Sensor | Release 2021.11 | Binary Sensor, Sensor | 29 | | | hps | Human Presence Sensor | Release 2021.11 | Binary Sensor, Number | 30 | | | sos | Emergency Button | Release 2021.10 | Binary Sensor, Sensor | 31 | | | ldcg | Luminance Sensor | Release 2021.10 | Binary Sensor, Sensor | 32 | | | sp | Smart Camera | Release 2021.11 | Camera, Siren, Switch, Light, Number, Select, Sensor | 33 | | | sgbj | Siren Alarm | Release 2021.11 | Number, Siren, Switch, Select | 34 | | | zd | Vibration Sensor | Release 2021.11 | Sensor, Binary Sensor, Number | 35 | | | co2bj | CO2 Detector | Release 2021.11 | Binary Sensor, Sensor | 36 | | | cobj | CO Detector | Release 2021.11 | Binary Sensor, Sensor | 37 | | | jqbj | Formaldehyde Detector | Release 2021.11 | Binary Sensor, Sensor | 38 | | | jwbj | Methane Detector | Release 2021.11 | Binary Sensor, Sensor | 39 | | | voc | Volatile Organic Compound Sensor | Release 2021.11 | Binary Sensor, Sensor | 40 | | | ylcg | Pressure Sensor | Release 2021.11 | Binary Sensor, Sensor | 41 | | Lighting | dj | Light | Release 2021.10 | Light, Switch | 42 | | | dd | Light Strip | Release 2021.10 | Light | 43 | | | fwl | Ambient light | Release 2021.10 | Light | 44 | | | dc | Light string | Release 2021.10 | Light | 45 | | | xdd | Ceiling Light | Release 2021.10 | Light, Switch | 46 | | | fsd | Ceiling Fan Light | Release 2021.11 | Light | 47 | | | fwd | Ambient Light | Release 2021.11 | Light | 48 | | | gyd | Motion Sensor Light | Release 2021.11 | Light | 49 | | | jsq | Humidifier | Release 2021.10 | Light, humidifier | 50 | | | tgkg | Dimmer Switch | Release 2021.11 | Light, Number, Select | 51 | | | tgq | Dimmer | Release 2021.11 | Light, Number, Select | 52 | | | tyndj | Solar Light | Release 2021.11 | Light, Sensor, Switch | 53 | | | ykq | Remote Control | Release 2021.11 | Light | 54 | | Kitchen Appliances | bh | Smart Kettle | Release 2021.10 | Switch, Number, Sensor | 55 | | | kfj | Coffee Maker | Release 2021.10 | Number, Select | 56 | -------------------------------------------------------------------------------- /docs/supported_devices_cn.md: -------------------------------------------------------------------------------- 1 | # 支持的产品品类 2 | 3 | | 大类 | 品类码 | 品类 | HA支持版本 | HA 平台 | 4 | |-----------------------|---------------|----------------------------------|---------------------------|------------------------------------------------------| 5 | | 大家电 | kt |空调 | Release 2021.10 | Climate, Switch, Light | 6 | | 小家电 | cwysj | 宠物喂食器 | Release 2021.10 | Switch | 7 | | | qn | 取暖器 | Release 2021.10 | Climate, Switch, Select, Sensor | 8 | | | sd | 扫地机器人 | Release 2021.11 | Vacuum | 9 | | | fs | 风扇 | Release 2021.10 | Fan | 10 | | | cl | 窗帘电机 | Release 2021.11 | Cover | 11 | | | kj | 抽湿机 | Release 2021.10 | Fan, Switch | 12 | | | cs | 除湿机 | Release 2021.11 | Humidifier | 13 | | | xxj | 香薰机 | Release 2021.11 | Switch | 14 | | 电工 | kg | 开关 | Release 2021.10 | Sensor, Switch, Light, Select | 15 | | | cz | 插座 | Release 2021.10 | Sensor, Switch | 16 | | | pc | 排插 | Release 2021.10 | Sensor, Switch | 17 | | | clkg | 窗帘开关 | Release 2021.11 | Cover | 18 | | | jdcljqr | 窗帘机器人 | Release 2021.11 | Cover | 19 | | | wk | 温控器 | Release 2021.10 | Climate | 20 | | | dlq | 断路器 | Release 2021.10 | Switch | 21 | | | ckmkzq | 车库门控制器 | Release 2021.11 | Cover, Switch | 22 | | 安防 & 传感 | wsdcg | 温湿度传感器 | Release 2021.11 | Binary Sensor, Sensor | 23 | | | mcs | 门窗传感器 | Release 2021.10 | Sensor, Binary Sensor | 24 | | | ywbj | 烟雾报警器 | Release 2021.11 | Sensor, Binary Sensor | 25 | | | rqbj | 燃气报警器 | Release 2021.11 | Sensor, Binary Sensor | 26 | | | pir | 被动红外检测 | Release 2021.10 | Sensor, Binary Sensor | 27 | | | sj | 水浸检测 | Release 2021.11 | Sensor, Binary Sensor | 28 | | | pm25 | PM2.5 传感器 | Release 2021.11 | Binary Sensor, Sensor | 29 | | | hps | 人体存在传感器 | Release 2021.11 | Binary Sensor, Number | 30 | | | sos | 紧急按钮 | Release 2021.10 | Binary Sensor, Sensor | 31 | | | ldcg | 亮度传感器 | Release 2021.10 | Binary Sensor, Sensor | 32 | | | sp | 云台相机 | Release 2021.11 | Camera, Siren, Switch, Light, Number, Select, Sensor | 33 | | | sgbj | 声光报警 | Release 2021.11 | Number, Siren, Switch, Select | 34 | | | zd | 震动传感器 | Release 2021.11 | Sensor, Binary Sensor, Number | 35 | | | co2bj | CO2 传感器 | Release 2021.11 | Binary Sensor, Sensor | 36 | | | cobj | CO 传感器 | Release 2021.11 | Binary Sensor, Sensor | 37 | | | jqbj | 甲醛检测仪 | Release 2021.11 | Binary Sensor, Sensor | 38 | | | jwbj | 甲烷检测仪 | Release 2021.11 | Binary Sensor, Sensor | 39 | | | voc | 挥发性有机化合物传感器 | Release 2021.11 | Binary Sensor, Sensor | 40 | | | ylcg | 压力传感器 | Release 2021.11 | Binary Sensor, Sensor | 41 | | 照明 | dj | 灯具 | Release 2021.10 | Light, Switch | 42 | | | dd | 灯带 | Release 2021.10 | Light | 43 | | | fwl | 氛围灯 | Release 2021.10 | Light | 44 | | | dc | 灯串 | Release 2021.10 | Light | 45 | | | xdd | 吸顶灯 | Release 2021.10 | Light, Switch | 46 | | | fsd | 风扇灯 | Release 2021.11 | Light | 47 | | | fwd | 氛围灯 | Release 2021.11 | Light | 48 | | | gyd | 感应灯 | Release 2021.11 | Light | 49 | | | jsq | 加湿器 | Release 2021.10 | Light, humidifier | 50 | | | tgkg | 调光开关 | Release 2021.11 | Light, Number, Select | 51 | | | tgq | 调光器 | Release 2021.11 | Light, Number, Select | 52 | | | tyndj | 太阳能灯 | Release 2021.11 | Light, Sensor, Switch | 53 | | | ykq | 遥控器 | Release 2021.11 | Light | 54 | | 厨房电器 | bh | 智能电茶壶 | Release 2021.10 | Switch, Number, Sensor | 55 | | | kfj | 咖啡机 | Release 2021.10 | Number, Select | 56 | --------------------------------------------------------------------------------