Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Discovery OK but impossible to config mss310 #69

Closed
No-Smart opened this issue Sep 5, 2021 · 13 comments
Closed

Discovery OK but impossible to config mss310 #69

No-Smart opened this issue Sep 5, 2021 · 13 comments
Labels
enhancement New feature or request fixed Upcoming fix/feature already on dev

Comments

@No-Smart
Copy link

No-Smart commented Sep 5, 2021

I have 4 device Meross mss310 discovery+automatic configuration OK, bat the last device i buy mss310 is only discovered and not configure!

what is happening?
Meross LAN asks me for the key, before it was generated / discovered automatically

@krahabb
Copy link
Owner

krahabb commented Sep 5, 2021

Hello @No-Smart,
If discovery works but the device is not properly configured it is likely a 'key issue'.
I need more context in order to figure out a possible solution but this is what I can say from a general point of view:

Every device has a secret key used to communicate and this is set up when pairing the device. If your devices are paired to the official Meross app they all share the same key which is set from the app itself and recorded in your account configuration in Meross cloud.

This is a previous issue where we discussed a bit on how to fix key issues in meross_lan.

The first thing you can try, if your devices are paired to the original Meross app/cloud (that means meross_lan is using HTTP to communicate), is to leave the key field 'empty' in meross_lan device configuration so to see if the key-hack algorithm works. If this is the scenario and meross_lan is still not working with empty key then you'll need the real key from the device (following previous thread/issue discussion)

If you can't figure out a solution so far, I would need the device trace. You can enable tracing by following https://github.com/krahabb/meross_lan#troubleshooting

@Gronda74
Copy link

I think I'm, encountering the same issue with a Meross MSS210 plug that recently had a firmware update. The plug is discovered but won't configure. I've tried working through the steps set out at https://github.com/albertogeniola/MerossIot/wiki/HTTP-APIs but can't get this to work (not sure where I'm going wrong but I get an error about the request taking longer than 30 seconds when I submit via https://web.postman.co/).

Is there any way of fishing the key out of my current config in Home Assistant given that I still have another Meross device connected and working?

@krahabb
Copy link
Owner

krahabb commented Sep 11, 2021

Well, I can't really direct you to an easy solution, but if you are using meross-homeassistant the login api is hidden there and access tokens together with the key are retrieved for sure and saved somewhere (at least in code if not persisted)

Following https://github.com/albertogeniola/MerossIot/wiki/HTTP-APIs I still can get my login tokens. Just to recap I'm using this 'pseudo-coded' payload

POST https://iot.meross.com/v1/Auth/Login HTTP/1.1
Content-Type: application/json

{
    "params": base64({"email": "YOUR_EMAIL", "password": "YOUR_PASSWORD"}),
    "sign": md5("23x17ahWarFH6w29" + timestamp + nonce + params),
    "timestamp": 0,
    "nonce": "9123456789ABCDEF"
}

using the dummy fields provided it should go like this:

POST https://iot.meross.com/v1/Auth/Login HTTP/1.1
Content-Type: application/json

{
    "params": "eyJlbWFpbCI6ICJZT1VSX0VNQUlMIiwgInBhc3N3b3JkIjogIllPVVJfUEFTU1dPUkQifQ==",
    "sign": "192a561b2f5d06d096a2b9be3c3f02b1",
    "timestamp": 0,
    "nonce": "9123456789ABCDEF"
}

I've used some online tools to base64 encode and md5 hash the fields and then I'm using a vs-code plugin to send the POST but any curl like utility should do

@Gronda74
Copy link

Thanks, this has helped cut down the cruft about headers from the other thread and I now get a 404 response, which is odd. Can you confirm that for timestamp you are just using 0 and not replacing that with a current timestamp?

@krahabb
Copy link
Owner

krahabb commented Sep 12, 2021

yes, I've just tried yesterday when posting my reply.
Keep in mind you have to 'stringify' the time so 0 means "0" when you concatenate the string to md5-hash.
I've just finished adding the previous code automated in meross_lan right when you setup your device and it is not working because of the key error.
I'm pushing right now to dev so you can eventually try it (I'm hiring you as a beta-tester ;)

EDIT:
well yeah the 404 looks strange..maybe a temporary issue with their servers?

@Gronda74
Copy link

Very happy to help :)

Currently not seeing any option to update from 2.2.1 in HACS (I have enabled show beta versions which I assume is the right step).

@krahabb
Copy link
Owner

krahabb commented Sep 12, 2021

Hello @Gronda74 ,

sorry for that. I was suggesting you to manually download the 'dev' branch from the repo but you pointed me to a very nice feature I could exploit and didn't know.
I'm going to publish a beta release soon in order to be able to easily install it from HACS but I need some relax to figure out the process. I'm in a 'deep coding session' and I would rather not interrupt that.

Nevertheless, I think you are close enough with manually inquiring the Meross api endpoint. Did you check the url and the verb were spelled correctly? maybe the 404 issue was due to a typo or any other transient issue.

@krahabb
Copy link
Owner

krahabb commented Sep 15, 2021

Hello @Gronda74,
I've published (beta release 2.3.0.beta) the feature so you could be able to try it if you're still on the issue
Thank you

@Gronda74
Copy link

Hey, thanks for getting back to this. I did try manually installing the dev channel earlier in the week but it acted the same way.

I've just updated to 2.3.0 beta and still no joy - the device is detected and I click configure. it populates with the right IP address (192.168.1.76) which is manually set, and I add http:// manually before clicking submit. I get a spinning blue wheel for a few seconds and then an "Unable to connect" message.

@krahabb
Copy link
Owner

krahabb commented Sep 15, 2021

Hello @Gronda74 ,
thank you for quickly replying. The 'http://' preamble is not needed and mostly dangerous: the host field just needs the device ip/address with nothing else. That is likely the reason of the 'Unable to connect' error.
If you set the address and leave the key empty (or wrong at any rate) you'll get the 'invalid key' error: at the point just SUBMIT again without editing any and you'll be prompted for your Meross credentials in order to retrieve the device key from your account configuration.
If it works you'll get again to the config dialog pre-filled with the right key fetched from the cloud: cross-fingers and SUBMIT again to see if it works

@Gronda74
Copy link

Ah. I was adding the http as it took longer to get to the unable to connect message. Without it as soon as I press submit I get unable to connect immediately.

But then prompted by your comment about leaving the key wrong, rather than having it blank I entered "abc123" and hit submit. That then gave me a different error message prompting me to press submit again which then brought up the username / password dialog for the Meross site and after that I got the key filled in! I've now been able to add the socket back into HA and it's up and running :)

This is brilliant, thank you so much!

@krahabb
Copy link
Owner

krahabb commented Sep 15, 2021

Yeah, leaving 'blank' instructs my code to try the 'old' key-hack mechanism which is likely unstable/random so it could work but there are probably some firmwares that 'raise the bar' so the trick doesn't always work flawlessly.

I'll refine the config flow to better streamline the UX based on your experience: Thank you!!!

@Gronda74
Copy link

Very happy to help. Let me know if I can do / test anything else.

@krahabb krahabb added enhancement New feature or request fixed Upcoming fix/feature already on dev labels Sep 18, 2021
@krahabb krahabb closed this as completed Sep 28, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request fixed Upcoming fix/feature already on dev
Projects
None yet
Development

No branches or pull requests

3 participants