🌧 An easy-to-use API for devices that use Tuya's cloud services. Documentation: https://codetheweb.github.io/tuyapi.
Clone or download
renovate[bot] and codetheweb Update dependency ava to v1.1.0 (#129)
This PR contains the following updates:

| Package | Type | Update | Change | References |
|---|---|---|---|---|
| ava | devDependencies | minor | `1.0.1` -> `1.1.0` | [homepage](https://ava.li), [source](https://togithub.com/avajs/ava) |

---

### Release Notes

<details>
<summary>avajs/ava</summary>

### [`v1.1.0`](https://togithub.com/avajs/ava/releases/v1.1.0)

[Compare Source](https://togithub.com/avajs/ava/compare/v1.0.1...v1.1.0)

### 1.1.0

#### New features

AVA now exports a `meta` object. Currently, you can retrieve the path of the test file being run:

```js
import test from 'ava';

console.log('Test currently being run: ', test.meta.file);
```

```js
import {meta} from 'ava';

console.log('Test currently being run: ', meta.file);
```

This is useful in helpers that need to know the test file. [`bccd297`](https://togithub.com/avajs/ava/commit/bccd297f38c9f4cf6dbb16dffa7ee8753dbbd12f)

#### Bug fixes and other improvements

-   `t.log()` now works in hooks [`d187712`](https://togithub.com/avajs/ava/commit/d1877122cea7ce54455d9dcc2bca046612dbd628)
-   Error output for improper usage of `t.throws()` once again links to the correct documentation [`dc552bc`](https://togithub.com/avajs/ava/commit/dc552bcb57181d9b6d9c39711013f9813ddc2c51)
-   We've added a section on webpack aliases to the [Babel recipe](https://togithub.com/avajs/ava/blob/master/docs/recipes/babel.md) [`c3bcbf2`](https://togithub.com/avajs/ava/commit/c3bcbf2a568c12017fe0da041dc247a226019001)

-   We've updated the [Vue recipe](https://togithub.com/avajs/ava/blob/master/docs/recipes/vue.md) for Babel 7, and added a section on webpack aliases [`c3bcbf2`](https://togithub.com/avajs/ava/commit/c3bcbf2a568c12017fe0da041dc247a226019001)

#### All changes πŸ“š

[`v1.0.1...v1.1.0`](https://togithub.com/avajs/ava/compare/v1.0.1...v1.1.0)

#### Thanks πŸ’Œ

πŸ’– Huge thanks to [@&#8203;fitztrev](https://togithub.com/fitztrev), [@&#8203;forresst](https://togithub.com/forresst), [@&#8203;astrob0t](https://togithub.com/astrob0t), [@&#8203;pearofducks](https://togithub.com/pearofducks), [@&#8203;coreyfarrell](https://togithub.com/coreyfarrell) and [@&#8203;dflupu](https://togithub.com/dflupu) for helping us with this release. We couldn’t have done it without you!

#### Get involved ✌️

We welcome new contributors. AVA is a friendly place to get started in open source. We have a [great article](https://medium.com/@&#8203;vadimdemedes/making-your-first-contribution-de6576ddb190#.umxr7id07) on getting started contributing and a comprehensive [contributing guide](https://togithub.com/avajs/ava/blob/master/contributing.md).

</details>

---

### Renovate configuration

πŸ“… **Schedule**: At any time (no schedule defined).

🚦 **Automerge**: Disabled by config. Please merge this manually once you are satisfied.

♻️ **Rebasing**: Whenever PR becomes conflicted, or if you modify the PR title to begin with "`rebase!`".

πŸ”• **Ignore**: Close this PR and you won't be reminded about this update again.

---

 - [ ] <!-- renovate-rebase -->If you want to rebase/retry this PR, check this box

---

This PR has been generated by [Renovate Bot](https://togithub.com/marketplace/renovate). View repository job log [here](https://renovatebot.com/dashboard#codetheweb/tuyapi).
Latest commit f03feb1 Jan 17, 2019

README.md

TuyAPI 🌧 πŸ”Œ

XO code style Build Status Coverage Status Node Version

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

Installation

npm install codetheweb/tuyapi

Basic Usage

Asynchronous (event based, recommended)

const device = new TuyAPI({
  id: 'xxxxxxxxxxxxxxxxxxxx',
  key: 'xxxxxxxxxxxxxxxx',
  ip: 'xxx.xxx.xxx.xxx',
  persistentConnection: true});

device.on('connected',() => {
  console.log('Connected to device.');
});

device.on('disconnected',() => {
  console.log('Disconnected from device.');
});

device.on('data', data => {
  console.log('Data from device:', data);

  const status = data.dps['1'];

  console.log('Current status:', status);

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

device.on('error',(err) => {
  console.log('Error: ' + err);
});

device.connect();

// Disconnect after 10 seconds
setTimeout(() => { device.disconnect(); }, 10000);

Synchronous

const TuyAPI = require('tuyapi');

const device = new TuyAPI({
  id: 'xxxxxxxxxxxxxxxxxxxx',
  key: 'xxxxxxxxxxxxxxxx',
  ip: 'xxx.xxx.xxx.xxx'});

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

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

    device.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. The above examples will work with smart plugs; they may need some tweaking for other types of devices.

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

πŸ“ Notes

  • Only one TCP connection can be in use with a device at once. If using this, do not have the app on your phone open.
  • Some devices ship with older firmware that may not work with tuyapi. If you're experiencing issues, please try updating the device's firmware in the official app.

πŸ““ Docs

See the docs.

TODO

  1. Document details of protocol
  2. Figure out correct CRC algorithm

Contributors

Related

Ports

Projects built with TuyAPI

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

forthebadge forthebadge