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.
npm install codetheweb/tuyapi
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.
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.
- Document details of protocol
- Figure out correct CRC algorithm
- Keep connection open between requests
- python-tuya a Python port by clach04
- m4rcus.TuyaCore a .NET port by Marcus-L
- tuya-cli: a CLI interface for Tuya devices
- homebridge-tuya: a Homebridge plugin for Tuya devices
- tuyaweb: a web interface for controlling devices by bmachek
- homebridge-igenix-air-conditioner: a Homebridge plugin for the Igenix IG9901WIFI air conditioner
To add your projects to either of the above lists, please open a pull request.