jixunmoe / meross-login

meross login info fetcher tool

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Un-official meross-cli

Prerequisite

Install node v14+, then run npm ci --prod to setup dependencies.

Usage

For command and its flags, run node meross help for built-in usage & help.

Commands

Currently implemented commands:

  • login
  • generate-config

Run node meross <command> --help for command help.

Getting Started

Run generate-config command to generate a random mobile config (uuid):

node meross generate-config

Then run the script to fetch user info:

# Login to US region (default)
node meross login "jixun.moe@your.email.com" "your-password"

# Login to EU region
node meross login --region EU "jixun.moe@your.email.eu" "your-password"

Your should see the following:

{
  "apiStatus": 0,
  "sysStatus": 0,
  "data": {
    "token": "ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff",
    "key": "ffffffffffffffffffffffffffffffff",
    "userid": "123456789",
    "email": "jixun.moe@your.email.com",
    "domain": "https://us-iot.meross.com",
    "mqttDomain": "mqtt-us.meross.com"
  },
  "info": "Success",
  "timeStamp": 123456789
}

... along with a message login ok! save to user.json....

Deprecated

Old login script, us region only:

node src/bin/do-login.js "jixun.moe@your.email.com" "your-password"

API Region Error

In the case of region error:

{
  "apiStatus": 1030,
  "sysStatus": 0,
  "data": {
    "domain": "https://us-iot.meross.com",
    "mqttDomain": "mqtt-us.meross.com"
  },
  "info": "redirect app to login other than this region",
  "timeStamp": 1623977935
}

Update RemoteAPI::remoteBase to the new data.domain field value.

The us-iot.meross.com domain is enabled by default.

Some notes about user data usage for Meross API

key is required to sign your request to Meross' IOT device, in some cases.

See Robdel12/homebridge-meross-plug#1 for more technical information.

  private static BaseBean setupSign(String strFrom, String strMethod, String strNamespace) {  // setup some signature stuff
    BaseBean bean = new BaseBean();
    Header header = new Header();
    long time = System.currentTimeMillis() / 1000; // unix seconds
    String messageId = PackageFactory.generateMessageId(); // random MD5 string
    header.setMessageId(messageId);
    header.setSign(PackageFactory.calculateMD5AllParts(messageId, User.getInstance().key, String.valueOf(time)).toLowerCase());
    header.setFrom(strFrom);
    header.setTimestamp(Long.valueOf(time));
    header.setMethod(strMethod);
    header.setNamespace(strNamespace);
    header.setPayloadVersion(Integer.valueOf(1));
    bean.setHeader(header);
    return bean;
  }

Where:

const calculateMD5AllParts = (a, b, c) => md5(a + b + c).toString('hex');
const generateMessageId = () => md5('anything unique').toString('hex');

For an example of the header, see: Robdel12/homebridge-meross-plug/src/index.js#L146

TODO

  • Publish this npm package somewhere (github/npmjs)
  • Publish to ghcr.io as a docker container
  • Instruction on how to contribute / debug / capture

Source

  • meross_v2.28.1.apk

License

The 3-Clause BSD License

About

meross login info fetcher tool

License:BSD 3-Clause "New" or "Revised" License


Languages

Language:JavaScript 100.0%