Getting deviceId and localKey directly with API calls #435
Replies: 59 comments 4 replies
-
I tried this. I am getting: There was an error in evaluating the Pre-request Script: TypeError: Cannot read property 'sigBytes' of undefined. when trying to make the get request. I also can't tell what I am suppose to use as schema value when making the request. |
Beta Was this translation helpful? Give feedback.
-
This could be really useful @SleepWalker, thank you for researching it.
I'll take a look at some point this weekend. |
Beta Was this translation helpful? Give feedback.
-
Hello. i would try your method, but im noob . It's ok for my virtual id, i have found. But can you tell me how i have to find local key. I don't know how i can use tuya openapi. Can you tell me step by step what i have to write to found please. thank you |
Beta Was this translation helpful? Give feedback.
-
@etttoutoi This quick start guide from tuya has all the info you need for using postman to get the local key. Basically:
|
Beta Was this translation helpful? Give feedback.
-
Here is a gist, that demonstrates how to get https://gist.github.com/SleepWalker/18f19679adbfacee6c415d4f6dc218bb#file-readme-md I've successfully turned on/off my socket using |
Beta Was this translation helpful? Give feedback.
-
@SleepWalker so after looking at this a bit, it seems that while linking your TuyaSmart account to your SaaS instance works fine, there's not a programmatic way to get all device IDs. Ideally, the user would be able to link their account through the web interface and then run one |
Beta Was this translation helpful? Give feedback.
-
@codetheweb you can use So the user should copy I've added demo script in gist, that lists all the available devices: https://gist.github.com/SleepWalker/18f19679adbfacee6c415d4f6dc218bb#file-listdevices-js |
Beta Was this translation helpful? Give feedback.
-
deviceId can be obtained programmatically using the cloudtuya library, by providing it with your account login details (smart_life, tuya smart app) it will list the device ids for all connected devices, which can then be used here. |
Beta Was this translation helpful? Give feedback.
-
Beta Was this translation helpful? Give feedback.
-
@tim-jc looks like you've forgot to link your smart life account to your tuya dev account (https://auth.tuya.com/). See the issue description for the screenshots. |
Beta Was this translation helpful? Give feedback.
-
What do i put for the schema. |
Beta Was this translation helpful? Give feedback.
-
@SleepWalker - thank you. I had linked, but when I went back in to my Tuya account I saw my device count was now 0. I think I'd inadvertently run the |
Beta Was this translation helpful? Give feedback.
-
what did u add for the schema to get auth token? |
Beta Was this translation helpful? Give feedback.
-
@aidbish - follow the instructions here. The Channel ID (step 3) is the value to use as the schema. |
Beta Was this translation helpful? Give feedback.
-
hmm, tried that, still getting same error 100 i wonder if there is a delay before device being available, although it says 1 device |
Beta Was this translation helpful? Give feedback.
-
Please just use the trial! You only need it for getting the local key. |
Beta Was this translation helpful? Give feedback.
-
Could someone please assist. I run the access_token - all works great - success = true I then paste {{url}}/v1.0/devices/{{device_id}} into the GET box... run it What am I doing wrong? Edit: nevermind. Seems there is a pre-set GET that has that in although i missed it due to all the chinese writing!! |
Beta Was this translation helpful? Give feedback.
-
please read devaxtator post
…On Tue, Mar 2, 2021 at 4:03 PM vaderag ***@***.***> wrote:
Could someone please assist.
I run the access_token - all works great - success = true
I then paste {{url}}/v1.0/devices/{{device_id}} into the GET box... run it
{ "code": 1010, "msg": "token invalid", "success": false, "t":
1614xxxxxxxxx }
What am I doing wrong?
—
You are receiving this because you commented.
Reply to this email directly, view it on GitHub
<#323 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AOI7KSSREMJMKOPDCGCCFU3TBUD6PANCNFSM4NFCOYFQ>
.
|
Beta Was this translation helpful? Give feedback.
-
Beta Was this translation helpful? Give feedback.
-
Beta Was this translation helpful? Give feedback.
-
Clearly from my screenshot, device management is enabled and open under the API Groups. |
Beta Was this translation helpful? Give feedback.
-
confirmed the response is response{}
something is wrong
…On Thu, Mar 4, 2021 at 1:05 PM matyman1122 ***@***.***> wrote:
Clearly from my screenshot, device management is enabled and open under
the API Groups.
I think it is strange I am getting blank response from Europe region api?
Do you get blank response from any region?
—
You are receiving this because you commented.
Reply to this email directly, view it on GitHub
<#323 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AOI7KSVYCAF2VVNTQXB3MXDTB6ATNANCNFSM4NFCOYFQ>
.
|
Beta Was this translation helpful? Give feedback.
-
thanks for the confirmation, I will try again tomorrow |
Beta Was this translation helpful? Give feedback.
-
If you are getting 'Permission Deny' read my post from the 5th Jan 2021... |
Beta Was this translation helpful? Give feedback.
-
Thanks for the reply, this step is already completed as per my last message. You can see in my screenshot all the API groups are available for selection. I suspect I get the deny message because that deviceID is not available on the China API as my devices are under the Europe location. But when I use the Europe one I get {} response. I might need to raise a ticket to them to enquire the status of the API. I was not able to find a status page anywhere. |
Beta Was this translation helpful? Give feedback.
-
Just to let everyone know I decided to try and use postman to call the Europe API instead and this is working. |
Beta Was this translation helpful? Give feedback.
-
For anyone that is trying to use the API Explorer through Tuya IOT Platform and getting the response {} I have found the issue. I was able to get the API working again using this extension for Chrome: |
Beta Was this translation helpful? Give feedback.
-
Here is a simple lib to connect to the api and retrieve local keys of devices: |
Beta Was this translation helpful? Give feedback.
-
Beta Was this translation helpful? Give feedback.
-
Do i need to pay to retrieve the API key? or am i just dumb : (( |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Hello, I've found out, that an official Smart Life app shows you
deviceId
. I've tested thatdeviceId
with tuya OpenAPI and it works (at least for my smart sockets). This means, that you can getlocalKey
from an OpenAPI/v1.0/devices/{{device_id}}
.I think, that this may be useful to simplify
tuyapi
setup workflow.The new setup will consist of three steps:
@tuyapi/cli
, you should "Link device by Tuya Smart App Account":deviceId
:localKey
value:Beta Was this translation helpful? Give feedback.
All reactions