Meross Garage Opener

The problem is that when opened/closed, Meross devices push their open/close status to a Meross MQTT server in the cloud. They don't send anything locally. So the driver has to specifically ask them. "Hey are you open/closed?" It does this every 5 min for performance reasons. So any rules you have to trigger on the garage opening may be delayed by up to 5 min. If you are just testing in the middle of another rule, you could probably run the the refresh command before preforming the test. I'm not great at rule machine though.

Maybe the driver could add a runIn(30, refresh) to the end of the open and close commands? Then it would update the status 30 seconds after you run the "open" command. Of course this wouldn't change anything if you open using the meross app.

1 Like

This has stopped working for me as of late. I can occasionally get it to connect to refresh, but it will not send a command. Testing via postman just consistently returns an error saying the socket disconnected. I did the http catcher again and reset my message id, sign, and timestamp within the device settings which did not help. Reset the device by powering it down. Gave it a new IP address. I am still able to control it thru the Meross app via their cloud, but not locally thru HE. I guess I should add I am using this with the MSG100 garage door opener.

Meross put out a firmware update that patched some vulnarabilites that prevent the same MessageId, Sign, and Timestamp from being used. I managed to fix it and created a pull request on Github. Firmware update by coKaliszewski · Pull Request #4 · ithinkdancan/hubitat-meross (github.com) You'll need a Key that is provided from Meross when you login and can get it by running this script (github.com). You'll need to have Python installed to run it. The key is unique to your account so you only need to get it once.

3 Likes

Cool thx. I will give it a shot.

I was able to run your script and
get the key for my device, I then brought down your updated driver from github into HE. I am getting the following errors in the log. I removed my device and re-added it back.


I forgot to add a check for null values. I pushed changes to the same branch if you want to give that a shot.

1 Like

Working well. Thanks!!

Hi All! New to Hubitat and Home automation :slight_smile: so bear with me a bit.

I am using @Demon 's latest changes that support the Key based authentication and able to correctly get door open/close status. Unable to send "close"/"open" instructions though. Keeps failing with "The target server failed to respond".

Also, anyone know what the UUID here in the preferences is? Is it the Device UUID or a random UUID? if device uuid, how do I get that?

UPDATE - I fixed this, you do need to set up Charles Proxy (and disable firewalls on your machine). Connect your mobile device to that proxy. Once that is set up, you should be able to sniff requests from the mobile device to the garage door opener via the Meross App. That gives you the UUID and the other parameters that should be a part of your request. In my case it was a combination of the python script and the Charles Proxy work.

@Demon Thanks for this. I wondered why it had just stopped after the last upgrade. Used your script + new driver and works fine on my MSG100!

Any chance another firmware update squashed this? I'm setting it up for the first time, and everything seemed to go as described. But I don't have control or see status. I'm seeing the "The target server failed to respond" errors in the log.

Hello. I'm trying to get this to work at home and need a little help. I have the MSG200. I was able to make the API call with Chrome to get my credentials, and I added a new virtual device and selected the Meross driver. I set all the preferences on the device, and I reserved an IP address for the device in my eero router. I wasn't sure what the UUID was, but I'm assuming its the "token" returned from the API call, correct? In either case, I am seeing "error request failed" in the logs. Any ideas how to get this to work?

I figured it out. First, there is a bug in the driver code. Since I'm installing for the first time, there was no version number recorded. So it was defaulting to 0, and therefore not using the code for the newer firmware version. I changed the lines in the refresh and sendCommand functions to default to 323 instead of 0 when no version found, and that allowed it to communicate. Once I made this change, I was able to click "Refresh" on the virtual device and it was then able to query the status of the garage door (and version number then showed up on device page).

This is the line I changed (same line in refresh and sendCommand methods):

    def currentVersion = device.currentState('version')?.value ? device.currentState('version')?.value.replace(".","").toInteger() : 323

