главная страница
умный дом
  iRobot
  zigbee vs wi-fi
  лампа Сбер
  обогреватель
  tuya api

Настройка API устройств Tuya (Smart Life)

https://iot.tuya.com/

Описание настройки в проекте GitHub jasonacox/tinytuya (python)

TUYA ACCOUNT - Set up a Tuya Account (see PDF Instructions)

NOTE: Tuya often changes their portal and services. Please open an issue with screenshots if we need to update these instructions.

  • Create a Tuya Developer account on iot.tuya.com. When it asks for the "Account Type", select "Skip this step..."
  • Click on "Cloud" icon -> "Create Cloud Project"
  • Pick the correct Data Center "Region" for your location.
  • Skip the configuration wizard but remember the Authorization Key: API ID and Secret for below.
  • Click on "Cloud" icon -> Select your project -> Devices -> Link Tuya App Account.
  • Click Add App Account (screenshot) and it will pop-up a "Link Tuya App Account" dialog, chose "Automatic" and "Read Only Status" (it will still alow commands). Click OK and it will display a QR code. Scan the QR code with the Smart Life app on your Phone (see step 1 above) by going to the "Me" tab in the Smart Life app and clicking on the QR code button [..] in the upper right hand corner of the app. When you scan the QR code, it will link all of the devices registered in your Smart Life app into your Tuya IoT project. If the QR code will not scan then make sure to disable any browser theming plug-ins (such as Dark Reader) and try again. NO DEVICES? If no devices show up after scanning the QR code, you will need to select a different data center and edit your project (or create a new one) until you see your paired devices from the Smart Life App show up. (screenshot). The data center may not be the most logical. As an example, some in the UK have reported needing to select "Central Europe" instead of "Western Europe". SERVICE API: Under "Service API" ensure these APIs are listed: IoT Core and Authorization. To be sure, click subscribe again on every service. Very important: disable popup blockers otherwise subscribing won't work without providing any indication of a failure. Make sure you authorize your Project to use those APIs: Click "Service API" tab Click "Go to Authorize" button Select the API Groups from the dropdown and click Subscribe (screenshot) WIZARD - Run Setup Wizard: From your Linux/Mac/Win PC run the TinyTuya Setup Wizard to fetch the Local_Keys for all of your registered devices: python -m tinytuya wizard # use -nocolor for non-ANSI-color terminals The Wizard will prompt you for the API ID key, API Secret, API Region (cn, us, us-e, eu, eu-w, or in) from your Tuya IoT project as set in Step 3 above. To find those again, go to iot.tuya.com, choose your project and click Overview API Key: Access ID/Client ID API Secret: Access Secret/Client Secret It will also ask for a sample Device ID. You can have the wizard scan for one (enter scan), use one from step 2 above or in the Device List on your Tuya IoT project. The Wizard will poll the Tuya IoT Cloud Platform and print a JSON list of all your registered devices with the "name", "id" and "key" of your registered device(s). The "key"s in this list are the Devices' Local_Key you will use to access your device. In addition to displaying the list of devices, Wizard will create a local file devices.json that TinyTuya will use to provide additional details for scan results from tinytuya.deviceScan() or when running python -m tinytuya scan. The wizard also creates a local file tuya-raw.json that contains the entire payload from Tuya Cloud. The Wizard will ask if you want to poll all the devices. If you do, it will display the status of all devices on record and create a snapshot.json file with these results. Make sure your LAN and firewall permit UDP (6666, 6667 and 7000) and TCP (6668) traffic.