Skip to content

Mathieu2301/Tuya-Cloud-API

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

8 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Tuya Cloud API

API for Tuya Cloud

No dependencies 💪


Installation

npm i tuya-cloud

Example (test.js)

const tuyaCloud = require('tuya-cloud');

tuyaCloud.connect({
  region: 'eu', // eu (Default) / us / cn / in
  clientID: 'xxxxxxxxxxxxxxxxxxxx',
  secret: 'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx',
}).then(async (tuya) => {
  console.log('Logged !')

  const tempSensor = tuya.device('xxxxxxxxxxxxxxxxxxxxxx');

  setInterval(async () => {
    console.log(await tempSensor.getInfos());
    console.log(await tempSensor.getStatus());
  }, 10000);

  const light = tuya.device('xxxxxxxxxxxxxxxxxxxxxx');

  console.log(await light.getFunctions());
  console.log(await light.getStatus());

  light.sendCommands([
    {
      code: 'colour_data',
      value: {
        h: 120, // Green
        s: 1000,
        v: 1000,
      },
    },
  ]);

}).catch((error) => {
  console.error(error.message);
});

Problems

If you have errors in console or unwanted behavior, just reload the page. If the problem persists, please create an issue here.

About

API For Tuya Cloud

Topics

Resources

Stars

Watchers

Forks

Contributors 2

  •  
  •