mirror of
https://github.com/lehanspb/tuya-mqtt.git
synced 2025-12-24 01:53:00 +00:00
ADD: support to toggle device state
This commit is contained in:
@@ -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
|
||||
});
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user