Meross Garage Opener

When I add this device and fill out the parameters it locks up my hub. Only thing I see different then in the documentation is mine is reporting version 4. Any idea? And thanks for your work on this.

Tried again left both with the ports set at 1 and they worked.

Thanks for the driver @ithinkdancan. It works great with my MSG100. Looks like it gets the status every 5 minutes, which is good enough for setting up notifications that I left the garage door open.

Worked well - thank you!

I have just configured this on my MSG100 and it works fine to open and close the garage door. One small quibble, though. Once open, the garage door reports its state to Hubitat as 'closed' again, as soon as it is open, before it actually closes again. Are other people getting this or is it just me? But otherwise great and it does what's required. Would be great to be able to test the state to evaluate whether to do an an action (e.g. close the garage door in my case - a sadly hourly requirement in my place).

Yes, that is how mine behaves. It does have a cron task that runs every five minutes and refreshes the device state.

Out of interest, how and when do you test that in HE? I was really hoping that the open/closed sensor which comes with the Meross device (which its own software knows how to report on) would be readable by the driver.

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 ?