ADD: support to toggle device state

This commit is contained in:
KarstenSiedentopp
2019-04-09 19:23:15 +02:00
parent 59acf6d2a4
commit cfefbabe90
2 changed files with 24 additions and 10 deletions

View File

@@ -255,9 +255,13 @@ var TuyaDevice = (function () {
TuyaDevice.prototype.toggle = function () {
if (!this.connected) return;
debug("toogle state");
return this.set({
set: !status
return new Promise((resolve, reject) => {
this.get().then((status) => {
debug("toogle state", status);
this.set({
set: !status
});
});
});
}