Then I had to figure out my UUID. That was a pain. I tried that Charles Proxy sniffer on my iOS, but when enabled the Meross app would not work, and it would not capture the request being sent. But I was able to modify the code and execute the code below in the same chrome inspect window where I copied/pasted the script from GITHUB (https://github.com/ithinkdancan/hubitat-meross/blob/main/login.js) to get the key info. Then I executed this method (below), replacing "TOKEN" with the token value received from the previous call. This gave me a list of my devices with their UUIDs. I then plugged that UUID into the device settings, and it worked!

(async function test(token) {
  var nonce = randomString(16);
  var unix_time = Math.floor(new Date().getTime() / 1000);

  var param = "e30=";
  var encoded_param = param;

  concat_sign = ["23x17ahWarFH6w29", unix_time, nonce, encoded_param].join("");
  var sign = md5(concat_sign);

  var data = {
    params: encoded_param,
    sign: sign,
    timestamp: parseInt(unix_time, 10),
    nonce: nonce,
  };

  try {
    const response = await fetch("https://iot.meross.com/v1/Device/devList", {
      headers: {
         "Content-Type": "application/json",
         "Authorization": "Basic " + token
      },
      method: "POST",
      body: JSON.stringify(data),
    });

    const result = await response.json();
    console.log(result);
    
  } catch (error) {
    console.log({ error });
  }
  
    
})(“TOKEN”);

Sharing this so anyone else who wants to use this can get it working correctly. I'd suggest updating the code and eliminate the check for version and the extra settings, since I don't think you need to support the older firmware versions anymore (plus, no reason to enter message ID and sign and other fields when they are auto-generated by the code for the newer firmware version anyway).

6 Likes

Hello,
I've my Hubitat for only 2 weeks, so it's all new for me.
I've managed to get a few devices working. But now I'm trying to get my Meross garage door opener (MSG100) working. When i run the script from GITHUB (https://github.com/ithinkdancan/hubitat-meross/blob/main/login.js). I receive key, token,... In Hubitat I can see the status of the Meross opener, but can not open or close it.
I think I need the UUID. Therefore I've tried the scrip here above (from ajardolino3). I've replaced Token in the bottom line with the token I received from the other script, but I only get an error message : "Uncaught SyntaxError: Invalid or unexpected token".
Anyone an idea what i'm doing wrong ?

Do you use the token immediately after requesting it using the login script? That token will expire.

I just tried it again, and it worked. This is what I did:

  1. Go To https://iot.meross.com/v1/Auth/login.
  2. Copy login.js script into console window, replace USERNAME and PASSWORD and execute.
  3. Save "token" value returned by script.
  4. Copy paste my code (above) into the console window, replace TOKEN with value from previous API call.
  5. Got back a success message with list of UUIDS.
2 Likes

@ajardolino3,
Thank you for your step-by-step explanation. I followed them, but got an error again.
Suddenly I noticed that the quotes around TOKEN are different than in the rest of the script. I changed them and then it worked.

Thank you so much for your script and the time you put into it. My garage door finally works in Hubitat :smiley:

foute haakjes

Juiste haakjes

1 Like

@ajardolino3 The version number code change resolved this for me. I had everything else configured properly, but was pounding my head about why my device wasn't responding. I had previously noticed those 0s in the driver code (Thinking "Is there really a version zero?!), but couldn't quite process what to do about it.

Since previously giving up on this, I ended up using the (convoluted and somewhat unreliable) IFTTT approach that others have used. This is working so much better than that. Thanks!

Only problem with using IFTTT is now you are dependent on the internet for your garage door to work. Someone should really update the device driver for hubitat so it pulls the UUIDs automatically for you instead of having to run javascript in a browser console. @ithinkdancan - is this possible?

1 Like

Or just use a zen 16 and a security 2.0 to dry contact button.

I'm trying to get this to work. I think i followed all the steps using chrome.
Is the UUID the "userid" from the chrome console?

I'm getting these errors


1 Like