From 34066280402b0816b204cb867c44d1f4e7b3b603 Mon Sep 17 00:00:00 2001 From: Max Isom Date: Fri, 12 Jan 2018 12:36:07 -0600 Subject: [PATCH] Update usage example, fix style error --- README.md | 2 ++ index.js | 6 +++--- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index f0f5d99..c15569a 100644 --- a/README.md +++ b/README.md @@ -15,6 +15,7 @@ Currently only supports smart plugs, but it should be fairly trivial to add othe id: 'xxxxxxxxxxxxxxxxxxxx', key: 'xxxxxxxxxxxxxxxx'}); + tuya.resolveIds().then(() => { tuya.get().then(status => { console.log('Status: ' + status); @@ -27,6 +28,7 @@ Currently only supports smart plugs, but it should be fairly trivial to add othe }); }); }); + }); This should report the current status, set the device to the opposite of what it currently is, then report the changed status. diff --git a/index.js b/index.js index f68bb94..6aa02a7 100644 --- a/index.js +++ b/index.js @@ -164,8 +164,8 @@ TuyaDevice.prototype.get = function (options) { } else { resolve(data.dps['1']); } - }).catch(error => { - reject(error); + }).catch(err => { + reject(err); }); }); }; @@ -271,7 +271,7 @@ TuyaDevice.prototype._send = function (ip, buffer) { resolve(data); }); client.on('error', error => { - error.message = "Error communicating with device. Make sure nothing else is trying to control it or connected to it." + error.message = 'Error communicating with device. Make sure nothing else is trying to control it or connected to it.'; reject(error); }); });