Extends the TUYAPI/openapi to include controls for air cons
npm install @redgrid/tuya-ac-apiAn extension to @tuyapi/openapi that adds support for calling functins to control airconditioners via IR
``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('
const remote_indices = await api.getSupportedRemotes('
// need to add a remote to an IR device before it is possible to send keys
await api.addRemote('
const status = await api.status('
console.log(status)
const result = await api.sendKeys(' const updatedStatus = await api.status(' main() ```
console.log(updatedStatus)
}
.catch(err => {
console.error(err)
})