Skip to content

🌧 An easy-to-use API for devices that use Tuya's cloud services. Documentation: https://codetheweb.github.io/tuyapi.

License

Notifications You must be signed in to change notification settings

chadacious/tuyapi

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

TuyAPI 🌧 🔌

XO code style Build Status Coverage Status

A library for communicating with devices that use the Tuya cloud network. These devices are branded under many different names, but if port 6668 is open on your device chances are this library will work with it.

Installation

npm install codetheweb/tuyapi

Basic Usage

const TuyaDevice = require('tuyapi');

let tuya = new TuyaDevice({
  id: 'xxxxxxxxxxxxxxxxxxxx',
  key: 'xxxxxxxxxxxxxxxx',
  ip: 'xxx.xxx.xxx.xxx'});

tuya.get().then(status => {
  console.log('Status:', status);

  tuya.set({set: !status}).then(result => {
    console.log('Result of setting status to ' + !status + ': ' + result);

    tuya.get().then(status => {
      console.log('New status:', status);
      return;
    });
  });
});

This should report the current status, set the device to the opposite of what it currently is, then report the changed status.

See the setup instructions for how to find the needed parameters.

📓 Docs

See the docs.

IMPORTANT: Only one TCP connection can be in use with a device at once. If testing this, do not have the app on your phone open.

TODO

  1. Document details of protocol
  2. Figure out correct CRC algorithm
  3. Keep connection open between requests

Contributors

Related

Ports

Projects built with TuyAPI

To add your projects to either of the above lists, please open a pull request.

forthebadge forthebadge

About

🌧 An easy-to-use API for devices that use Tuya's cloud services. Documentation: https://codetheweb.github.io/tuyapi.

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • JavaScript 100.0%