Skip to content

Commit

Permalink
fix display name issues of outlet and switch
Browse files Browse the repository at this point in the history
fix status issues of curtain
fix plugin login security issue
  • Loading branch information
Hanh94 committed Sep 23, 2021
1 parent 68684e3 commit dcb00df
Show file tree
Hide file tree
Showing 6 changed files with 20 additions and 10 deletions.
2 changes: 1 addition & 1 deletion lib/base_accessory.js
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ class BaseAccessory {
}

// Service
if (this.subServices.length == 0) {
if (this.subServices.length == 0 || this.subServices.length == 1) {
// Service
this.service = this.homebridgeAccessory.getService(this.serviceType);
if (this.service) {
Expand Down
7 changes: 6 additions & 1 deletion lib/outlet_accessory.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,12 @@ class OutletAccessory extends BaseAccessory {
continue;
}
var value = status.value
const service = this.homebridgeAccessory.getService(subType);
let service
if (this.subTypeArr.length == 1) {
service = this.service;
}else{
service = this.homebridgeAccessory.getService(subType);
}
this.setCachedState(service.displayName, value);
if (this.isRefresh) {
service
Expand Down
7 changes: 6 additions & 1 deletion lib/switch_accessory.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,12 @@ class SwitchAccessory extends BaseAccessory {
continue;
}
var value = status.value
const service = this.homebridgeAccessory.getService(subType);
let service
if (this.subTypeArr.length == 1) {
service = this.service;
}else{
service = this.homebridgeAccessory.getService(subType);
}
this.setCachedState(service.displayName, value);
if (this.isRefresh) {
service
Expand Down
2 changes: 1 addition & 1 deletion lib/tuyaopenapi.js
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,7 @@ class TuyaOpenAPI {
'lang': this.lang,
'dev_lang': 'javascript',
'dev_channel': 'homebridge',
'devVersion': '1.4.0',
'devVersion': '1.4.1',

};
this.log.log(`TuyaOpenAPI request: method = ${method}, endpoint = ${this.endpoint}, path = ${path}, params = ${JSON.stringify(params)}, body = ${JSON.stringify(body)}, headers = ${JSON.stringify(headers)}`);
Expand Down
10 changes: 5 additions & 5 deletions lib/tuyashopenapi.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,17 @@ const axios = require('axios').default;
const Crypto = require('crypto-js');
const uuid = require('uuid');
const nonce = uuid.v1();
const DEFAULT_ENDPOINT = 'https://openapi.tuyacn.com';
class TuyaSHOpenAPI {

constructor(accessId, accessKey, username, password, countryCode, appSchema, log, lang = 'en') {
this.endpoint = DEFAULT_ENDPOINT;
this.countryCode = countryCode;
this.endpoint = (this.countryCode && this.countryCode == 86)? 'https://openapi.tuyacn.com' : 'https://openapi.tuyaus.com'
this.access_id = accessId;
this.access_key = accessKey;
this.lang = lang;
this.username = username;
this.password = password;
this.countryCode = countryCode;

this.appSchema = appSchema;
this.log = log;

Expand Down Expand Up @@ -46,7 +46,7 @@ class TuyaSHOpenAPI {
'schema': this.appSchema
});
let { access_token, refresh_token, uid, expire_time , platform_url} = res.result;
this.endpoint = platform_url ? platform_url : DEFAULT_ENDPOINT;
this.endpoint = platform_url ? platform_url : this.endpoint;
this.tokenInfo = {
access_token: access_token,
refresh_token: refresh_token,
Expand Down Expand Up @@ -164,7 +164,7 @@ class TuyaSHOpenAPI {
'lang': this.lang,
'dev_lang': 'javascript',
'dev_channel': 'homebridge',
'devVersion': '1.4.0',
'devVersion': '1.4.1',

};
this.log.log(`TuyaOpenAPI request: method = ${method}, endpoint = ${this.endpoint}, path = ${path}, params = ${JSON.stringify(params)}, body = ${JSON.stringify(body)}, headers = ${JSON.stringify(headers)}`);
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "homebridge-tuya-platform",
"version": "1.4.0",
"version": "1.4.1",
"description": "Official Homebridge plugin for Tuya Open API, maintained by the Tuya Developer Team.",
"main": "index.js",
"scripts": {
Expand Down

0 comments on commit dcb00df

Please sign in to comment.