Skip to content

Commit

Permalink
prep
Browse files Browse the repository at this point in the history
  • Loading branch information
bwp91 committed Dec 29, 2023
1 parent 3ccc90b commit 9c3e968
Show file tree
Hide file tree
Showing 6 changed files with 48 additions and 7 deletions.
14 changes: 14 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,20 @@ This project tries to adhere to [Semantic Versioning](http://semver.org/). In pr
- `MINOR` version when a new device type is added, or when a new feature is added that is backwards-compatible
- `PATCH` version when backwards-compatible bug fixes are implemented

## 10.2.8 (2023-12-29)

⚠️ A note for users using MFA/2FA with Meross

- If you are not using MFA/2FA, you can ignore this message
- If you are using MFA/2FA:
- You will need to update the plugin config to include the current code from your authenticator app, otherwise the plugin will not be able to log in
- The code is only valid for 30 seconds, so you will need to update your config and restart Homebridge within this time
- You will currently need to do this every time you restart Homebridge, until I can find a better way to handle this

### Fixed

- Login issues

## 10.2.7 (2023-12-28)

### Fixed
Expand Down
12 changes: 11 additions & 1 deletion config.schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,14 +21,23 @@
"type": "string",
"description": "Enter your Meross password to enable cloud devices."
},
"mfaCode": {
"title": "Meross MFA Key",
"type": "string",
"description": "Enter the 6 digit code from your MFA app.",
"maxLength": 6,
"condition": {
"functionBody": "return model.username && model.password;"
}
},
"userkey": {
"title": "Meross Key",
"type": "string",
"description": "Enter your Meross key to enable local devices. You don't need to enter this if you have entered your username and password above, even for local devices. For help with obtaining this value see <a href=\"https://github.com/bwp91/homebridge-meross/wiki/Local-Control\" target=\"_blank\">the wiki</a>.",
"minLength": 32,
"maxLength": 32,
"condition": {
"functionBody": "return !(model.username && model.password);"
"functionBody": "return !(model.username || model.password);"
}
},
"connection": {
Expand Down Expand Up @@ -1727,6 +1736,7 @@
"layout": [
"username",
"password",
"mfaCode",
"userkey",
"ignoreHKNative",
"ignoreMatter",
Expand Down
16 changes: 15 additions & 1 deletion lib/connection/http.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@ export default class {
this.ignoredDevices = platform.ignoredDevices;
this.ignoreHKNative = platform.config.ignoreHKNative;
this.ignoreMatter = platform.config.ignoreMatter;
this.localUUIDs = platform.localUUIDs;
this.log = platform.log;
this.mfaCode = platform.config.mfaCode;
this.password = platform.config.password;
this.username = platform.config.username;
this.userkey = platform.config.userkey;
Expand All @@ -37,6 +37,18 @@ export default class {
const loginParams = encodeParams({
email: this.username,
password: this.password,
encryption: 0,
accountCountryCode: '--',
mobileInfo: {
resolution: '--',
carrier: '--',
deviceModel: '--',
mobileOs: '--',
mobileOSVersion: '--',
uuid: '--',
},
agree: 1,
mfaCode: this.mfaCode || undefined,
});

// Generate the md5-hash (called signature)
Expand Down Expand Up @@ -78,6 +90,8 @@ export default class {
.trim();
return await this.login();
}
} else if (res.data.apiStatus === 1033) {
throw new Error(platformLang.mfaFail);
}
throw new Error(res.data.info || `${platformLang.loginFail} - ${JSON.stringify(res.data)}`);
}
Expand Down
11 changes: 6 additions & 5 deletions lib/platform.js
Original file line number Diff line number Diff line change
Expand Up @@ -253,18 +253,19 @@ export default class {
}
this.config[key] = val === 'false' ? false : !!val;
break;
case 'name':
case 'platform':
break;
case 'domain':
case 'mfaCode':
case 'password':
case 'username':
case 'domain':
if (typeof val !== 'string') {
logIgnore(key);
} else {
this.config[key] = val;
}
break;
case 'name':
case 'platform':
break;
case 'userkey':
if (typeof val !== 'string') {
logIgnore(key);
Expand Down Expand Up @@ -337,7 +338,7 @@ export default class {
// Initialise the cloud configured devices into Homebridge
cloudDevices.forEach((device) => this.initialiseDevice(device));
} catch (err) {
const eText = parseError(err, [platformLang.missingCreds]);
const eText = parseError(err, [platformLang.mfaFail, platformLang.missingCreds]);
this.log.warn('%s %s.', platformLang.disablingCloud, eText);
this.cloudClient = false;
this.accountDetails = {
Expand Down
1 change: 1 addition & 0 deletions lib/utils/constants.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ export default {
name: 'Meross',
username: '',
password: '',
mfaCode: '',
userkey: '',
ignoreHKNative: false,
ignoreMatter: false,
Expand Down
1 change: 1 addition & 0 deletions lib/utils/lang-en.js
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ export default {
loginFail: 'login failed',
logout: 'Meross session closed and logged out',
merossKey: 'Meross Key',
mfaFail: 'MFA code missing or incorrect - please update your config',
missingCreds: 'username and password not supplied in config',
missingModal: 'missing config property \'model\' for this device',
noCredentials: 'Neither of username and password nor user key has been configured, or there was an issue obtaining cloud devices',
Expand Down

0 comments on commit 9c3e968

Please sign in to comment.