# @redgrid/tuya-ac-api

> Extends the TUYAPI/openapi to include controls for air cons

Latest version **0.2.0** (published 2020-06-05) · MIT license · 0 weekly downloads

## Install

```sh
npm install @redgrid/tuya-ac-api
pnpm add @redgrid/tuya-ac-api
yarn add @redgrid/tuya-ac-api
bun add @redgrid/tuya-ac-api
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support; pre 1.0.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.2.0 |
| Published | 2020-06-05 |
| First published | 2020-04-20 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 1 |
| Unpacked size | 6.3 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Author | Willem Olding |
| Maintainers | willemolding |

## Links

- npm: https://www.npmjs.com/package/@redgrid/tuya-ac-api
- npm.io page: https://npm.io/package/@redgrid/tuya-ac-api

## Dependencies (1)

- [@tuyapi/openapi](https://npm.io/package/@tuyapi/openapi.md) ^1.0.0

## Recent versions

- 0.2.0 (latest) — 2020-06-05
- 0.1.0 — 2020-05-20
- 0.0.1 — 2020-04-20

## README

# TUYA-AC-API

An extension to [@tuyapi/openapi](https://github.com/TuyaAPI/openapi) that adds support for calling functins to control airconditioners via IR

## Usage

```javascript
const TuyaAcApi = require('./lib')

const apiConfig = {
  key: 'xxx',
  secret: 'xxx',
  schema: 'xxx'
}

async function main () {
  const api = new TuyaAcApi(apiConfig)
  await api.getToken() // must call this first

  // control a non-IR device (e.g. a smart plug)
  const deviceId = '55780007bcddc2af5cd6'
  // get its functions
  const functions = await api.functions(deviceId)
  console.log(functions)
  // call one to switch it on
  const response = await api.sendCommands(deviceId, [
    {
      code: 'switch',
      value: true
    }
  ])

  // control and IR device
  const brands = await api.getSupportedBrands('<device-id>')
  const remote_indices = await api.getSupportedRemotes('<device-id>', '<brand-id>')

  // need to add a remote to an IR device before it is possible to send keys
  await api.addRemote('<device-id>', '<remote-index>')

  const status = await api.status('<device-id>', '<remote-id>')
  console.log(status)

  const result = await api.sendKeys('<device-id>', '<remote-id>', '<remote-index', { power: 1, temp: 20 })

  const updatedStatus = await api.status('<device-id>', '<remote-id>')
  console.log(updatedStatus)
}

main()
  .catch(err => {
    console.error(err)
  })

````

---
_Source: https://npm.io/package/@redgrid/tuya-ac-api · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
