From e00de4137158ef04c738184e26acbc8de1a2c6d5 Mon Sep 17 00:00:00 2001 From: "huan.hu@tuya.com" Date: Wed, 29 Sep 2021 16:00:30 +0800 Subject: [PATCH] Fixed single control switch and outlet control issues --- lib/outlet_accessory.js | 7 ++++++- lib/switch_accessory.js | 7 ++++++- lib/tuyaopenapi.js | 2 +- lib/tuyashopenapi.js | 2 +- package.json | 2 +- 5 files changed, 15 insertions(+), 5 deletions(-) diff --git a/lib/outlet_accessory.js b/lib/outlet_accessory.js index 2db81f14..6acdb3f6 100644 --- a/lib/outlet_accessory.js +++ b/lib/outlet_accessory.js @@ -41,6 +41,7 @@ class OutletAccessory extends BaseAccessory { let service if (this.subTypeArr.length == 1) { service = this.service; + this.switchValue = status; }else{ service = this.homebridgeAccessory.getService(subType); } @@ -83,7 +84,11 @@ class OutletAccessory extends BaseAccessory { var code; var value; const isOn = value ? true : false; - code = name; + if (this.subTypeArr.length == 1) { + code = this.switchValue.code; + }else{ + code = name; + } value = isOn; return { "commands": [ diff --git a/lib/switch_accessory.js b/lib/switch_accessory.js index d4a12221..c504cc1c 100644 --- a/lib/switch_accessory.js +++ b/lib/switch_accessory.js @@ -38,6 +38,7 @@ class SwitchAccessory extends BaseAccessory { let service if (this.subTypeArr.length == 1) { service = this.service; + this.switchValue = status; }else{ service = this.homebridgeAccessory.getService(subType); } @@ -78,7 +79,11 @@ class SwitchAccessory extends BaseAccessory { var code; var value; const isOn = value ? true : false; - code = name; + if (this.subTypeArr.length == 1) { + code = this.switchValue.code; + }else{ + code = name; + } value = isOn; return { "commands": [ diff --git a/lib/tuyaopenapi.js b/lib/tuyaopenapi.js index 3bb7765e..87c65aa1 100644 --- a/lib/tuyaopenapi.js +++ b/lib/tuyaopenapi.js @@ -170,7 +170,7 @@ class TuyaOpenAPI { 'lang': this.lang, 'dev_lang': 'javascript', 'dev_channel': 'homebridge', - 'devVersion': '1.4.1', + 'devVersion': '1.4.2', }; this.log.log(`TuyaOpenAPI request: method = ${method}, endpoint = ${this.endpoint}, path = ${path}, params = ${JSON.stringify(params)}, body = ${JSON.stringify(body)}, headers = ${JSON.stringify(headers)}`); diff --git a/lib/tuyashopenapi.js b/lib/tuyashopenapi.js index 6af519a0..b703f78e 100644 --- a/lib/tuyashopenapi.js +++ b/lib/tuyashopenapi.js @@ -164,7 +164,7 @@ class TuyaSHOpenAPI { 'lang': this.lang, 'dev_lang': 'javascript', 'dev_channel': 'homebridge', - 'devVersion': '1.4.1', + 'devVersion': '1.4.2', }; this.log.log(`TuyaOpenAPI request: method = ${method}, endpoint = ${this.endpoint}, path = ${path}, params = ${JSON.stringify(params)}, body = ${JSON.stringify(body)}, headers = ${JSON.stringify(headers)}`); diff --git a/package.json b/package.json index 057f1894..f66acaef 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "homebridge-tuya-platform", - "version": "1.4.1", + "version": "1.4.2", "description": "Official Homebridge plugin for Tuya Open API, maintained by the Tuya Developer Team.", "main": "index.js", "scripts": {