Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Code 1010 #12

Closed
haukee opened this issue May 27, 2021 · 4 comments
Closed

Code 1010 #12

haukee opened this issue May 27, 2021 · 4 comments

Comments

@haukee
Copy link

haukee commented May 27, 2021

I get a Code 1010 if I try to use the Plugin.

My configuration:

"platform": "TuyaPlatform",
            "name": "TuyaPlatform",
            "options": {
                "username": "<my smart life email-adress>",
                "password": "<my smart life password>",
                "accessId": "<the accessId from project overview>",
                "accessKey": "<the accessKey from project overview>",
                "lang": "en",
                "endPoint": "https://openapi.tuyaeu.com",
                "projectType": "2",
                "appSchema": "smartlife",
                "countryCode": 49
            }

The Log regarding login:

TuyaOpenAPI request: method = post, endpoint = https://openapi.tuyaeu.com, path = /v1.0/iot-01/associated-users/actions/authorized-login, params = null, body = {"country_code":49,"username":"<the email I use for smart life>","password":"<redacted>","schema":"smartlife"}, headers = {"t":"1622144608219","client_id":"hmqkvnj7amd9oue5s40x","sign":"BD61F9FFAA08F7A7A9F99A32A607DB7710E258B292AAD9D97921C6D8957295B3","sign_method":"HMAC-SHA256","access_token":"","lang":"en","dev_lang":"javascript","dev_channel":"homebridge","devVersion":"1.0.6"}

....

TuyaOpenAPI response: {"code":1010,"msg":"令牌過期","success":false,"t":1622144608498} path = /v1.0/iot-01/associated-users/actions/authorized-login
(node:13746) UnhandledPromiseRejectionWarning: TypeError: Cannot destructure property 'access_token' of 'res.result' as it is undefined.
    at TuyaSHOpenAPI._refreshAccessTokenIfNeed (/usr/lib/node_modules/homebridge-tuya-platform/lib/tuyashopenapi.js:45:10)
    at processTicksAndRejections (internal/process/task_queues.js:97:5)
    at TuyaSHOpenAPI.request (/usr/lib/node_modules/homebridge-tuya-platform/lib/tuyashopenapi.js:128:5)
    at TuyaSHOpenAPI.getDevices (/usr/lib/node_modules/homebridge-tuya-platform/lib/tuyashopenapi.js:58:15)
    at TuyaPlatform.initTuyaSDK (/usr/lib/node_modules/homebridge-tuya-platform/index.js:76:17)
(node:13746) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). To terminate the node process on unhandled promise rejection, use the CLI flag `--unhandled-rejections=strict` (see https://nodejs.org/api/cli.html#cli_unhandled_rejections_mode). (rejection id: 1)
(node:13746) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.
@lodev09
Copy link

lodev09 commented May 27, 2021

I was able to fix this by modifying the tuyashopenapi.js file like so:

this.tokenInfo = {
  access_token: '<get the token from the tuya iot API explorer>',
  refresh_token: '', // can be empty
  uid: '<get the uid from your linked devices by app account>',
  expire: 1653686505, // in seconds (+1 year)
}

Until they officially fix this issue, this will do for now lol.. Also, modify this block on comparing the expiry (it looks like a bug)

async _refreshAccessTokenIfNeed(path) {
  // ...
  if ((this.tokenInfo.expire - 60) * 1000 > new Date().getTime()) {
    return;
  }
  // ...
}

@Hanh94
Copy link
Contributor

Hanh94 commented May 29, 2021

@haukee Sorry for the bad experience, the server problem has been fixed, please try again

@Hanh94
Copy link
Contributor

Hanh94 commented May 29, 2021

@lodev09
Thank you for your feedback

The plugin currently supports one standard instruction in one Tuya category, such as Lightbulb, brightness support 'bright_value', and temperature support 'temp_value'.

As for your expectations Support for Light accessory _v2 `#13, we would like developers to participate in the development of our plugin. You can according to Standard Status Set to try to modify the plugin has meet your requirements.

@haukee
Copy link
Author

haukee commented May 29, 2021

@haukee Sorry for the bad experience, the server problem has been fixed, please try again

thank you. Its working now.

@haukee haukee closed this as completed May 29, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants