1.1.2 • Published 10 months ago
@iampravikant/tuya-cloud-sdk-nodejs v1.1.2
Tuya Cloud SDK - NodeJS
Access Tuya supported devices via this SDK
Installation
npm i @iampravikant/tuya-cloud-sdk-nodejs
Prerequisite
- Login into your Tuya account (If you don't have an account yet, Sign up)
- Goto Cloud and create a new project. Make sure your select the correct region and make a note of it (You will need while initialising the SDK).
- Once created, open it and go to Overview tab.
- Make a note of Access ID and Access Secret (You will need while initialising the SDK).
- Open Devices tab and link your app account. Click on "Link your app account" and once the QR code opens, scan it from your app (example: SmartLife). (In SmartLife app, there is a button on top right to scan QR code.)
- Now you should see your app account added. Make a node of the UID. This is be your User ID (You will need while initialising the SDK).
Usage
Initial configuration
import { TuyaConfig, TuyaRegion, TuyaClient } from '@iampravikant/tuya-cloud-sdk-nodejs';
TuyaConfig.init('YOUR_ACCESS_ID_FROM_TUYA', 'YOUR_ACCESS_SECRET_FROM_TUYA', 'YOUR_REGION_FROM_TUYA', 'YOUR_USER_ID_FROM_TUYA');
Example:
TuyaConfig.init('...', '...', TuyaRegion.EU, 'eu...');
Home
Get homes
TuyaClient.Home.getHomes();
Get home
TuyaClient.Home.getHome(homeId);
Delete home
TuyaClient.Home.deleteHome(homeId);
Room
Get rooms in a home
TuyaClient.Room.getRooms(homeId);
Create a room in a home
TuyaClient.Room.createRoom(homeId, roomnName);
Delete rooms in a home
TuyaClient.Room.deleteRoom(homeId, roomId);
Device
Get devices in a home
TuyaClient.Device.getDevices(homeId);
Control device
Get the switch status of a device
TuyaClient.Device.getDeviceSwitch(deviceId);
Set the switch status of a device
TuyaClient.Device.setDeviceSwitch(deviceId, on);
Finally
- Feel free to open an issue.
- Star the repo if you found it useful 😀
1.1.2
10 months ago
1.1.1
10 months ago
1.1.0
10 months ago
1.0.14
10 months ago
1.0.13
10 months ago
1.0.12
10 months ago
1.0.11
10 months ago
1.0.10
10 months ago
1.0.9
10 months ago
1.0.8
10 months ago
1.0.7
10 months ago
1.0.6
10 months ago
1.0.5
10 months ago
1.0.4
10 months ago
1.0.3
10 months ago
1.0.2
10 months ago
1.0.1
10 months ago
1.0.0
10 months ago