Код:
from tuya_iot import TuyaOpenAPI
# Cloud project authorization info
ACCESS_ID = 'g83k8g5q3y39rg3m47sp'
ACCESS_KEY = '********************************'
# Select an endpoint base on your project availability zone
# For more info, refer to: https://developer.tuya.com/en/docs/iot/api-request?id=Ka4a8uuo1j4t4
ENDPOINT = "https://openapi.tuyaeu.com"
# Project configuration
USERNAME = 'gg-116407294134666146856'
PASSWORD = '*****'
DEVICE_ID = 'vdevo171821589556861'
# Initialization of tuya openapi
openapi = TuyaOpenAPI(ENDPOINT, ACCESS_ID, ACCESS_KEY)
openapi.connect(USERNAME, PASSWORD)
commands = {'commands': [{'code':'switch_1','value': True}]}
request = openapi.post(f'/v1.0/iot-03/devices/{DEVICE_ID}/commands', commands)
print(request)
Получаю результат:
{'code': 1010, 'msg': 'token invalid', 'success': False, 't': 1718218573822, 'tid': '70e5303828ed11ef939256f60e0857fb'}
На странице api написано:
Authorization Key
Access ID/Client ID: g83k8g5q3y39rg3m47sp
Access Secret/Client Secret: ********************************
Project Code: p1718213881740yhx743