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. |
|
This could be really useful @SleepWalker, thank you for researching it.
I'll take a look at some point this weekend. |
|
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 |
|
@etttoutoi This quick start guide from tuya has all the info you need for using postman to get the local key. Basically:
|
|
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 |
|
@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 |
|
@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 |
|
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. |
|
@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. |
|
What do i put for the schema. |
|
@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 |
|
what did u add for the schema to get auth token? |
|
hmm, tried that, still getting same error 100 i wonder if there is a delay before device being available, although it says 1 device |
|
Please just use the trial! You only need it for getting the local key. |
|
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!! |
|
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>
.
|
|
Clearly from my screenshot, device management is enabled and open under the API Groups. |
|
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>
.
|
|
thanks for the confirmation, I will try again tomorrow |
|
If you are getting 'Permission Deny' read my post from the 5th Jan 2021... |
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. |
|
Just to let everyone know I decided to try and use postman to call the Europe API instead and this is working. |
|
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: |
|
Here is a simple lib to connect to the api and retrieve local keys of devices: |













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 thatdeviceIdwith tuya OpenAPI and it works (at least for my smart sockets). This means, that you can getlocalKeyfrom an OpenAPI/v1.0/devices/{{device_id}}.I think, that this may be useful to simplify
tuyapisetup workflow.The new setup will consist of three steps:
@tuyapi/cli, you should "Link device by Tuya Smart App Account":deviceId:localKeyvalue:All reactions