Skip to content

Commit

Permalink
chore: release v0.0.9
Browse files Browse the repository at this point in the history
- fix login
  • Loading branch information
TA2k committed Dec 21, 2024
1 parent c378594 commit 6df6980
Show file tree
Hide file tree
Showing 5 changed files with 173 additions and 158 deletions.
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,10 @@ Stop:
<https://forum.iobroker.net/topic/59466/test-adapter-vesync>

## Changelog
### 0.0.9 (2024-12-21)

- fix login

### 0.0.8 (2024-10-26)

- fix login
Expand Down
15 changes: 14 additions & 1 deletion io-package.json
Original file line number Diff line number Diff line change
@@ -1,8 +1,21 @@
{
"common": {
"name": "vesync",
"version": "0.0.8",
"version": "0.0.9",
"news": {
"0.0.9": {
"en": "fix login",
"de": "zurück zur übersicht",
"ru": "исправить логин",
"pt": "corrigir login",
"nl": "fix login",
"fr": "correction de la connexion",
"it": "fix login",
"es": "corrección de inicio",
"pl": "naprawić logowanie",
"uk": "фіксувати логін",
"zh-cn": "固定登录"
},
"0.0.8": {
"en": "fix login",
"de": "zurück zur übersicht",
Expand Down
65 changes: 27 additions & 38 deletions main.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ class Vesync extends utils.Adapter {

this.json2iob = new Json2iob(this);
this.requestClient = axios.create();
this.clientVersion = 'VeSync 5.0.50 build16';
}

/**
Expand All @@ -36,9 +35,9 @@ class Vesync extends utils.Adapter {
async onReady() {
// Reset the connection indicator during startup
this.setState('info.connection', false, true);
if (this.config.interval < 0.1) {
this.log.info('Set interval to minimum 0.1');
this.config.interval = 0.1;
if (this.config.interval < 0.5) {
this.log.info('Set interval to minimum 0.5');
this.config.interval = 0.5;
}
if (!this.config.username || !this.config.password) {
this.log.error('Please set username and password in the instance settings');
Expand Down Expand Up @@ -93,34 +92,25 @@ class Vesync extends utils.Adapter {
async login() {
await this.requestClient({
method: 'post',
url: 'https://smartapi.vesync.com/user/api/accountManage/v3/appLoginV3',
url: 'https://smartapi.vesync.com/cloud/v1/user/login',
headers: {
accept: '*/*',
'content-type': 'application/json',
'user-agent': 'VeSync/5.0.50 (com.etekcity.vesyncPlatform; build:16; iOS 16.7.2) Alamofire/5.2.1',
'accept-language': 'de-DE;q=1.0',
},
data: {
context: {
token: '.',
terminalId: this.terminalId,
osInfo: 'iOS16.7.2',
clientInfo: 'ioBroker',
traceId: '',
accountID: '.',
clientType: 'vesyncApp',
userCountryCode: 'US',
method: 'appLoginV3',
clientVersion: this.clientVersion,
acceptLanguage: 'de',
timeZone: 'Europe/Berlin',
debugMode: false,
},
data: {
userType: 1,
email: this.config.username,
password: crypto.createHash('md5').update(this.config.password).digest('hex'),
},
timeZone: 'Europe/Berlin',
acceptLanguage: 'de',
appVersion: '2.5.1',
phoneBrand: 'SM N9005',
phoneOS: 'Android',
traceId: Date.now().toString(),
devToken: '',
userType: '1',
method: 'login',
email: this.config.username,
password: crypto.createHash('md5').update(this.config.password).digest('hex'),
},
})
.then((res) => {
Expand Down Expand Up @@ -350,7 +340,7 @@ class Vesync extends utils.Adapter {
}

const forceIndex = true;
const preferedArrayName = undefined;
const preferedArrayName = null;

this.json2iob.parse(device.cid + '.' + element.path, data, {
forceIndex: forceIndex,
Expand Down Expand Up @@ -409,7 +399,7 @@ class Vesync extends utils.Adapter {
allData: true,
configModule: this.fetchHealthData,
page: 1,
pageSize: 300,
pageSize: 100,
subUserID: null,
uploadTimestamp: null,
weightUnit: 'kg',
Expand All @@ -435,9 +425,9 @@ class Vesync extends utils.Adapter {
phoneOS: 'iOS16.7.2',
clientInfo: 'iPhone 8 Plus',
clientType: 'vesyncApp',
clientVersion: this.clientVersion,
clientVersion: 'VeSync 5.0.50 build16',
traceId: Date.now().toString(),
appVersion: this.clientVersion,
appVersion: 'VeSync 5.0.50 build16',
token: this.session.token,
terminalId: this.terminalId,
phoneBrand: 'iPhone 8 Plus',
Expand All @@ -456,14 +446,14 @@ class Vesync extends utils.Adapter {
accountID: this.session.accountID,
clientInfo: 'iPhone 8 Plus',
clientType: 'vesyncApp',
clientVersion: this.clientVersion,
clientVersion: 'VeSync 5.0.50 build16',
debugMode: false,
method: 'getWeighingDataV4',
osInfo: 'iOS16.7.2',
terminalId: this.terminalId,
timeZone: 'Europe/Berlin',
token: this.session.token,
traceId: Date.now().toString(),
traceId: '',
userCountryCode: 'DE',
},
data: status.data,
Expand All @@ -489,7 +479,7 @@ class Vesync extends utils.Adapter {
if (res.data.code != 0) {
this.log.error(status.url);
if (res.data.code === -11300030) {
this.log.info('Device ' + status.url + ' is offline');
this.log.info('Device ' + device.cid + ' is offline');

Check failure on line 482 in main.js

View workflow job for this annotation

GitHub Actions / check-and-lint

'device' is not defined

Check failure on line 482 in main.js

View workflow job for this annotation

GitHub Actions / check-and-lint

'device' is not defined
return;
}
this.log.error(JSON.stringify(res.data));
Expand All @@ -509,7 +499,7 @@ class Vesync extends utils.Adapter {
return {
acceptLanguage: 'de',
accountID: this.session.accountID,
appVersion: this.clientVersion,
appVersion: 'VeSync 4.1.52 build4',
cid: device.cid,
configModule: device.configModule,
debugMode: false,
Expand All @@ -532,7 +522,7 @@ class Vesync extends utils.Adapter {
return {
acceptLanguage: 'de',
accountID: this.session.accountID,
appVersion: this.clientVersion,
appVersion: 'VeSync 4.2.20 build12',
cid: device.cid,
configModule: device.configModule,
debugMode: false,
Expand Down Expand Up @@ -600,7 +590,7 @@ class Vesync extends utils.Adapter {
traceId: Date.now(),
phoneBrand: 'iPhone 8 Plus',
acceptLanguage: 'de',
appVersion: this.clientVersion,
appVersion: 'VeSync 4.1.10 build2',
userCountryCode: 'DE',
token: this.session.token,
};
Expand All @@ -625,7 +615,6 @@ class Vesync extends utils.Adapter {
this.refreshTokenInterval && clearInterval(this.refreshTokenInterval);
callback();
} catch (e) {

Check failure on line 617 in main.js

View workflow job for this annotation

GitHub Actions / check-and-lint

'e' is defined but never used

Check failure on line 617 in main.js

View workflow job for this annotation

GitHub Actions / check-and-lint

'e' is defined but never used
this.log.error(e);
callback();
}
}
Expand Down Expand Up @@ -670,7 +659,7 @@ class Vesync extends utils.Adapter {
cookMode: JSON.parse(state.val),
},
method: 'bypass',
appVersion: this.clientVersion,
appVersion: 'VeSync 4.1.10 build2',
deviceRegion: 'EU',
phoneBrand: 'iPhone 8 Plus',
token: this.session.token,
Expand Down Expand Up @@ -759,7 +748,7 @@ class Vesync extends utils.Adapter {
source: 'APP',
method: command,
},
appVersion: this.clientVersion,
appVersion: 'VeSync 4.1.10 build2',
deviceRegion: 'EU',
phoneBrand: 'iPhone 8 Plus',
token: this.session.token,
Expand Down
Loading

0 comments on commit 6df6980

Please sign in to comment.