tuya / tuya-connector-nodejs Goto Github PK
View Code? Open in Web Editor NEWnodejs sdk
nodejs sdk
At the moment the project seems to not be published on NPM, moreover it's a Typescript project, and needs to be built (in ./lib
as I read the config file) to be consumed
How can we help?
Hi,
According to this doc : https://developer.tuya.com/en/docs/cloud/f76865b055?id=Kag2ycn1lvwpt
The endpoint GET: /v1.0/iot-03/devices/{device_id}/status
returns an array.
However, it seems that the TuyaContext.deviceStatus.status(...)
method returns a single item.
I have a nuxt app which throws an error when trying to make requests through the TuyaContext.
Access to XMLHttpRequest at 'https://openapi.tuyaeu.com/v1.0/token?grant_type=1' from origin 'http://localhost:3000' has been blocked by CORS policy: Response to preflight request doesn't pass access control check: The 'Access-Control-Allow-Origin' header has a value 'https://iot.tuya.com' that is not equal to the supplied origin.
I tried to send a api call witht his sdk, i provide correcte secret and access key. but it always return an sign invalid error. Here the example of the code
const result = await client.request({
method: 'post',
path: `/v1.0/iot-03/devices/${deviceID}/commands`,
body: {
device_id: deviceID,
commands: [{
code: 'switch_led',
value: value,
}]
}
});
I followed the README file, to create a small tuya.device.detail request for one of my devices. While the call is without any problems working when using the Tuya IoT Platform (https://iot.tuya.com/) I just get the error message No permissions. This API is not subscribed.
when using this module. I verified access key and secret multiple times.
Hi,
The other official Tuya SDK projects have licenses associated with them - either Apache 2.0 or MIT from what I've seen. Is there a chance one of these could be applied to this NodeJS code? It's unclear how 'safe' it is to use within projects without this!
Thanks!
This code says Invalid token:
let deviceIdArray = ["someid","someOtherId"]
let deviceList = deviceIdArray.join()
let statusResponse= await tuya.request({
path: `/v1.0/iot-03/devices/status`,
method: 'GET',
query:{
device_ids: deviceList
});
And this one works:
let deviceIdArray = ["someid","someOtherId"]
let deviceList = deviceIdArray.join()
let statusResponse= await tuya.request({
path: `/v1.0/iot-03/devices/status?device_ids=${deviceList}`,
method: 'GET',
});`
Ideally, both imply same things, but looks like the query formation has some issue, using v2.0.2
I saw the .deviceFunction.command() function but get every time an error with 'uri path invalid'.
After looking in the functions.ts file of this repo, I saw that I was right. There is an param to add commands (line 55).
But I think the Request Function is messed up because it is missing the command param and set to GET instead of POST (line 94).
Am I right in my suspicion?
Hi,
I think there is a bug. I cannot login from central europe. using this url:
return __generator(this, function (_a) { switch (_a.label) { case 0: return [4 /*yield*/, this.client.request({ path: "/v1.0/iot-03/categories/" + param.category + "/functions", method: 'GET', })]; case 1: res = _a.sent(); return [2 /*return*/, res.data]; } });
But removing the /iot-03/ works....
When I try to connect to the Central Europe server to get the device as per the "getting started" code I get a 1106 permission deny
error. The gateway device that I am trying to connect to has "Read, write, and Manage" permissions.
import { TuyaContext } from '@tuya/tuya-connector-nodejs';
const tuya = new TuyaContext({
baseUrl: 'https://openapi.tuyaeu.com',
accessKey: process.env['ACCESSID'],
secretKey: process.env['ACCESSSECRET'],
});
export const getDevice = async () => {
const device = await tuya.device.detail({
device_id: process.env['DEVICEID']
});
}
TypeError: crypto.createHash is not a function
crypto will run only on nodejs, can you use some other api library so that it will work in the browser also.
Please check http://www.w3.org/TR/WebCryptoAPI/
Here is my code snippet to get all list of devices:
var device = await tuya.request({
method: 'GET',
path: '/v1.0/devices',
body: {
page_size:10,
page_no:1
}
})
But its giving the following response:
{ code: 1100, msg: 'param is empty', success: false, t: 1629498362573 }
I have also tried this api explorer at https://iot.tuya.com/ but getting the same response. Please let me know what other parameter need to be passed in this api for getting the correct response.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.